本文整理汇总了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)
示例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",