From 94d26fa3f810e59b74b2824fa3890131c14ec425 Mon Sep 17 00:00:00 2001 From: Cecilia Nievas Date: Tue, 10 Nov 2020 12:00:32 +0100 Subject: [PATCH 1/3] full_files set to True when calling get_admin_level_definition in SERA_mapping_admin_units_to_cells; full_files made explicit input parameter of give_totals_SERA_per_country in GDE_TOOLS_read_SERA --- GDE_TOOLS_read_SERA.py | 4 ++-- SERA_mapping_admin_units_to_cells.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/GDE_TOOLS_read_SERA.py b/GDE_TOOLS_read_SERA.py index a2dba1c..e7e489c 100644 --- a/GDE_TOOLS_read_SERA.py +++ b/GDE_TOOLS_read_SERA.py @@ -225,8 +225,8 @@ def check_number_points_per_admin_level(country_name, path): return exposure_cases, actual_levels_list, have_one_point_per_ID -def give_totals_SERA_per_country(country_name, path, cols_to_add=['number','structural','night'], output_dfs=False): - _, _, _, df= get_admin_level_definition(country_name, path, output_dfs=True) +def give_totals_SERA_per_country(country_name, path, cols_to_add=['number','structural','night'], full_files=False, output_dfs=False): + _, _, _, df= get_admin_level_definition(country_name, path, output_dfs=True, full_files=full_files) for case in ['Res','Com','Ind']: for col in cols_to_add: print(country_name+', '+case+', '+col+': '+'{:,.2f}'.format(df[case][col].values.sum())) diff --git a/SERA_mapping_admin_units_to_cells.py b/SERA_mapping_admin_units_to_cells.py index b20f1c2..2be9eb4 100644 --- a/SERA_mapping_admin_units_to_cells.py +++ b/SERA_mapping_admin_units_to_cells.py @@ -67,7 +67,7 @@ def run_this_file(config_dict): print('\n') print('Working on '+country_name+', country '+str(k+1)+' of '+str(len(countries))+'\n') # There is repetition of admin levels across Res/Com/Ind. I pre-analyse the case so as to carry out spatial intersections only once. - admin_levels, level_groups, level_groups_levels, dfs_dict= gdet_sera.get_admin_level_definition(country_name, sera_models_path, output_dfs=True) + admin_levels, level_groups, level_groups_levels, dfs_dict= gdet_sera.get_admin_level_definition(country_name, sera_models_path, full_files = True, output_dfs=True) for j in range(0,len(level_groups)): # Group of any combination of Res/Com/Ind with the same admin level definition (given by level_groups_levels) try: adm_boundary = gpd.GeoDataFrame.from_file(os.path.join(sera_shp_path,'Adm'+str(level_groups_levels[j])+'_'+country_name+'.shp')) -- GitLab From 68c3b25b37569ab257a63f9adac04ff3ba5acc5b Mon Sep 17 00:00:00 2001 From: Cecilia Nievas Date: Tue, 10 Nov 2020 12:05:44 +0100 Subject: [PATCH 2/3] corrected destination folder in GDE_plot_maps --- GDE_plot_maps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GDE_plot_maps.py b/GDE_plot_maps.py index 7d53ec1..cd67cc2 100644 --- a/GDE_plot_maps.py +++ b/GDE_plot_maps.py @@ -76,7 +76,7 @@ def run_this_file(config_dict): #################################################### print('Processing configuration parameters...') # Path for output: - out_path= os.path.join(config_dict['File Paths']['out_path'], 'examining_outputs_GDE', 'post_processing_maps_TESTING') + out_path= os.path.join(config_dict['File Paths']['out_path'], 'examining_outputs_GDE', 'post_processing_maps') # The visual output files have names such as GDE_visual_'+crit+'_'+location_var+'.csv' location_var= config_dict['GDE_plot_maps']['location_var'] # Occupancy cases to consider: -- GitLab From 118bd2b0eb6052a94bdc6bd3e7f3a30b8f4dd2a2 Mon Sep 17 00:00:00 2001 From: Cecilia Nievas Date: Tue, 10 Nov 2020 12:13:20 +0100 Subject: [PATCH 3/3] added comma to separate thousands in the format of numbers printed to screen/logs --- ...ate_visual_output_of_grid_model_full_files.py | 8 ++++---- ...ng_compare_visual_output_vs_OQ_input_files.py | 4 ++-- ...uilding_exposure_from_cells_alternative_01.py | 16 ++++++++-------- ...uilding_exposure_from_cells_alternative_02.py | 16 ++++++++-------- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/SERA_create_visual_output_of_grid_model_full_files.py b/SERA_create_visual_output_of_grid_model_full_files.py index 3be6d23..2d5c82f 100644 --- a/SERA_create_visual_output_of_grid_model_full_files.py +++ b/SERA_create_visual_output_of_grid_model_full_files.py @@ -192,16 +192,16 @@ def run_this_file(config_dict): string= ' Occupancy: '+case print(string) out_csv.write(string+'\n') - string= ' Total number of buildings: '+'{:.2f}'.format(tot_num_bdgs[case_pos]) + string= ' Total number of buildings: '+'{:,.2f}'.format(tot_num_bdgs[case_pos]) print(string) out_csv.write(string+'\n') - string= ' Total number of dwellings: '+'{:.2f}'.format(tot_num_dwells[case_pos]) + string= ' Total number of dwellings: '+'{:,.2f}'.format(tot_num_dwells[case_pos]) print(string) out_csv.write(string+'\n') - string= ' Total number of people: '+'{:.2f}'.format(tot_num_ppl[case_pos]) + string= ' Total number of people: '+'{:,.2f}'.format(tot_num_ppl[case_pos]) print(string) out_csv.write(string+'\n') - string= ' Total cost: '+'{:.2f}'.format(tot_cost[case_pos]) + string= ' Total cost: '+'{:,.2f}'.format(tot_cost[case_pos]) print(string) out_csv.write(string+'\n') out_csv.close() diff --git a/SERA_testing_compare_visual_output_vs_OQ_input_files.py b/SERA_testing_compare_visual_output_vs_OQ_input_files.py index ef75344..eb483f5 100644 --- a/SERA_testing_compare_visual_output_vs_OQ_input_files.py +++ b/SERA_testing_compare_visual_output_vs_OQ_input_files.py @@ -94,8 +94,8 @@ def run_this_file(config_dict): print(' ERROR!! CELL ID '+str(cell_id)+' FOUND MORE THAN ONCE IN VISUAL OUTPUT CSV!!!') row_read[which]= True print('\n') - print('Total cost OQ: '+'{:.2f}'.format(full_cost_oq)) - print('Total cost visual: '+'{:.2f}'.format(full_cost_visual)) + print('Total cost OQ: '+'{:,.2f}'.format(full_cost_oq)) + print('Total cost visual: '+'{:,.2f}'.format(full_cost_visual)) print('\n') print('Done!') diff --git a/SERA_testing_rebuilding_exposure_from_cells_alternative_01.py b/SERA_testing_rebuilding_exposure_from_cells_alternative_01.py index ce8f7e2..9c3be60 100644 --- a/SERA_testing_rebuilding_exposure_from_cells_alternative_01.py +++ b/SERA_testing_rebuilding_exposure_from_cells_alternative_01.py @@ -206,28 +206,28 @@ def run_this_file(config_dict): out_csv.close() print('\n') out_csv= open(os.path.join(out_path, 'rebuilding_SERA', 'rebuilding_SERA_alt_01_'+country_name+'_'+case+'_'+param_for_weighting+'_print_screen.txt'), 'w') - string= ' Total number of buildings from SERA CSV files: '+'{:.4f}'.format(sera_num_bdgs_country) + string= ' Total number of buildings from SERA CSV files: '+'{:,.4f}'.format(sera_num_bdgs_country) print(string) out_csv.write(string+'\n') - string= ' Total number of buildings from cells summation: '+'{:.4f}'.format(per_admin_unit_num_bdgs_derived.sum()) + string= ' Total number of buildings from cells summation: '+'{:,.4f}'.format(per_admin_unit_num_bdgs_derived.sum()) print(string) out_csv.write(string+'\n') - string= ' Total number of dwellings from SERA CSV files: '+'{:.4f}'.format(sera_num_dwells_country) + string= ' Total number of dwellings from SERA CSV files: '+'{:,.4f}'.format(sera_num_dwells_country) print(string) out_csv.write(string+'\n') - string= ' Total number of dwellings from cells summation: '+'{:.4f}'.format(per_admin_unit_num_dwells_derived.sum()) + string= ' Total number of dwellings from cells summation: '+'{:,.4f}'.format(per_admin_unit_num_dwells_derived.sum()) print(string) out_csv.write(string+'\n') - string= ' Total number of people from SERA CSV files: '+'{:.4f}'.format(sera_num_ppl_country) + string= ' Total number of people from SERA CSV files: '+'{:,.4f}'.format(sera_num_ppl_country) print(string) out_csv.write(string+'\n') - string= ' Total number of people from cells summation: '+'{:.4f}'.format(per_admin_unit_num_ppl_derived.sum()) + string= ' Total number of people from cells summation: '+'{:,.4f}'.format(per_admin_unit_num_ppl_derived.sum()) print(string) out_csv.write(string+'\n') - string= ' Total cost of buildings from SERA CSV files: '+'{:.4f}'.format(sera_repl_cost_country) + string= ' Total cost of buildings from SERA CSV files: '+'{:,.4f}'.format(sera_repl_cost_country) print(string) out_csv.write(string+'\n') - string= ' Total cost of buildings from cells summation: '+'{:.4f}'.format(per_admin_unit_repl_cost_derived.sum()) + string= ' Total cost of buildings from cells summation: '+'{:,.4f}'.format(per_admin_unit_repl_cost_derived.sum()) print(string) out_csv.write(string+'\n') print('\n') diff --git a/SERA_testing_rebuilding_exposure_from_cells_alternative_02.py b/SERA_testing_rebuilding_exposure_from_cells_alternative_02.py index 035d08a..8ba2d7b 100644 --- a/SERA_testing_rebuilding_exposure_from_cells_alternative_02.py +++ b/SERA_testing_rebuilding_exposure_from_cells_alternative_02.py @@ -203,28 +203,28 @@ def run_this_file(config_dict): out_csv.close() print('\n') out_csv= open(os.path.join(out_path, 'rebuilding_SERA', 'rebuilding_SERA_alt_02_'+country_name+'_'+case+'_'+param_for_weighting+'_print_screen.txt'), 'w') - string= ' Total number of buildings from SERA CSV files: '+'{:.4f}'.format(sera_num_bdgs_country) + string= ' Total number of buildings from SERA CSV files: '+'{:,.4f}'.format(sera_num_bdgs_country) print(string) out_csv.write(string+'\n') - string= ' Total number of buildings from cells summation: '+'{:.4f}'.format(per_admin_unit_num_bdgs.sum()) + string= ' Total number of buildings from cells summation: '+'{:,.4f}'.format(per_admin_unit_num_bdgs.sum()) print(string) out_csv.write(string+'\n') - string= ' Total number of dwellings from SERA CSV files: '+'{:.4f}'.format(sera_num_dwells_country) + string= ' Total number of dwellings from SERA CSV files: '+'{:,.4f}'.format(sera_num_dwells_country) print(string) out_csv.write(string+'\n') - string= ' Total number of dwellings from cells summation: '+'{:.4f}'.format(per_admin_unit_num_dwells.sum()) + string= ' Total number of dwellings from cells summation: '+'{:,.4f}'.format(per_admin_unit_num_dwells.sum()) print(string) out_csv.write(string+'\n') - string= ' Total number of people from SERA CSV files: '+'{:.4f}'.format(sera_num_ppl_country) + string= ' Total number of people from SERA CSV files: '+'{:,.4f}'.format(sera_num_ppl_country) print(string) out_csv.write(string+'\n') - string= ' Total number of people from cells summation: '+'{:.4f}'.format(per_admin_unit_num_ppl.sum()) + string= ' Total number of people from cells summation: '+'{:,.4f}'.format(per_admin_unit_num_ppl.sum()) print(string) out_csv.write(string+'\n') - string= ' Total cost of buildings from SERA CSV files: '+'{:.4f}'.format(sera_repl_cost_country) + string= ' Total cost of buildings from SERA CSV files: '+'{:,.4f}'.format(sera_repl_cost_country) print(string) out_csv.write(string+'\n') - string= ' Total cost of buildings from cells summation: '+'{:.4f}'.format(per_admin_unit_repl_cost.sum()) + string= ' Total cost of buildings from cells summation: '+'{:,.4f}'.format(per_admin_unit_repl_cost.sum()) print(string) out_csv.write(string+'\n') print('\n') -- GitLab