pelagos_py.steps.input_output.correct_values#
- class pelagos_py.steps.input_output.correct_values.CorrectValues(name, parameters=None, diagnostics=False, context=None)[source]#
Bases:
pelagos_py.steps.base_step.BaseStepApply an affine correction
corrected = slope * value + interceptto a variable.The correction is conditional when
expected_rangeis given: the median of the valid (non-NaN) data is compared against[min, max], and the correction is applied only when the median falls outside that range (i.e. the data still looks uncorrected). Whenexpected_rangeis omitted the correction is always applied.This makes a config robust to upstream fixes: e.g. a CNDC unit conversion (
slope: 10) targetingexpected_range: [20, 45]will scale S/m data into mS/cm, but quietly skip files that already arrive in mS/cm.- Parameters:
target_variable (str) – Name of the variable to correct (e.g.
"CNDC").slope (float, optional) – Multiplicative factor (default
1.0). For a x10 unit conversion, set10.intercept (float, optional) – Additive offset applied after scaling (default
0.0). Use for alignment.expected_range (list, optional) –
[min, max]for the corrected variable. The correction is applied only when the data’s median falls outside this range. If omitted, the correction is always applied.corrected_units (str, optional) – Units string written to the variable’s attributes after a correction is applied (e.g.
"mS/cm"). Left untouched if omitted or if no correction runs.
Examples
Example usage in a pipeline configuration:
steps: - name: Correct Values parameters: target_variable: CNDC slope: 10.0 intercept: 0.0 expected_range: [20, 45] corrected_units: mS/cm diagnostics: false