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


Python SessionConfiguration.plot_map方法代码示例

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


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

示例1: visualize

# 需要导入模块: from opus_core.session_configuration import SessionConfiguration [as 别名]
# 或者: from opus_core.session_configuration.SessionConfiguration import plot_map [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,
#.........这里部分代码省略.........
开发者ID:apdjustino,项目名称:DRCOG_Urbansim,代码行数:103,代码来源:matplotlib_map.py

示例2: visualize

# 需要导入模块: from opus_core.session_configuration import SessionConfiguration [as 别名]
# 或者: from opus_core.session_configuration.SessionConfiguration import plot_map [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, table_name + "." + self.get_file_extension())

                        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,
                            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,
                            project_name=source_data.project_name
                            # 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)

        visualization_representations = []
        for indicator_names, table_name, years in viz_metadata:
            visualization_representations.append(
                self._get_visualization_metadata(
                    computed_indicators=computed_indicators,
                    indicators_to_visualize=indicator_names,
                    table_name=table_name,
                    years=years,
                )
            )

        return visualization_representations
开发者ID:psrc,项目名称:urbansim,代码行数:101,代码来源:mapnik_map.py


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