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.QCHandlingMixinSubtract 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
_ADJUSTEDcompanion variable. Written for chlorophyll but works for any variable with a deep, signal-free region.The dark value is estimated as follows:
Find profiles whose
depth_varreaches pastdepth_threshold(deeper = larger, e.g.PRES > 950) that also carry enough data: at leastmin_profile_pointsfinite points overall andmin_valid_pointsbelow the threshold. Take the firstn_profilesthat qualify.Smooth each profile with a
smoothing_window-point rolling median.Keep the deep points (below the threshold) that are finite and below
max_valid_value(guards against non-dark readings).Take each profile’s minimum deep value, provided it has at least
min_valid_pointsvalid deep points.Use the median of those per-profile minima as the dark value.
A
dark_valuesupplied via config skips this estimation and is subtracted directly. Samples whose flags fall incalculation_flag_filterare 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