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


Python DatasetSubset._create_id_mapping方法代码示例

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


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

示例1: run

# 需要导入模块: from opus_core.datasets.dataset import DatasetSubset [as 别名]
# 或者: from opus_core.datasets.dataset.DatasetSubset import _create_id_mapping [as 别名]
    def run(self, current_year_emme2_dir, current_year, dataset_pool, config=None):
        """Writes to the an emme2 input file in the [current_year_emme2_dir]/tripgen/inputtg/tazdata.ma2.
        """
        
        missing_dataset = ''
        try:
            missing_dataset = 'constant_taz_column'
            taz_col_set = dataset_pool.get_dataset("constant_taz_column")
            taz_col_set.load_dataset()
            missing_dataset = 'zone'
            zone_set = dataset_pool.get_dataset("zone")
            zone_set.load_dataset()
            missing_dataset = 'household'
            household_set = dataset_pool.get_dataset("household")
        except:
            raise Exception("Dataset %s is missing from dataset_pool" % missing_dataset)
        
        """specify travel input file name: [current_year_emme2_dir]/tripgen/inputtg/tazdata.ma2 """
        full_path = os.path.join(current_year_emme2_dir, 'tripgen', 'inputtg')
        if not os.path.exists(full_path):
            os.makedirs(full_path)
        tm_input_file = os.path.join(full_path, 'tazdata.ma2')
        
        tm_year = self._decade_floor(current_year)
        
        logger.log_status("calculating entries for emme2 input file")
        taz_col_set.compute_variables("zone_id=constant_taz_column.taz")
        current_taz_col = DatasetSubset(taz_col_set, index=where(taz_col_set.get_attribute("year")==tm_year)[0])
        
        current_taz_col._id_names = ['taz']
        current_taz_col._create_id_mapping()
        zone_set.join(current_taz_col, "pctmf", join_attribute='zone_id')
        zone_set.join(current_taz_col, "gqi", join_attribute='zone_id')
        zone_set.join(current_taz_col, "gqn", join_attribute='zone_id')
        zone_set.join(current_taz_col, "fteuniv", join_attribute='zone_id')
        zone_set.join(current_taz_col, "den", new_name='density', join_attribute='zone_id')

        value_122 = zeros(zone_set.size())
        index_122 = zone_set.try_get_id_index(array([58,59,60,71,72,73,84,85,86,150,251,266,489,578,687,688,797,868]))
        value_122[index_122[index_122 != -1]] = 1
        zone_set.add_attribute(data=value_122, name="v122")
        
        value_123 = zeros(zone_set.size())
        index_123 = zone_set.try_get_id_index(array([531,646,847,850,888,894,899,910]))
        value_123[index_123[index_123 != -1]] = 1
        zone_set.add_attribute(data=value_123, name="v123")
        
        value_124 = logical_not(value_122 + value_123)
        zone_set.add_attribute(data=value_124, name="v124")
                
        """specify which variables are passing from urbansim to travel model; the order matters"""
        variables_list = self.get_variables_list(dataset_pool)
        
        zone_set.compute_variables(variables_list, dataset_pool=dataset_pool )

        return self._write_to_file(zone_set, variables_list, tm_input_file)
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:58,代码来源:travel_model_input_file_writer.py

示例2: _write_input_file_1

# 需要导入模块: from opus_core.datasets.dataset import DatasetSubset [as 别名]
# 或者: from opus_core.datasets.dataset.DatasetSubset import _create_id_mapping [as 别名]
    def _write_input_file_1(self, current_year_emme2_dir, input_dir, current_year, dataset_pool, config=None):
        missing_dataset = ''
        try:
            missing_dataset = 'group_quarter'
            taz_col_set = dataset_pool.get_dataset("group_quarter")
            taz_col_set.load_dataset()
            missing_dataset = 'zone'
            zone_set = dataset_pool.get_dataset("zone")
            zone_set.load_dataset()
            missing_dataset = 'household'
            household_set = dataset_pool.get_dataset("household")
        except:
            raise Exception("Dataset %s is missing from dataset_pool" % missing_dataset)
        
        """specify travel input file name """
        if not os.path.exists(input_dir):
            os.makedirs(input_dir)
        tm_input_file = os.path.join(input_dir, 'tazdata.in')
        
        tm_year = self._get_tm_year(current_year, taz_col_set)
        
        logger.log_status("calculating entries for emme%s input file" % self.emme_version)
        taz_col_set.compute_variables("zone_id=group_quarter.taz")
        current_taz_col = DatasetSubset(taz_col_set, index=where(taz_col_set.get_attribute("year")==tm_year)[0])
        
        current_taz_col._id_names = ['taz']
        current_taz_col._create_id_mapping()
        zone_set.join(current_taz_col, "gqdorm", join_attribute='zone_id')
        zone_set.join(current_taz_col, "gqmil", join_attribute='zone_id')
        zone_set.join(current_taz_col, "gqoth", join_attribute='zone_id')
        zone_set.join(current_taz_col, "fteuniv", join_attribute='zone_id')
              
        """specify which variables are passing from urbansim to travel model; the order matters"""
        variables_list = self.get_variables_list(dataset_pool)
        
        zone_set.compute_variables(variables_list, dataset_pool=dataset_pool )

        return self._write_to_file(zone_set, variables_list, tm_input_file, tm_year)
开发者ID:,项目名称:,代码行数:40,代码来源:


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