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.Used for cross-calibration against a reference, unit conversions and renames. The coefficients come from the user; the step does no comparison itself. QC flags are copied unchanged. See Cross-Calibration.
With
expected_range, the correction runs only when the median of the input (before correcting) is outside[min, max], so a unit conversion skips files that already arrive in the right units. Leave it out for cross-calibration.- Parameters:
target_variable (str) – Name of the variable to correct (e.g.
"CNDC"). Its_ADJUSTEDversion is read instead when present, so corrections stack.output_as (str or list, optional) – Name(s) to write the result under. Defaults to
<target_variable>_ADJUSTED, leaving the raw variable untouched. Set it to a new name to copy/rename, e.g.LATITUDE_GPS->LATITUDEwithslope: 1leaves the values unchanged and just exposes the new name. A list writes the same result under several names, e.g.[CHLA_ADJUSTED, CHLA_MID]keeps a mid-processing snapshot inCHLA_MID. Each output gets a copy of the source’s_QC.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]where correct data lies. The correction is applied only when the input’s median falls outside it. If omitted, it is always applied.time_start (str, optional) – Restrict the correction to a TIME window (e.g.
"2024-07-01T00:00:00"). Points outside the window keep their raw value. Either bound may be omitted.time_end (str, optional) – Restrict the correction to a TIME window (e.g.
"2024-07-01T00:00:00"). Points outside the window keep their raw value. Either bound may be omitted.corrected_units (str, optional) – Units string written to the output variable’s attributes after a correction is applied (e.g.
"mS/cm"). Left untouched if omitted or if no correction runs.append_description (str, optional) – Note written to the output variable’s
commentattribute (e.g."Renamed from LATITUDE_GPS").append_descriptionadds to any existing comment;overwrite_descriptionreplaces it. Set at most one.overwrite_description (str, optional) – Note written to the output variable’s
commentattribute (e.g."Renamed from LATITUDE_GPS").append_descriptionadds to any existing comment;overwrite_descriptionreplaces it. Set at most one.optional (bool, optional) – If
True, skip without an error whentarget_variableis absent, e.g. a rename that only applies to some file naming conventions. DefaultFalse.
Examples
Example usage in a pipeline configuration:
steps: - name: Correct Values parameters: target_variable: TEMP slope: 1.001 intercept: -0.05 diagnostics: false