pelagos_py.steps.processing.deep_correction#

class pelagos_py.steps.processing.deep_correction.deep_correction(name, parameters=None, diagnostics=False, context=None)[source]#

Bases: pelagos_py.steps.base_step.BaseStep, pelagos_py.utils.qc_handling.QCHandlingMixin

Subtract a deep dark offset from a profile variable.

Estimates a roughly-constant baseline (the dark value) from the deepest measurements and subtracts it from the whole record, writing the result to an _ADJUSTED companion variable. Written for chlorophyll but works for any variable with a deep, signal-free region.

The dark value is estimated as follows:

  1. Find profiles whose depth_var reaches past depth_threshold (deeper = larger, e.g. PRES > 950) that also carry enough data: at least min_profile_points finite points overall and min_valid_points below the threshold. Take the first n_profiles that qualify.

  2. Smooth each profile with a smoothing_window-point rolling median.

  3. Keep the deep points (below the threshold) that are finite and below max_valid_value (guards against non-dark readings).

  4. Take each profile’s minimum deep value, provided it has at least min_valid_points valid deep points.

  5. Use the median of those per-profile minima as the dark value.

A dark_value supplied via config skips this estimation and is subtracted directly. Samples whose flags fall in calculation_flag_filter are left out of the estimate but still corrected — they just cannot bias it.

Examples

A minimal config only needs the variable to correct; every other parameter has a sensible default:

- name: "Deep Correction"
  parameters:
    apply_to: "CHLA"
  diagnostics: true