@@ -0,0 +1,2502 @@
+# ActivitySim%0A# Copyright (C) 2016 RSG Inc%0A# See full license in LICENSE.txt.%0A%0Aimport os%0A%0Aimport pandas as pd%0Aimport openmatrix as omx%0A%0A%0Adef read_manifest(manifest_file_name):%0A%0A    column_map = %7B%0A        'Token': 'skim_key1',%0A        'TimePeriod': 'skim_key2',%0A        'File': 'source_file_name',%0A        'Matrix': 'source_key',%0A    %7D%0A    converters = %7B col: str for col in column_map.keys() %7D%0A%0A    manifest = pd.read_csv(manifest_file_name, header=0, comment='#', converters=converters)%0A%0A    manifest.rename(columns=column_map, inplace=True)%0A%0A    return manifest%0A%0A%0Adef omx_getMatrix(omx_file_name, omx_key):%0A%0A    with omx.openFile(omx_file_name, 'r') as omx_file:%0A%0A        if omx_key not in omx_file.listMatrices():%0A            print %22Source matrix with key '%25s' not found in file '%25s%22 %25 (omx_key, omx_file,)%0A            print omx_file.listMatrices()%0A            raise RuntimeError(%22Source matrix with key '%25s' not found in file '%25s%22 %25 (omx_key, omx_file,))%0A%0A        data = omx_file%5Bomx_key%5D%0A%0A    return data%0A%0A%0Amanifest_dir = '/Users/jeff.doyle/work/activitysim-data/mtc_tm1'%0Asource_data_dir = '/Users/jeff.doyle/work/activitysim-data/mtc_tm1/source_skims'%0Adest_data_dir = '/Users/jeff.doyle/work/activitysim-data/mtc_tm1/data'%0A%0Amanifest_file_name = os.path.join(manifest_dir, %22skim_manifest.csv%22)%0Adest_file_name = os.path.join(dest_data_dir, %22skims.omx%22)%0A%0Awith omx.openFile(dest_file_name, 'a') as dest_omx:%0A%0A    manifest = read_manifest(manifest_file_name)%0A%0A    for row in manifest.itertuples(index=True):%0A%0A        source_file_name = os.path.join(source_data_dir, row.source_file_name)%0A%0A        if row.skim_key2:%0A            dest_key = row.skim_key1 + '__' + row.skim_key2%0A        else:%0A            dest_key = row.skim_key1%0A%0A        print %22Reading '%25s' from '%25s' in %25s%22 %25 (dest_key, row.source_key, source_file_name)%0A        with omx.openFile(source_file_name, 'r') as source_omx:%0A%0A            if row.source_key not in source_omx.listMatrices():%0A                print %22Source matrix with key '%25s' not found in file '%25s%22 %25 (row.source_key, source_file_name,)%0A                print source_omx.listMatrices()%0A                raise RuntimeError(%22Source matrix with key '%25s' not found in file '%25s%22 %25 (row.source_key, omx_file,))%0A%0A            data = source_omx%5Brow.source_key%5D%0A%0A            if dest_key in dest_omx.listMatrices():%0A                print %22deleting existing dest key '%25s'%22 %25 (dest_key,)%0A                dest_omx.removeNode(dest_omx.root.data, dest_key)%0A%0A            dest_omx%5Bdest_key%5D = data%0A

move build_omx.py to scripts