Deal with NULL database values when reading built-up area
The function calculate_weights()
in GDE_TOOLS_general.py
crashes when the input cells_param_vals
comes from having retrieved NULL values from the tiles database (https://git.gfz-potsdam.de/dynamicexposure/legacy/gde_calculations_prototype/-/blob/master/GDE_TOOLS_general.py#L162). The error is the following:
File "SERA_distributing_exposure_to_cells.py", line 121, in <module>
run_this_file(config_dict)
File "SERA_distributing_exposure_to_cells.py", line 100, in run_this_file
cells_ids_weights= gdet_gral.calculate_weights(cells_param_vals, gdet_psql.define_subweights_of_cells(cells_ids, 'all'))
File "/.../gde_calculations_prototype/GDE_TOOLS_general.py", line 162, in calculate_weights
aux_array= cells_param_vals * subweights
TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'
The code retrieved the values of ghs_km2
for the cells associated with a particular admin ID, but some of them were NULL because the code that assigned them had not been run (issue of running parts of a country and forgetting that the whole country is not run, for example). If we can guarantee that this never happens when refactoring the code, then this is not a problem. However, if we cannot guarantee that NULL values will never be retrieved, then this needs to be dealt with.