# export computations to tab file [person level] if export_computations_person == True: print '[Person Level] Exporting computations to: %s' % out_table_name_person_computations persons.write_dataset(attributes = ['person_id', 'home2work_travel_time_min', 'work2home_travel_time_min', 'travel_cost_per_person'], out_storage = storage_output, out_table_name = out_table_name_person_computations) # Exports according to case study if case_study == 'brussels' and policy_level == 'zone': # export computations to tab file [zone level] if export_computations_zone == True: print '[Zone Level] Exporting computations to: %s' % out_table_name_computations zones.write_dataset(attributes = ['income_per_zone', 'housing_cost_per_zone', 'travel_cost_per_zone', 'utility_of_residents_zone'], out_storage = storage_output, out_table_name = out_table_name_computations) # Summarize utility_of_residents_zone attributes swf_per_year = zones.attribute_sum('utility_of_residents_zone') elif case_study == 'zurich' and policy_level == 'parcel': # export computations to tab file [parcel level] if export_computations_parcel == True: print '[Parcel Level] Exporting computations to: %s' % out_table_name_computations parcels.write_dataset(attributes = ['income_per_parcel', 'housing_cost_per_parcel', 'travel_cost_per_parcel', 'utility_of_residents_parcel'], out_storage = storage_output, out_table_name = out_table_name_computations) # Summarize utility_of_residents_zone attributes swf_per_year = parcels.attribute_sum('utility_of_residents_parcel') print 'Social Welfare for year %s: %s' % (year, swf_per_year) # Place swf idicator value for the running year into a dict storage # Add swf as primary attribute for the running year swf_indicators.add_elements(data = {"swf_id":array([1]), "year":array([year]), "social_welfare":array([swf_per_year])}, require_all_attributes = True, change_ids_if_not_unique = True)
# export computations to tab file [zone level] if export_computations_zone == True: print '[Zone Level] Exporting computations to: %s' % out_table_name_computations print 'Time Start: %s' % strftime("%a, %d %b %Y %X", gmtime()) zones.write_dataset(attributes = ['income_per_zone', 'housing_cost_per_zone', 'travel_cost_per_zone', 'travel_benefit_car', #'travel_benefit_pt', 'utility_of_residents_zone', 'utility_of_commuters', 'utility_of_the_rest_of_the_world'], out_storage = storage_output, out_table_name = out_table_name_computations) print 'Time End: %s' % strftime("%a, %d %b %Y %X", gmtime()) # Compute social welfare per year by summarizing attributes swf_per_year = zones.attribute_sum('utility_of_residents_zone') \ + zones.attribute_sum('utility_of_commuters') \ + zones.attribute_sum('utility_of_the_rest_of_the_world') elif case_study == 'zurich' and policy_level == 'parcel': # export computations to tab file [parcel level] if export_computations_parcel == True: print '[Parcel Level] Exporting computations to: %s' % out_table_name_computations print 'Time Start: %s' % strftime("%a, %d %b %Y %X", gmtime()) parcels.write_dataset(attributes = ['income_per_parcel', 'housing_cost_per_parcel', 'travel_cost_per_parcel', 'travel_benefit_car', #'travel_benefit_pt', 'utility_of_residents_parcel', 'utility_of_commuters', 'utility_of_the_rest_of_the_world'], out_storage = storage_output,