Skip to content

Quality control

Observation quality control annotates suspicious physics; it does not rewrite measurements or drop reports. Request it on weather.observations(), inspect the bitfield, and choose the filtering policy that fits your model.

from mostlyright import weather
reports = weather.observations(
"KNYC",
"2025-01-06",
"2025-01-08",
quality_control=True,
)
clean = reports[reports["obs_qc_status"] == 0]
flagged = reports[reports["obs_qc_status"] != 0]

quality_control is the 2.0 keyword. The old qc= name is gone.

obs_qc_status is an integer bitfield. Zero means that none of the registered rules fired. A set bit means that rule flagged the row.

Bit Rule id Flags when
0 temp_c.out_of_range Temperature is outside [-89, 57] °C
1 dewpoint_c.exceeds_temp Dewpoint is above temperature
2 wind_speed_ms.negative Wind speed is negative
3 wind_direction_degrees.out_of_range Wind direction is outside [0, 360]
4 sea_level_pressure_hpa.out_of_range Sea-level pressure is outside [870, 1085] hPa

Existing bit positions are stable. New rules append a new bit so stored values keep their meaning.

The separate qc_field column is the upstream source’s quality marker. It is not the SDK physics bitfield.

TEMP_RANGE = 1 << 0
DEWPOINT = 1 << 1
status = reports["obs_qc_status"].fillna(0).astype(int)
bad_temperature = reports[(status & TEMP_RANGE) != 0]
# Accept a dewpoint warning but reject every other rule.
other_rules = status & ~DEWPOINT
usable = reports[other_rules == 0]

The returned measurements remain unchanged. This lets you audit a sensor failure, change your filtering threshold later, or re-run training without re-fetching.

QC applies to observation features, not settlement truth. Read official labels with weather.daily_summaries() and keep their source separate from the observation source.

For exact settlement replay, preserve the label as reported even when an observation feature looks suspicious. For model training, record the policy that decided whether to keep, mask, or transform a flagged feature.

Not every domain uses the observation bitfield:

  • CWOP and satellite rows use qc_status values such as clean, flagged, or suspect.
  • NWP forecast rows carry model-aware qc_status.
  • qc_field is raw source metadata on METAR/SPECI rows.

Do not compare these columns as though they were the same scale.