Routines

Routines are standalone, array-in / array-out processing functions: each takes plain arrays (plus scalar parameters) and returns one or more arrays. Each routine lives in its own versioned file under +routines, so it can be lifted into another project as a standalone function. A routine uses base MATLAB where possible. If a routine needs an external dependency, that dependency does not ship with RSKtools, so you can install it separately and add it to your MATLAB path.

Note

Calling a routine (MATLAB). Routines live in the +routines package, so call them with the routines. prefix (RSKtools must be on your MATLAB path):

[temperatureCorrected, mask] = routines.correcttempADCcal(temperature, time);

Request help the same way — help routines.correcttempADCcal or doc routines.correcttempADCcal. The bare name (help correcttempADCcal) and lookfor do not resolve package members; discover routines with tab-completion after typing routines., from doc, from this page, or via the See also line of the matching RSK* post-processor.

correcttempADCcal

routines.correcttempADCcal(temperature, time)

correcttempADCcal - Remove periodic A2D self-calibration outliers from temperature.

Version: 1.0.0

Syntax:

[temperatureCorrected, mask] = routines.correcttempADCcal(temperature, time)

[temperatureCorrected, mask, version] = routines.correcttempADCcal(temperature, time)

Standalone, array-in / array-out routine (no RSK object, no file I/O). RBR instruments’ analogue-to-digital (A2D) converter recalibrates periodically; while it does, one or more temperature samples are affected and become outliers. This routine detects those recurring outliers and replaces the affected samples by interpolation from clean neighbours.

The self-cal event is driven by the instrument’s own 60-s clock cycle, and the same clock stamps every sample, so once the cycle’s phase is locked the contaminated samples in the whole record are determined exactly (the ADC does not skip cycles, and the timestamps do not drift relative to the cycle). If the phase cannot be locked the routine makes no change and returns the series unchanged rather than fabricating a correction.

This routine depends only on base MATLAB so it can be lifted into another repository unchanged.

Inputs:

Required:

  • temperature – Temperature samples (degrees C), N-by-1.

  • time – Matching sample times in SECONDS, N-by-1. Elapsed or absolute both work: the routine phase-locks on the 60-s self-cal cycle, so it only needs the 60-s periodicity and a consistent phase, not an absolute reference. The intervals must be the true sample spacing.

Outputs:

  • temperatureCorrected – Cleaned series (defect removed, still a valid temperature; a drop-in replacement for temperature).

  • mask – Logical N-by-1, true for the samples that were actually corrected. A detected run that was skipped (no finite neighbour, or the whole series) or whose interpolated proposal clamped to no change is excluded, so sum(mask) is the number of samples genuinely modified.

  • version – This routine’s own semantic version, for logging.

If the periodic A2D self-calibration signature cannot be confirmed (the instrument does not perform it, or the record is too short to verify), the routine returns the series unchanged with an all-false mask – it never fabricates a correction and raises no error.

Example:

[tCorr, mask] = routines.correcttempADCcal(temperature, tstamp);

See also:

RSKcorrecttempADCcal().