Commit 02f1c4c0 authored by Cecilia Nievas's avatar Cecilia Nievas
Browse files

Merge branch 'dev_minor_bugs_2' into 'master'

Dev minor bugs 2

See merge request dynamicexposure/globaldynamicexposure/gde_calculations_prototype!8
parents c3978f5b 118bd2b0
......@@ -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()))
......
......@@ -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:
......
......@@ -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()
......
......@@ -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'))
......
......@@ -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!')
......
......@@ -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')
......
......@@ -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')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment