Detect physically-impossible target-column corruption in the native frame.
Applies two independent rules on the native-cadence (e.g. 15-min) series within a rolling look-back window ending at the last observed target timestamp:
Range rule (sub-hourly cadence only): an hour is flagged when intra-hour max - intra-hour min > range_mw for any target column. Vacuously skipped for hourly-or-coarser cadence (intra-hour range is undefined on a single slot per hour).
Step rule: an hour is flagged when any |adjacent-slot diff| that touches that hour exceeds step_mw for any target column. Applies to all cadences.
Deviation rule (dropout-only, all cadences): an hour is flagged when target − reference < -deviation_mw holds for at least deviation_slotsconsecutive native-cadence slots within the scan window, where the reference is a published companion column such as the ENTSO-E day-ahead "Forecasted Load". The rule is asymmetric by design: the known corruption class is exclusively a dropout below the day-ahead forecast, while actuals above the forecast are ordinary under-forecasting. NaN in either column yields a NaN difference, which compares False — so the publication-lag frontier (forecast published, actual not yet) never flags, and a data gap breaks a consecutive run. On hourly-or-coarser cadence the sustained requirement collapses to a single slot. The rule is silently skipped when deviation_ref is missing from the frame (mirroring how absent target columns are skipped).
Flags are OR-ed across target columns. ALL native-cadence slots of a flagged calendar hour are marked True in the returned boolean Series, so downstream NaN-ing operates on full hours rather than individual sub-hourly slots.
The detector is inert (returns all-False) unless window_days is set AND at least one of range_mw / step_mw / deviation_mw is set. If the data is shorter than window_days, the window is clamped to df.index.min() without raising.
Maximum allowed dropout below the reference column (MW, positive magnitude): slots with target − reference < -deviation_mw are candidates. None skips the deviation rule.
Name of the reference column (e.g. "Forecasted Load"). The rule is skipped when None or when the column is absent from df. The reference column itself is never checked as a target by this rule.
Minimum number of consecutive sub-hourly slots the dropout must sustain before any hour is flagged (default 2 — a single-slot blip is more likely a metering glitch than the oscillating dropout class). Clamped to 1 on hourly-or-coarser cadence.