For most countries in ESRM20, a unique combination of:
lead to unique values of parameters such as
total_cost_per_building (which in turn depend on the number of dwellings per building, number of people per dwelling, etc). However, there are special cases, such as the residential exposure models for Italy and Portugal for which this is not true.
This MR introduces a modification to the methods that retrieve building classes and their properties, so that the code itself can identify these cases and "decide" what to do. The code checks whether the parameters mentioned above are unique for the unique combinations of the variables that define a building class (the list of bullet points above). If this check "fails", it logs a warning regarding which parameters "failed" and switches to calculating the weighted average of these parameters. The functionality to calculate weighted average values already existed, as it is the one used to assign building classes and their properties to the "filler" data units that are created to fill in geographical gaps in the exposure. This means that the same two methods that were already handling this procedure (
ExposureModelESRM20._retrieve_building_classes_of_data_units) keep on doing so.
One of the tests has been modified to now cover this new case (i.e. the case in which the check "fails" and the code switches to using the weighted average).
Apart from the tests, the functioning of the code has also been evaluated by running Italy (country for which the automatic switching needs to occur) and Kosovo (country for which a filler data unit needs to be created). Results have been satisfactory in both cases.