pelagos_py.steps.quality_control.apply_qc#

class pelagos_py.steps.quality_control.apply_qc.ApplyQC(name, parameters=None, diagnostics=False, context=None)[source]#

Bases: pelagos_py.steps.base_step.BaseStep

Step to apply quality control tests to the dataset.

Inherits properties from BaseStep (see base_step.py).

organise_flags(new_flags, overwrite=False)[source]#

Method for taking in new flags (new_flags) and cross checking against existing flags (self.flag_store), including upgrading flags when necessary, following ARGO flagging standards. With overwrite the new flags replace the stored ones outright (tests that merge themselves, e.g. visual qc). See Wong et al. 2025 pp. 106 (http://dx.doi.org/10.13155/33951) and Mancini et al. 2021 pp. 43-44 for additional ARGO flag definitions.

Combinatrix logic: 0: No QC performed, the initial flag. 1: Good data. No adjustment needed. 2: Probably good data. 3: Probably bad data that are potentially correctable. 4: Bad data that are not correctable. 5: Value changed. 6, 7: Not used. 8: Estimated by interpolation, extrapolation, or other algorithm. 9: Missing value.

The combinatrix defines flagging priority when merging in new flags. The flag value itself acts as a kind of index. As an example, if an existing flag is 2 (probably good data) and a new flag is 4 (bad data), the resulting flag will be 4. 2 (probably good data) + 4 (bad data) -> 4 (bad data) 3 (probably bad data) + 5 (value changed) -> 3 (probably bad data)

Parameters:

new_flags (xarray.Dataset) – Dataset containing new QC flag variables to be merged into the existing flag store.

run()[source]#

Run the Apply QC step.

Raises:
  • KeyError – If no QC operations are specified, or if requested QC tests are invalid.

  • ValueError – If no data is found in context.