metobs_toolkit.gap.Gap.weighted_diurnal_debiased_model_gapfill#
- Gap.weighted_diurnal_debiased_model_gapfill(sensordata: SensorData, modeltimeseries: ModelTimeSeries, leading_period_duration: pd.Timedelta, min_lead_debias_sample_size: int, trailing_period_duration: pd.Timedelta, min_trail_debias_sample_size: int, max_gap_duration_to_fill: pd.Timedelta = Timedelta('0 days 12:00:00'), min_value=None, max_value=None) None[source]#
Fill the gaps using a weighted sum of model data corrected for the diurnal bias and weights with respect to the start of the gap.
This method fills the gap using model data corrected for its diurnal bias. The diurnal bias is a bias that is estimated for each timestamp in the leading and trailing period (separately). For both periods separately, all biases are averaged over hour, minute and second, to obtain a diurnal bias (for each timestamp).
In addition, a normalized weight is computed for each gap record indicating the distance (in time) to the start and end of the gap. The correction applied on the interpolated (in time) model data is thus a weighted sum of corrections coming from both the leading and trailing period.
- Parameters:
sensordata (SensorData) – The corresponding SensorData used in the computation of the bias. Only the observations that are not labeled as outliers are used to compute the bias.
modeltimeseries (ModelTimeSeries) – The model time series used to fill the gap records. The model data must be compatible (equivalent obstype and related to the same Station as the gap.)
leading_period_duration (pandas.Timedelta) – The duration of the leading period. That is the period before the gap, used for bias estimation.
min_lead_debias_sample_size (int) – The minimum number of leading samples required for bias estimation. If this condition is not met, the gap is not filled.
trailing_period_duration (pandas.Timedelta) – The duration of the trailing period. That is the period after the gap, used for bias estimation.
min_trail_debias_sample_size (int) – The minimum number of trailing samples required for bias estimation. If this condition is not met, the gap is not filled.
max_gap_duration_to_fill (pandas.Timedelta, optional) – The maximum gap duration of to fill with interpolation. The result is independent on the time-resolution of the gap. Defaults to 12 hours.
min_value (float, optional) – Minimum allowed value for filled data. If provided, filled values below this threshold will be clipped to this value. Default is None (no minimum limit).
max_value (float, optional) – Maximum allowed value for filled data. If provided, filled values above this threshold will be clipped to this value. Default is None (no maximum limit).
- Return type:
None.
Notes
A schematic description of the weighted diurnal debiased modeldata gap fill:
Check the compatibility of the ModelTimeSeries with the gap.
Construct a leading and trailing sample, and test if they meet the required conditions. The required conditions are tested by testing the samplesizes per hour, minute and second for the leading and trailing periods (seperatly).
A leading and trailing set of diurnal biases are computed by grouping to hour, minute and second, and averaging the biases.
A weight is computed for each gap record, that is the normalized distance to the start and end of the gap.
Fill the gap records by using raw (interpolated) modeldata is corrected by a weighted sum the coresponding diurnal bias for the lead and trail periods.
Clip filled values to the range [min_value, max_value] if specified.
Update the gap attributes with the interpolated values, labels, and details.
A suitable min_debias_sample_size depends on the sizes of the leading- and trailing periods, and also on the time resolution gap (=time resolution of the corresponding SensorData).
References
Jacobs A, et. al. (2024) Filling gaps in urban temperature observations by debiasing ERA5 reanalysis data