Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Quality Control Checks

This notebook demonstrates the xopr.qc module, which provides standardized quality control checks for radar datasets. Each check produces a per-trace boolean mask that can be used to filter or visualize data quality.

The built-in checks are:

We’ll load a flight line, run all checks, and visualize which checks pass or fail along the radargram.

Load an example flight

We’ll start by querying the first few frames of an example flight.

Loading...

We’ll load all frames from the results, merge them into one dataset, and resample to uniform 2-second spacing.

Heading is an angle, so a plain mean is wrong wherever it wraps at ±π. We drop it before resampling and let the QC reconstruct it from the resampled GPS track instead.

Loading...

Run QC checks

run_qc() automatically loads layer picks (standard:surface and standard:bottom) when they are not already in the dataset — just pass the opr connection. It also fills in Heading from the GPS positions when a season did not record one (see below); pass "heading_change": {"source": "gps"} to force the reconstruction even when a measured heading exists.

Passing checks=None (the default) runs all registered checks with their default parameters. You can override parameters for specific checks by passing a dict:

  qc_ice_thickness_threshold: 481/969 passed
  qc_snr_bed_pick: 944/969 passed
  qc_heading_change: 938/969 passed
  qc_minimum_agl: 969/969 passed

Combined: 430/969 traces passed all checks (44.4%)

Visualize the radargram with per-check QC flags

The top panel shows the radargram with layer picks overlaid and red shading on traces that fail the combined QC. The bottom panel shows a stacked plot of each individual check. Each check’s trace is high when the check passes and low when it fails.

<Figure size 1500x700 with 2 Axes>

Flight track map

The flight track projected onto EPSG:3031 with coastline context. Traces that pass all QC checks are shown in green; traces filtered out by any check are shown in red.

/home/runner/work/xopr/xopr/.venv/lib/python3.12/site-packages/cartopy/io/__init__.py:263: DownloadWarning: Downloading: https://naturalearth.s3.amazonaws.com/10m_physical/ne_10m_ocean.zip
  warnings.warn(f'Downloading: {url}', DownloadWarning)
/home/runner/work/xopr/xopr/.venv/lib/python3.12/site-packages/cartopy/io/__init__.py:263: DownloadWarning: Downloading: https://naturalearth.s3.amazonaws.com/10m_physical/ne_10m_coastline.zip
  warnings.warn(f'Downloading: {url}', DownloadWarning)
<Figure size 800x800 with 1 Axes>

Running a subset of checks

You can run only specific checks by passing a subset of the registry keys. You can also mix in custom check functions as callable keys:

Strict thresholds: 288/969 traces passed (29.7%)
Default thresholds: 430/969 traces passed (44.4%)

Seasons without a heading

Many older seasons (for example every Greenland P3 season before 2002, and the 2009–2012 DC8 and TO seasons) have no Heading, Roll, or Pitch in their CSARP files. For heading_change, run_qc reconstructs a heading from the GPS positions using xopr.add_heading. The dataset records where the heading came from in attrs["heading_source"].

The reconstruction is the course over ground, not the true platform heading: it omits the crab angle from crosswind. That offset is typically a few degrees and changes slowly, so it cancels in the rate of change that heading_change uses. Traces where the GPS track is unreliable (stationary platform, position dropouts, time gaps) get a NaN heading and fail the check.

Heading in file: False
heading_source: gps
qc_heading_change: 3338/3910 passed
/home/runner/work/xopr/xopr/src/xopr/opr_tools.py:57: FutureWarning: In a future version of xarray the default value for data_vars will change from data_vars='all' to data_vars=None. This is likely to lead to different results when multiple datasets have matching variables with overlapping values. To opt in to new defaults and get rid of these warnings now use `set_options(use_new_combine_kwarg_defaults=True) or set data_vars explicitly.
  merged_segment = xr.concat(segment_frames, dim='slow_time', combine_attrs=merge_dicts_no_conflicts).sortby('slow_time')

On a season that does have a measured heading we can compare the two. The difference is the crab angle: small, slowly varying, and irrelevant to the heading rate.

<Figure size 1200x500 with 2 Axes>

Custom check functions

You can also pass a callable as a check key. The function must accept a dataset as its first argument and return a dataset with QC mask variables added (via apply_qc_mask).

Here we define a simple roll-angle check that flags traces where the platform roll exceeds 5 degrees:

Note that Roll (like Heading) is only present for seasons with an inertial navigation system; unlike heading, it cannot be reconstructed from GPS, so this check raises on older seasons.

  qc: 438/969 passed
  qc_ice_thickness_threshold: 481/969 passed
  qc_roll: 917/969 passed