pelagos_py.steps.quality_control.range_qc#

class pelagos_py.steps.quality_control.range_qc.range_qc(data, **kwargs)[source]#

Bases: pelagos_py.steps.base_qc.BaseQC

Flag measurements by value range. A single, configurable replacement for the old separate “gross range” and “impossible range” tests.

Each {flag: bounds} entry describes one or more bands. A band is given as a [low, high] pair with an inside/outside keyword saying which side to flag:

  • ``[low, high, “outside”]`` — a good band; data < low or > high gets the flag. (The old “gross range” behaviour.) Accepts outside, out or o (any capitalisation).

  • ``[low, high, “inside”]`` — an impossible band; data strictly between the two bounds gets the flag. (The old “impossible range” behaviour.) Accepts inside, in or i (any capitalisation).

  • A single scalar value — flags exact matches (data == value). Handy for fill/filler values, e.g. 4: 0.0 to flag a pressure of exactly 0 as bad.

The same flag can cover several bands by giving a list of bands, e.g. 4: [[2, 3, "inside"], [0.1, 10, "outside"]] — a point is flagged if it falls in any of them.

If the keyword is omitted the bound order is used as a fallback: an ascending [low, high] means outside (a good band) and a descending [high, low] means inside (an impossible band). An explicit keyword always wins over the order, so write inside/outside when in doubt.

Within a variable, entries are applied most-severe-flag-first, so on overlap the worse flag wins. Anything checked but not flagged is marked good (1).

Target Variable: Any Flag Number: Any (user-defined) Variables Flagged: Any (the tested variables, plus any also_flag companions)

Example

- name: "Apply QC"
  parameters:
    qc_settings:
      range qc:
        variable_ranges:
          PRES:
            3: [-2.4, -5, inside]   # impossible band: flag data INSIDE it
            4: [-5, -.inf, inside]
            9: 0.0                  # single scalar -> flag the exact fill value 0.0
          TEMP:
            3: [0, 30, outside]     # good band: flag data OUTSIDE it
            4: [-2.5, 40, outside]
          CNDC:
            # one flag, two bands: flag bad both inside [2, 3] and outside [0.1, 10]
            4: [[2, 3, inside], [0.1, 10, outside]]
        also_flag:
          CNDC: [PRES, TEMP]    # CNDC's flags propagate onto PRES & TEMP (worst wins)
        test_depth_range: [-100, 0]   # OPTIONAL: only check this DEPTH window
  diagnostics: true             # plots every flagged variable, coloured by flag
return_qc()[source]#

Representative of QC processing, to be overridden by subclasses.

Returns:

flags – Output QC flags for the data specific to the test.

Return type:

array-like

plot_diagnostics()[source]#

Representative of diagnostic plotting (optional).