Example #1
0
    def run(self, config, year, *args, **kwargs):
        """Runs the travel model, using appropriate info from config. 
        """
        tm_config = config["travel_model_configuration"]
        self.prepare_for_run(tm_config, year)
        
        scenarioDirectory = tm_config.get('scenario_directory')
        genericDirectory = tm_config.get('generic_directory')
        #project_year_dir = get_project_year_dir(tm_config, year)
        
        logger.log_status('Start travel model from directory %s for year %d' % (scenarioDirectory, year))
        macroname, ui_db_file = tm_config['macro']['run_transcad_travel_model'], tm_config['ui_file']

        #loops = 1
        macro_args = [["scenarioDirectory", scenarioDirectory],
                      ["genericDirectory", genericDirectory],
                      ["year", year],
                      #["Options", [0]*10]
                  ]

        logger.log_status('Running travel model ...')
        tcwcmd = win32api.GetShortPathName(tm_config['transcad_binary'])

        os.system('start /B "start TransCAD" %s' % tcwcmd)  #start TransCAD in background
        time.sleep(1)
        #os.system("%s -a %s -ai '%s'" % (tcwcmd, ui_db_file, macroname))
        run_transcad_macro(macroname, ui_db_file, macro_args)
Example #2
0
    def _update_travel_model_data_file(self, config, 
                                       data, 
                                       header, 
                                       filepath, 
                                       #datatable, #name of travel model TAZ Data Table
                                       #joinfield, 
                                       #delimiter='\t',
                                      *args, **kwargs):

        #self._write_to_xls_file(data, header, filepath)
        scenarioDirectory = config.get('scenario_directory')
        genericDirectory = config.get('generic_directory')
        exchangeDirectory = os.path.split(os.path.split(filepath)[0])[0]
        year=kwargs.get('year')

        macro_args = [["scenarioDirectory", scenarioDirectory],
                      ["genericDirectory", genericDirectory],
                      ["exchangeDirectory", exchangeDirectory],
                      ["year", year]
                  ]
        
        macroname, ui_db_file = config['macro']['get_cache_data_into_transcad'], config['ui_file']
        run_transcad_macro(macroname, ui_db_file, macro_args)