示例#1
0
def prepare_for_running_macro(parser):
    from opus_core.file_utilities import get_resources_from_file
    parser.add_option("-r",
                      "--resources",
                      dest="resources_file_name",
                      action="store",
                      type="string",
                      help="Name of file containing resources")
    parser.add_option("-y",
                      "--year",
                      dest="year",
                      action="store",
                      type="int",
                      help="Year in which to 'run' the travel model")
    parser.add_option(
        "-o",
        "--output-file",
        dest="output_file",
        action="store",
        type="string",
        default=None,
        help=
        "Output log file. If not given, it is written into urbansim cache directory."
    )
    (options, args) = parser.parse_args()

    r = get_resources_from_file(options.resources_file_name)
    resources = Resources(get_resources_from_file(options.resources_file_name))

    SessionConfiguration(
        new_instance=True,
        package_order=resources['dataset_pool_configuration'].package_order,
        in_storage=AttributeCache())
    return (resources, options)
示例#2
0
def main(model_system_class):
    s = model_system_class()
    parser = OptionParser()
    parser.add_option("-r", "--resources", dest="resources_file_name", action="store", type="string",
                      help="Name of file containing resources")
    parser.add_option("-d", "--delete-resources-file-directory", dest="delete_resources_file_directory",
                      action="store_true",
                      help="Delete the directory containing the pickled resources file when done?")
    parser.add_option("--skip-cache-after-each-year", dest="skip_cache_after_each_year", default=False,
                      action="store_true", help="Datasets will not be cached at the end of each year.")
    parser.add_option("--log-file-name", dest="log_file_name", default='run_model_system.log',
                      help="File name for logging output of model system (without directory).")

    (options, args) = parser.parse_args()

    resources = Resources(get_resources_from_file(options.resources_file_name))
    delete_resources_file_directory = options.delete_resources_file_directory
    skip_cache_after_each_year = options.skip_cache_after_each_year
    log_file_name = options.log_file_name
    RunModelSystem(model_system = s,
                   resources = resources,
                   skip_cache_after_each_year = skip_cache_after_each_year,
                   log_file_name = log_file_name)
    if delete_resources_file_directory:
        dir = os.path.split(options.resources_file_name)[0]
        rmtree(dir)
示例#3
0
def prepare_for_running_macro(parser):
    from opus_core.file_utilities import get_resources_from_file
    parser.add_option("-r", "--resources", dest="resources_file_name", action="store", type="string",
                      help="Name of file containing resources")
    parser.add_option("-y", "--year", dest="year", action="store", type="int",
                      help="Year in which to 'run' the travel model")
    parser.add_option("-o", "--output-file", dest="output_file", action="store", type="string", default=None,
                      help="Output log file. If not given, it is written into urbansim cache directory.")
    (options, args) = parser.parse_args()
   
    r = get_resources_from_file(options.resources_file_name)
    resources = Resources(get_resources_from_file(options.resources_file_name))
    
    SessionConfiguration(new_instance=True,
                         package_order=resources['dataset_pool_configuration'].package_order,                           
                         in_storage=AttributeCache())
    return (resources, options)
示例#4
0
def main(model_system_class):
    s = model_system_class()
    parser = OptionParser()
    parser.add_option("-r",
                      "--resources",
                      dest="resources_file_name",
                      action="store",
                      type="string",
                      help="Name of file containing resources")
    parser.add_option(
        "-d",
        "--delete-resources-file-directory",
        dest="delete_resources_file_directory",
        action="store_true",
        help=
        "Delete the directory containing the pickled resources file when done?"
    )
    parser.add_option(
        "--skip-cache-after-each-year",
        dest="skip_cache_after_each_year",
        default=False,
        action="store_true",
        help="Datasets will not be cached at the end of each year.")
    parser.add_option(
        "--log-file-name",
        dest="log_file_name",
        default='run_model_system.log',
        help="File name for logging output of model system (without directory)."
    )

    (options, args) = parser.parse_args()

    resources = Resources(get_resources_from_file(options.resources_file_name))
    delete_resources_file_directory = options.delete_resources_file_directory
    skip_cache_after_each_year = options.skip_cache_after_each_year
    log_file_name = options.log_file_name
    RunModelSystem(model_system=s,
                   resources=resources,
                   skip_cache_after_each_year=skip_cache_after_each_year,
                   log_file_name=log_file_name)
    if delete_resources_file_directory:
        dir = os.path.split(options.resources_file_name)[0]
        rmtree(dir)
示例#5
0
                'matsim_config_file': self.matsim_config_full,
                'test_parameter': self.test_parameter } 
        
        logger.log_status('Running command %s' % cmd ) 
        
        cmd_result = os.system(cmd)
        if cmd_result != 0:
            error_msg = "MATSim Run failed. Code returned by cmd was %d" % (cmd_result)
            logger.log_error(error_msg)
            logger.log_error("Note that currently (dec/08), paths in the matsim config files are relative to the matsim4opus root,")
            logger.log_error("which is one level 'down' from OPUS_HOME.")
            raise StandardError(error_msg)        
        
        logger.end_block()

# called from opus via main!
if __name__ == "__main__":
    from optparse import OptionParser
    from opus_core.file_utilities import get_resources_from_file
    parser = OptionParser()
    parser.add_option("-r", "--resources", dest="resources_file_name", action="store", type="string",
                      help="Name of file containing resources")
    parser.add_option("-y", "--year", dest="year", action="store", type="int",
                      help="Year in which to 'run' the travel model")
    (options, args) = parser.parse_args()

    resources = Resources(get_resources_from_file(options.resources_file_name))

    logger.enable_memory_logging()
    RunTravelModel().run(resources, options.year)    
    parser.add_option("-r",
                      "--resources",
                      dest="resources_file_name",
                      action="store",
                      type="string",
                      help="Name of file containing resources")
    parser.add_option(
        "-y",
        "--year",
        dest="year",
        action="store",
        type="int",
        help=
        "Year for which the emme2 directory is defined in the configuration.")
    parser.add_option(
        "-d",
        "--directory",
        dest="directory",
        action="store",
        type="string",
        default="triptabs.org",
        help=
        "Name of sub-directory containing original trip tables (relative to the emme2 directory)."
    )
    (options, args) = parser.parse_args()

    r = get_resources_from_file(options.resources_file_name)
    resources = Resources(get_resources_from_file(options.resources_file_name))

    RestoreTripTables().run(resources, options.directory, options.year)
    parser.add_option(
        "-d",
        "--alt-cache-dir",
        dest="alt_cache_dir",
        action="store",
        type="string",
        help="cache directory if pickled resources not available",
        default=None)
    (options, args) = parser.parse_args()

    #options here added by SFCTA
    if (options.alt_config is not None) and (options.alt_cache_dir
                                             is not None):
        resources = get_config_from_opus_path(options.alt_config)
        resources['cache_directory'] = options.alt_cache_dir
    elif options.resources_file_name is not None:
        r = get_resources_from_file(options.resources_file_name)
        resources = Resources(
            get_resources_from_file(options.resources_file_name))
    else:
        parser.print_help()
        sys.exit(1)

    SessionConfiguration(
        new_instance=True,
        package_order=resources['dataset_pool_configuration'].package_order,
        in_storage=AttributeCache())

    #    logger.enable_memory_logging()
    GetTravelModelDataIntoCache().run(resources, options.year)