Commit 1f1e87a7 authored by Felix Delattre's avatar Felix Delattre
Browse files

Merge branch 'for_running' into 'master'

Adding a parameter to the config file

See merge request dynamicexposure/globaldynamicexposure/gde_calculations_prototype!1
parents 8951537e ad1b85b8
......@@ -178,6 +178,10 @@ def check_parameters(config, section_name):
raise IOError('ERROR!! countries PARAMETER MISSING FROM CONFIG FILE!!')
if not config.has_option('SERA_distributing_exposure_to_cells', 'columns_to_distribute'):
raise IOError('ERROR!! columns_to_distribute PARAMETER MISSING FROM CONFIG FILE!!')
if not config.has_option('SERA_distributing_exposure_to_cells', 'write_hdf5_bdg_classes_param'):
raise IOError('ERROR!! write_hdf5_bdg_classes_param PARAMETER MISSING FROM CONFIG FILE!!')
else:
check_if_param_is_True_or_False(config['SERA_distributing_exposure_to_cells']['write_hdf5_bdg_classes_param'], 'write_hdf5_bdg_classes_param')
elif section_name=='SERA_exploration_investigate_full_CSV_files':
if not config.has_option('SERA_exploration_investigate_full_CSV_files', 'tolerance_ratio'):
raise IOError('ERROR!! tolerance_ratio PARAMETER MISSING FROM CONFIG FILE!!')
......
......@@ -177,6 +177,9 @@ countries = Greece
admin_ids_to_ignore = 9999999
# Columns to distribute (TO DO: provide better description of this parameter):
columns_to_distribute = buildings, dwell_per_bdg, area_per_dwelling_sqm, cost_per_area_usd, ppl_per_dwell
# Write the HDF5 file of building classes parameters or not.
# (write_hdf5_bdg_classes parameter for gdet_sera.distribute_SERA_to_cells() function):
write_hdf5_bdg_classes_param = True
[SERA_exploration_investigate_full_CSV_files]
# Tolerance for the ratio of parameters (change rate, e.g. (X-Y)/Y):
......
......@@ -65,6 +65,14 @@ def run_this_file(config_dict):
admin_ids_to_ignore= []
# Columns to distribute (TO DO: provide better description of this parameter):
columns_to_distribute= config_dict['SERA_distributing_exposure_to_cells']['columns_to_distribute'].split(', ') # ['buildings','dwell_per_bdg','area_per_dwelling_sqm','cost_per_area_usd','ppl_per_dwell'] # OLD VERSION (OQ files): columns_to_distribute=['number','structural','night']
# Write the HDF5 file of building classes parameters or not:
write_hdf5_bdg_classes_str= config_dict['SERA_distributing_exposure_to_cells']['write_hdf5_bdg_classes_param']
if write_hdf5_bdg_classes_str.lower()=='true':
write_hdf5_bdg_classes_param= True
elif write_hdf5_bdg_classes_str.lower()=='false':
write_hdf5_bdg_classes_param= False
else:
print('ERROR!! IT SHOULD NOT GET TO THIS POINT, AS THE PARAMETER IS CHECKED IN THE CONFIG FILE CHECKS')
####################################################
# START
####################################################
......@@ -93,7 +101,7 @@ def run_this_file(config_dict):
for case in level_groups[j]: # Res, Com or Ind
if case not in ignore_occupancy_cases:
print(' '+country_name+', level group '+str(j+1)+' of '+str(len(level_groups))+', '+case+' ('+str(len(adm_ids_list))+' associated admin IDs)'+': Working on admin ID '+str(admin_id))
distrib_log= gdet_sera.distribute_SERA_to_cells(case, dfs_dict[case], cells_ids, cells_ids_weights, admin_id, adm_level, gdet_gral.get_ISO2_code_for_country(country_name), os.path.join(out_path,'Europe_SERA_cells_'+param_for_weighting+'_'+case+'.hdf5'), os.path.join(out_path,'Europe_SERA_bdg_classes_'+case+'.hdf5'), cols_to_distribute=columns_to_distribute, check=True, write_hdf5_bdg_classes=False)
distrib_log= gdet_sera.distribute_SERA_to_cells(case, dfs_dict[case], cells_ids, cells_ids_weights, admin_id, adm_level, gdet_gral.get_ISO2_code_for_country(country_name), os.path.join(out_path,'Europe_SERA_cells_'+param_for_weighting+'_'+case+'.hdf5'), os.path.join(out_path,'Europe_SERA_bdg_classes_'+case+'.hdf5'), cols_to_distribute=columns_to_distribute, check=True, write_hdf5_bdg_classes=write_hdf5_bdg_classes_param)
if distrib_log!='':
log.append(country_name+', Admin ID '+admin_id+', '+case+': ')
log.append(' '+distrib_log)
......
Supports Markdown
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