def run(self,
            current_year_emme2_dir,
            current_year,
            dataset_pool,
            config=None):
        """Writes emme2 input files into the [current_year_emme2_dir]/tripgen/inputtg/
        """
        tm_input_file_1 = HHJobsTravelModelInputFileWriter.run(
            self, current_year_emme2_dir, current_year, dataset_pool,
            config)  # writes TAZDATA.MA2

        missing_dataset = ''
        try:
            missing_dataset = 'person'
            person_set = dataset_pool.get_dataset("person")
        except:
            raise "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')
        tm_input_files = [
            os.path.join(full_path, 'tazdata.mf91'),
            os.path.join(full_path, 'tazdata.mf92'),
            os.path.join(full_path, 'tazdata.mf93'),
            os.path.join(full_path, 'tazdata.mf94')
        ]

        first_quarter, median_income, third_quarter = self._get_income_group_quartiles(
            dataset_pool)
        logger.log_status("calculating entries for emme2 *.mf9x input files")

        household_variables_to_compute = [
            "is_income_group_1 = household.income < %s" % first_quarter,
            "is_income_group_2 = numpy.logical_and(household.income >= %s, household.income < %s)"
            % (first_quarter, median_income),
            "is_income_group_3 = numpy.logical_and(household.income >= %s, household.income < %s)"
            % (median_income, third_quarter),
            "is_income_group_4 = household.income >= %s" % third_quarter
        ]

        dataset_pool.get_dataset("household").compute_variables(
            household_variables_to_compute, dataset_pool=dataset_pool)
        person_variables_to_compute = [
            "income_group_1 = person.disaggregate(household.is_income_group_1)",
            "income_group_2 = person.disaggregate(household.is_income_group_2)",
            "income_group_3 = person.disaggregate(household.is_income_group_3)",
            "income_group_4 = person.disaggregate(household.is_income_group_4)",
            "urbansim_parcel.person.zone_id",
            "urbansim_parcel.person.is_placed_non_home_based_worker_with_job",
            "job_zone_id = person.disaggregate(urbansim_parcel.job.zone_id)"
        ]

        person_set.compute_variables(person_variables_to_compute,
                                     dataset_pool=dataset_pool)

        return [tm_input_file_1] + self._write_workplaces_to_files(
            person_set, tm_input_files)
Пример #2
0
 def run(self, current_year_emme2_dir, current_year, dataset_pool, config=None):
     """Writes emme2 input files into the [current_year_emme2_dir]/tripgen/inputtg/
     """
     tm_input_file_1 = HHJobsTravelModelInputFileWriter.run(self, current_year_emme2_dir, current_year, dataset_pool, config) # writes TAZDATA.MA2
     self.compute_houshold_and_persons_variables(dataset_pool)
     """specify travel input file name: [current_year_emme2_dir]/tripgen/inputtg/tazdata.ma2 """
     full_path = os.path.join(current_year_emme2_dir, 'tripgen', 'inputtg')
     tm_input_files = [os.path.join(full_path, 'tazdata.mf91'), os.path.join(full_path, 'tazdata.mf92'),
                      os.path.join(full_path, 'tazdata.mf93'), os.path.join(full_path, 'tazdata.mf94')]
     return [tm_input_file_1] + self._write_workplaces_to_files(dataset_pool.get_dataset("person"), 
                                                                tm_input_files)
    def run(self, current_year_emme2_dir, current_year, dataset_pool, config=None):
        """Writes emme2 input files into the [current_year_emme2_dir]/tripgen/inputtg/
        """
        tm_input_file_1 = HHJobsTravelModelInputFileWriter.run(self, current_year_emme2_dir, current_year, dataset_pool, config) # writes TAZDATA.MA2
        
        missing_dataset = ''
        try:
            missing_dataset = 'person'
            person_set = dataset_pool.get_dataset("person")
        except:
            raise "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')
        tm_input_files = [os.path.join(full_path, 'tazdata.mf91'), os.path.join(full_path, 'tazdata.mf92'),
                         os.path.join(full_path, 'tazdata.mf93'), os.path.join(full_path, 'tazdata.mf94')]
                
        first_quarter, median_income, third_quarter = self._get_income_group_quartiles(dataset_pool)
        logger.log_status("calculating entries for emme2 *.mf9x input files")

        household_variables_to_compute = ["is_income_group_1 = household.income < %s" % first_quarter,
                                "is_income_group_2 = numpy.logical_and(household.income >= %s, household.income < %s)" % (first_quarter, median_income),
                                "is_income_group_3 = numpy.logical_and(household.income >= %s, household.income < %s)" % (median_income, third_quarter),
                                "is_income_group_4 = household.income >= %s" % third_quarter]
        
        dataset_pool.get_dataset("household").compute_variables(household_variables_to_compute, dataset_pool=dataset_pool)
        person_variables_to_compute = [
                                "income_group_1 = person.disaggregate(household.is_income_group_1)",
                                "income_group_2 = person.disaggregate(household.is_income_group_2)",
                                "income_group_3 = person.disaggregate(household.is_income_group_3)",
                                "income_group_4 = person.disaggregate(household.is_income_group_4)",
                                "urbansim_parcel.person.zone_id",
                                "urbansim_parcel.person.is_placed_non_home_based_worker_with_job",
                                "job_zone_id = person.disaggregate(urbansim_parcel.job.zone_id)"
                                ]
        
        person_set.compute_variables(person_variables_to_compute, dataset_pool=dataset_pool)

        return [tm_input_file_1] + self._write_workplaces_to_files(person_set, tm_input_files)