BUG: on transformation for climate and fir clim mix
Bug
Error description
When using the data handler DataHandlerMixedSamplingWithClimateAndFirFilter
with no extend length (which corresponds to usage of data handler only using climFIR, but with separated chem/meteo vars), there are the expected plots for the climate FIR filter (chem and meteo) but also plots for the FIR filter for all meteo vars in addition. See paramterers:
data_handler=DataHandlerMixedSamplingWithClimateAndFirFilter,
window_history_size=3 * 24 - 1,
window_history_offset={"chem": 24, "meteo": 24},
window_history_end={"chem": 0, "meteo": 0},
extend_length_opts={"chem": 0, "meteo": 0},
Error message
First guess on error origin
This only effects the meteo variables. Unexpected plots are created much later than the expected ones. Maybe this is related to transformation?
Error origin
Reason: During transformation the following is called
# meteo transformation
if len(meteo_vars) > 0:
kwargs_meteo = copy.deepcopy(kwargs)
cls.prepare_build(kwargs_meteo, meteo_vars, cls.meteo_indicator)
dh_transformation = (cls.data_handler_fir[cls.data_handler_fir_pos or 0], cls.data_handler_unfiltered)
transformation_meteo = super().transformation(set_stations, tmp_path=tmp_path,
dh_transformation=dh_transformation, **kwargs_meteo)
But as cls.data_handler_fir_pos
is initialized as None
, this code will always use the index 0
for transformation. Make sure to check beforehand, which extend length is used and set cls.data_handler_fir_pos
. Need to implement a method that sets the position before applying transformation. This should be similar to the following code block in cls.build
:
if len(meteo_vars) > 0:
if cls.data_handler_fir_pos is None:
if "extend_length_opts" in kwargs:
if isinstance(kwargs["extend_length_opts"], dict) and cls.meteo_indicator not in kwargs["extend_length_opts"].keys():
cls.data_handler_fir_pos = 0 # use faster fir version without climate estimate
else:
cls.data_handler_fir_pos = 1 # use slower fir version with climate estimate
else:
cls.data_handler_fir_pos = 0 # use faster fir version without climate estimate
Solution
-
extract relevant code from the cls.build
command to setcls.data_handler_fir_pos
in new classmethod -
replace extracted code parts in cls.build
-
add pos method call in cls.transformation
as used incls.build