当前位置: 首页>>代码示例>>Python>>正文


Python SessionConfiguration.get_attribute方法代码示例

本文整理汇总了Python中opus_core.session_configuration.SessionConfiguration.get_attribute方法的典型用法代码示例。如果您正苦于以下问题:Python SessionConfiguration.get_attribute方法的具体用法?Python SessionConfiguration.get_attribute怎么用?Python SessionConfiguration.get_attribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在opus_core.session_configuration.SessionConfiguration的用法示例。


在下文中一共展示了SessionConfiguration.get_attribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from opus_core.session_configuration import SessionConfiguration [as 别名]
# 或者: from opus_core.session_configuration.SessionConfiguration import get_attribute [as 别名]
    def __init__(self, config):
        if 'estimation_database_configuration' in config:
            db_server = DatabaseServer(config['estimation_database_configuration'])
            db = db_server.get_database(config['estimation_database_configuration'].database_name)
        
            out_storage = StorageFactory().build_storage_for_dataset(
                type='sql_storage', storage_location=db)
        else:
            out_storage = StorageFactory().get_storage(type='flt_storage',
                storage_location=os.path.join(config['cache_directory'], str(config['base_year']+1)))

        simulation_state = SimulationState()
        simulation_state.set_cache_directory(config['cache_directory'])
        simulation_state.set_current_time(config['base_year'])
        attribute_cache = AttributeCache()
        
        SessionConfiguration(new_instance=True,
                             package_order=config['dataset_pool_configuration'].package_order,
                             in_storage=attribute_cache)
        
        if not os.path.exists(os.path.join(config['cache_directory'], str(config['base_year']))):
            #raise RuntimeError, "datasets uncached; run prepare_estimation_data.py first"
            CacheScenarioDatabase().run(config, unroll_gridcells=False)

        for dataset_name in config['datasets_to_preload']:
            SessionConfiguration().get_dataset_from_pool(dataset_name)

        households = SessionConfiguration().get_dataset_from_pool("household")
        household_ids = households.get_id_attribute()
        workers = households.get_attribute("workers")
        
        hh_ids = []
        member_ids = []
        is_worker = []
        job_ids = []

        for i in range(households.size()):  
            if workers[i] > 0:
                hh_ids += [household_ids[i]] * workers[i]
                member_ids += range(1, workers[i]+1)
                is_worker += [1] * workers[i]
                job_ids += [-1] * workers[i]

        in_storage = StorageFactory().get_storage('dict_storage')
        
        persons_table_name = 'persons'
        in_storage.write_table(
                table_name=persons_table_name,
                table_data={
                    'person_id':arange(len(hh_ids))+1,
                    'household_id':array(hh_ids),
                    'member_id':array(member_ids),
                    'is_worker':array(is_worker),                    
                    'job_id':array(job_ids),
                    },
            )

        persons = PersonDataset(in_storage=in_storage, in_table_name=persons_table_name)
        persons.write_dataset(out_storage=out_storage, out_table_name=persons_table_name)
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:61,代码来源:expand_persons_from_households.py

示例2: are

# 需要导入模块: from opus_core.session_configuration import SessionConfiguration [as 别名]
# 或者: from opus_core.session_configuration.SessionConfiguration import get_attribute [as 别名]
# categorize months into group, and assign a sub_model id for each group
# we will estimate a set of coefficient for each sub model group
#category_bins = [2,4,6,8,10,12]
#sub_model_ids = consumption.categorize("month", category_bins) + 1 
#consumption.add_attribute(sub_model_ids, "sub_model_id")

#or
#"""Arranging consumption data by 2-month bill period"""
#print "Selecting data for bimonthly period"
months = [7, 8] # which two months to estimate and simulate
weather_attributes = ["t_max4"] # what are (is) the correspondent weather attribute name(s)

filter_indices = where(
    logical_and(
        logical_or(
            consumption.get_attribute("month") == months[0],
            consumption.get_attribute("month") == months[1],
            ),
        consumption.get_attribute('year') == year
        ),
    )[0]

index_est = filter_indices

# records consumption for a single year in given 2 months are less than 50000, so don't do sample
# but use full set by set index_set to None
#index_est = array(sample(month_index,50000))

#attache weather attribute to consumption data, as PRIMARY attribute

#consumption.join(weather, name=weather_attributes, join_attribute="year", 
开发者ID:psrc,项目名称:urbansim,代码行数:33,代码来源:consumption_weather_single_year_bellevue.py


注:本文中的opus_core.session_configuration.SessionConfiguration.get_attribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。