metobs_toolkit.gap.Gap.debiased_model_gapfill#

Gap.debiased_model_gapfill(sensordata: SensorData, modeltimeseries: ModelTimeSeries, leading_period_duration: str | pd.Timedelta, min_leading_records_total: int, trailing_period_duration: str | pd.Timedelta, min_trailing_records_total: 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 model data corrected for the bias.

This method fills the gap using model data corrected for bias. The bias is estimated using a leading (before the gap) and trailing (after the gap) period. The bias is computed by combining the leading and trailing period, and comparing the model with the observations (not labeled as outliers). The model data is then interpolated to the missing records, and corrected with the estimated bias.

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 (str or pandas.Timedelta) – The duration of the leading period.

  • min_leading_records_total (int) – The minimum number of records required in the leading period.

  • trailing_period_duration (str or pandas.Timedelta) – The duration of the trailing period.

  • min_trailing_records_total (int) – The minimum number of records required in the trailing period.

  • 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 debiased modeldata gap fill:

  1. Check the compatibility of the ModelTimeSeries with the gap.

  2. Construct a leading and trailing sample, and test if they meet the required conditions.

  3. Compute the bias of the modeldata (combine leading and trailing samples).

  4. Fill the gap records by using raw (interpolated) modeldata that is corrected by subtracting the bias.

  5. Clip filled values to the range [min_value, max_value] if specified.

  6. Update the gap attributes with the interpolated values, labels, and details.