Skip to content

Guides

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.

BitRule idFlags when
0temp_c.out_of_rangeTemperature is outside [-89, 57] °C
1dewpoint_c.exceeds_tempDewpoint is above temperature
2wind_speed_ms.negativeWind speed is negative
3wind_direction_degrees.out_of_rangeWind direction is outside [0, 360]
4sea_level_pressure_hpa.out_of_rangeSea-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. weather.training_table() keeps its daily_summary_* labels tied to the venue’s settlement 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.