Ejemplo n.º 1
0
    def run(self, macro_group_name, year, output_file=None):
        """This is the main entry point.  It is initialized with the appropriate values from the 
        travel_model_configuration part of this config, and then runs the specified 
        emme/2 macros. The macro specification should also have a specification of the bank it should run in.
        'macro_group_name' is the group name of the macros, such as 'export_macros'.
        The macros should live in the base directory of travel model, subdirectory given by the entry 'path' in each macro.  
        'config' must contain an entry ['travel_model_configuration'][year][macro_group_name].
        """
        from opus_emme2.travel_model_output import TravelModelOutput
        import opus_emme2
        tm_output = TravelModelOutput(self.emme_cmd)
        specified_macros = self.config['travel_model_configuration'][year][
            macro_group_name]
        if output_file is None:
            tmp_output_file = os.path.join(
                self.config['cache_directory'],
                "emme2_export_macros_%s_log.txt" % year)
        else:
            tmp_output_file = output_file
        ## if tmp_output_file is a remote sftp URL, redirect file to local tempdir
        tmp_output_file = redirect_sftp_url_to_local_tempdir(tmp_output_file)

        for macro_name, macro_info in specified_macros.iteritems():
            bank = macro_info['bank']
            bank_path = self.get_emme2_dir(year, bank)
            macro_path = os.path.join(self.get_emme2_base_dir(),
                                      macro_info.get('path', ''), macro_name)
            tm_output.run_emme2_macro(macro_path,
                                      bank_path,
                                      macro_info['scenario'],
                                      output_file=tmp_output_file)
 def create_output_matrix_files(self, year, max_zone_id):
     """Create data files with emme2 matrices."""
     from opus_emme2.travel_model_output import TravelModelOutput
     tm_output = TravelModelOutput(self.emme_cmd)
     year_config = self.config['travel_model_configuration'][year]
     for x in 1,2,3:
         if "bank%i" % x in year_config['matrix_variable_map']:
             bank_dir = self.get_emme2_dir(year, "bank%i" % x)
             for matrix_name in year_config['matrix_variable_map']["bank%i" % x].keys():
                 tm_output._get_matrix_into_data_file(matrix_name, max_zone_id, bank_dir, "%s_one_matrix.txt" % matrix_name)
 def get_node_travel_data_from_emme2(self, bank_dir, node_matrix_variable_map):
     """Create a new node travel_data from the emme2 output.
     Include the matrices listed in node_matrix_variable_map, which is a dictionary
     mapping the emme2 matrix name, e.g. au1tim, to the Opus variable
     name, e.g. single_vehicle_to_work_travel_time, as in:
     {"au1tim":"single_vehicle_to_work_travel_time"}
     """
     from opus_emme2.travel_model_output import TravelModelOutput
     tm_output = TravelModelOutput(self.emme_cmd)
     return tm_output.get_node_travel_data_set(node_matrix_variable_map, bank_dir)
Ejemplo n.º 4
0
 def get_node_travel_data_from_emme2(self, bank_dir,
                                     node_matrix_variable_map):
     """Create a new node travel_data from the emme2 output.
     Include the matrices listed in node_matrix_variable_map, which is a dictionary
     mapping the emme2 matrix name, e.g. au1tim, to the Opus variable
     name, e.g. single_vehicle_to_work_travel_time, as in:
     {"au1tim":"single_vehicle_to_work_travel_time"}
     """
     from opus_emme2.travel_model_output import TravelModelOutput
     tm_output = TravelModelOutput(self.emme_cmd)
     return tm_output.get_node_travel_data_set(node_matrix_variable_map,
                                               bank_dir)
Ejemplo n.º 5
0
 def create_output_matrix_files(self, year, max_zone_id):
     """Create data files with emme2 matrices."""
     from opus_emme2.travel_model_output import TravelModelOutput
     tm_output = TravelModelOutput(self.emme_cmd)
     year_config = self.config['travel_model_configuration'][year]
     for x in 1, 2, 3:
         if "bank%i" % x in year_config['matrix_variable_map']:
             bank_dir = self.get_emme2_dir(year, "bank%i" % x)
             for matrix_name in year_config['matrix_variable_map'][
                     "bank%i" % x].keys():
                 tm_output._get_matrix_into_data_file(
                     matrix_name, max_zone_id, bank_dir,
                     "%s_one_matrix.txt" % matrix_name)
Ejemplo n.º 6
0
 def run(self, macro_group_name, year, output_file=None):
     """This is the main entry point.  It is initialized with the appropriate values from the 
     travel_model_configuration part of this config, and then runs the specified 
     emme/2 macros. The macro specification should also have a specification of the bank it should run in.
     'macro_group_name' is the group name of the macros, such as 'export_macros'.
     The macros should live in the base directory of travel model, subdirectory given by the entry 'path' in each macro.  
     'config' must contain an entry ['travel_model_configuration'][year][macro_group_name].
     """
     from opus_emme2.travel_model_output import TravelModelOutput
     import opus_emme2
     tm_output = TravelModelOutput(self.emme_cmd)
     specified_macros = self.config['travel_model_configuration'][year][macro_group_name]
     if output_file is None:
         tmp_output_file = os.path.join(self.config['cache_directory'], "emme2_export_macros_%s_log.txt" % year)
     else:
         tmp_output_file = output_file
     ## if tmp_output_file is a remote sftp URL, redirect file to local tempdir
     tmp_output_file = redirect_sftp_url_to_local_tempdir(tmp_output_file)
     
     for macro_name, macro_info in specified_macros.iteritems():
         bank = macro_info['bank']
         bank_path = self.get_emme2_dir(year, bank)
         macro_path = os.path.join(self.get_emme2_base_dir(), macro_info.get('path',''), macro_name)
         tm_output.run_emme2_macro(macro_path, bank_path, macro_info['scenario'], output_file=tmp_output_file)