As the title says the behaviour of the method HazardDataProvider.get_data_cascading in hazard_data_provider.py is counterintuitive when the flag interpolate_years is set to False.
This is due to how the function decides whether a given latitude, longitude pair is marked as processed. The decision is solely based on spatial coverage, independently of whether or not a given resource contains data for a particular year.
Concretely, get_data_cascading iterates over the resource_paths_set for a particular hazard_type and indicator_id. For each resource_paths item it checks whether each requested location is in_bounds of the map corresponding to any year in that resource (all years are assumed to have the same spatial coverage). This way, the resource might not contain some or even any of the requested years for a given scenario, but as long as it contains any year for the requested scenario and the map for that year contains the given latitude, longitude pair in bounds, the location will be marked as processed and get_scenarios_and_years will attempt to provide data for all requested years with that resource. However, with interpolate_year=True if the resource does not contain data for a particular year get_scenarios_and_years will return an empty result. Then, since the location is already marked as processed, even if some of the requested years could still be satisfied with a later item in resource_paths_set, the function will never attempt to do so, it will not cascade.
I haven't researched it as much, but I believe a similar problem occurs with scenarios. If a resource contains at least one of the requested scenarios and the map for one of the years of that scenario has a given location in bounds, that location will be marked as processed by that resource, even if it cannot satisfy the request for other scenarios and some later resource could.
As the title says the behaviour of the method
HazardDataProvider.get_data_cascadinginhazard_data_provider.pyis counterintuitive when the flaginterpolate_yearsis set toFalse.This is due to how the function decides whether a given latitude, longitude pair is marked as processed. The decision is solely based on spatial coverage, independently of whether or not a given resource contains data for a particular year.
Concretely,
get_data_cascadingiterates over theresource_paths_setfor a particularhazard_typeandindicator_id. For eachresource_pathsitem it checks whether each requested location isin_boundsof the map corresponding to any year in that resource (all years are assumed to have the same spatial coverage). This way, the resource might not contain some or even any of the requested years for a given scenario, but as long as it contains any year for the requested scenario and the map for that year contains the given latitude, longitude pair in bounds, the location will be marked as processed andget_scenarios_and_yearswill attempt to provide data for all requested years with that resource. However, withinterpolate_year=Trueif the resource does not contain data for a particular yearget_scenarios_and_yearswill return an empty result. Then, since the location is already marked as processed, even if some of the requested years could still be satisfied with a later item inresource_paths_set, the function will never attempt to do so, it will not cascade.I haven't researched it as much, but I believe a similar problem occurs with scenarios. If a resource contains at least one of the requested scenarios and the map for one of the years of that scenario has a given location in bounds, that location will be marked as processed by that resource, even if it cannot satisfy the request for other scenarios and some later resource could.