本文整理汇总了Python中opus_core.session_configuration.SessionConfiguration.get_coordinate_system方法的典型用法代码示例。如果您正苦于以下问题:Python SessionConfiguration.get_coordinate_system方法的具体用法?Python SessionConfiguration.get_coordinate_system怎么用?Python SessionConfiguration.get_coordinate_system使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opus_core.session_configuration.SessionConfiguration
的用法示例。
在下文中一共展示了SessionConfiguration.get_coordinate_system方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from opus_core.session_configuration import SessionConfiguration [as 别名]
# 或者: from opus_core.session_configuration.SessionConfiguration import get_coordinate_system [as 别名]
def __init__(self, name_of_dataset_to_merge, in_table_name, attribute_cache, years_to_merge, *args, **kwargs):
"""Create a dataset that contains this many years of data from this dataset.
Years are from current year backwards, inclusive.
"""
self.name_of_dataset_to_merge = name_of_dataset_to_merge
self.years_to_merge = years_to_merge
self._validate_primary_attributes_same_for_all_years(name_of_dataset_to_merge, in_table_name, attribute_cache, years_to_merge)
# Add 'year' to id_names.
dataset_for_current_year = SessionConfiguration().get_dataset_from_pool(
self.name_of_dataset_to_merge)
id_names = dataset_for_current_year.get_id_name() + ['year']
self.base_id_name = dataset_for_current_year.get_id_name()
# Masquerade as a dataset of the right type (important for computing the right variables).
dataset_name = dataset_for_current_year.get_dataset_name()
AbstractDataset.__init__(self,
id_name=id_names,
in_table_name=in_table_name,
dataset_name=dataset_name,
*args, **kwargs)
coord_system = dataset_for_current_year.get_coordinate_system()
if coord_system is not None:
self._coordinate_system = coord_system
示例2: visualize
# 需要导入模块: from opus_core.session_configuration import SessionConfiguration [as 别名]
# 或者: from opus_core.session_configuration.SessionConfiguration import get_coordinate_system [as 别名]
def visualize(self,
indicators_to_visualize,
computed_indicators):
"""Create a map for the given indicator, save it to the cache
directory's 'indicators' sub-directory."""
#TODO: eliminate this example indicator stuff
example_indicator = computed_indicators[indicators_to_visualize[0]]
source_data = example_indicator.source_data
dataset_to_attribute_map = {}
package_order = source_data.get_package_order()
self._create_input_stores(years = source_data.years)
for name, computed_indicator in computed_indicators.items():
if name not in indicators_to_visualize: continue
if computed_indicator.source_data != source_data:
raise Exception('result templates in indicator batch must all be the same.')
dataset_name = computed_indicator.indicator.dataset_name
if dataset_name == 'parcel':
raise Exception('Cannot create a Matplotlib map for parcel dataset. Please plot at a higher geographic aggregation')
if dataset_name not in dataset_to_attribute_map:
dataset_to_attribute_map[dataset_name] = []
dataset_to_attribute_map[dataset_name].append(name)
viz_metadata = []
for dataset_name, indicator_names in dataset_to_attribute_map.items():
attributes = [(name,computed_indicators[name].get_computed_dataset_column_name())
for name in indicator_names]
for year in source_data.years:
SessionConfiguration(
new_instance = True,
package_order = package_order,
in_storage = AttributeCache())
SimulationState().set_cache_directory(source_data.cache_directory)
SimulationState().set_current_time(year)
dataset = SessionConfiguration().get_dataset_from_pool(dataset_name)
dataset.load_dataset()
if dataset.get_coordinate_system() is not None:
dataset.compute_variables(names = dataset.get_coordinate_system())
for indicator_name, computed_name in attributes:
indicator = computed_indicators[indicator_name]
table_data = self.input_stores[year].load_table(
table_name = dataset_name,
column_names = [computed_name])
if computed_name in table_data:
table_name = self.get_name(
dataset_name = dataset_name,
years = [year],
attribute_names = [indicator_name])
if self.scale:
min_value, max_value = self.scale
else:
min_value, max_value = (None, None)
file_path = os.path.join(self.storage_location,
table_name+ '.' + self.get_file_extension())
dataset.add_attribute(name = str(computed_name),
data = table_data[computed_name])
if not os.path.exists(file_path):
dataset.plot_map(
name = str(computed_name),
min_value = min_value,
max_value = max_value,
file = str(file_path),
my_title = str(indicator_name),
#filter = where(table_data[computed_name] != -1)
#filter = 'urbansim.gridcell.is_fully_in_water'
)
# self.plot_map(dataset = dataset,
# attribute_data = table_data[computed_name],
# min_value = min_value,
# max_value = max_value,
# file = file_path,
# my_title = indicator_name,
# filter = where(table_data[computed_name] != -1))
metadata = ([indicator_name], table_name, [year])
viz_metadata.append(metadata)
else:
logger.log_warning('There is no computed indicator %s'%computed_name)
visualization_representations = []
for indicator_names, table_name, years in viz_metadata:
visualization_representations.append(
self._get_visualization_metadata(
computed_indicators = computed_indicators,
#.........这里部分代码省略.........
示例3: visualize
# 需要导入模块: from opus_core.session_configuration import SessionConfiguration [as 别名]
# 或者: from opus_core.session_configuration.SessionConfiguration import get_coordinate_system [as 别名]
def visualize(self, indicators_to_visualize, computed_indicators):
"""Create a map for the given indicator, save it to the cache
directory's 'indicators' sub-directory."""
# TODO: eliminate this example indicator stuff
example_indicator = computed_indicators[indicators_to_visualize[0]]
source_data = example_indicator.source_data
dataset_to_attribute_map = {}
package_order = source_data.get_package_order()
self._create_input_stores(years=source_data.years)
for name, computed_indicator in computed_indicators.items():
if name not in indicators_to_visualize:
continue
if computed_indicator.source_data != source_data:
raise Exception("result templates in indicator batch must all be the same.")
dataset_name = computed_indicator.indicator.dataset_name
if dataset_name not in dataset_to_attribute_map:
dataset_to_attribute_map[dataset_name] = []
dataset_to_attribute_map[dataset_name].append(name)
viz_metadata = []
for dataset_name, indicator_names in dataset_to_attribute_map.items():
attributes = [
(name, computed_indicators[name].get_computed_dataset_column_name()) for name in indicator_names
]
for year in source_data.years:
SessionConfiguration(new_instance=True, package_order=package_order, in_storage=AttributeCache())
SimulationState().set_cache_directory(source_data.cache_directory)
SimulationState().set_current_time(year)
dataset = SessionConfiguration().get_dataset_from_pool(dataset_name)
dataset.load_dataset()
if dataset.get_coordinate_system() is not None:
dataset.compute_variables(names=dataset.get_coordinate_system())
for indicator_name, computed_name in attributes:
indicator = computed_indicators[indicator_name]
table_data = self.input_stores[year].load_table(
table_name=dataset_name, column_names=[computed_name]
)
if computed_name in table_data:
table_name = self.get_name(
dataset_name=dataset_name, years=[year], attribute_names=[indicator_name]
)
if self.scale:
min_value, max_value = self.scale
else:
min_value, max_value = (None, None)
file_path = os.path.join(
self.storage_location, "anim_" + table_name + "." + MapnikMap.get_file_extension(self)
)
dataset.add_attribute(name=str(computed_name), data=table_data[computed_name])
dataset.plot_map(
name=str(computed_name),
min_value=min_value,
max_value=max_value,
file=str(file_path),
my_title=str(indicator_name),
color_list=self.color_list,
range_list=self.range_list,
label_list=self.label_list,
is_animation=True,
year=year,
resolution=self.resolution,
page_dims=self.page_dims,
map_lower_left=self.map_lower_left,
map_upper_right=self.map_upper_right,
legend_lower_left=self.legend_lower_left,
legend_upper_right=self.legend_upper_right
# filter = where(table_data[computed_name] != -1)
# filter = 'urbansim.gridcell.is_fully_in_water'
)
# metadata = ([indicator_name], table_name, [year])
# viz_metadata.append(metadata)
else:
logger.log_warning("There is no computed indicator %s" % computed_name)
for indicator_name, computed_name in attributes:
self.create_animation(
dataset_name=dataset_name,
year_list=source_data.years,
indicator_name=str(indicator_name),
viz_metadata=viz_metadata,
)
visualization_representations = []
#.........这里部分代码省略.........