• RSK 
  • Channel : longName of channel to align (e.g. temperature)
  • lag : lag to apply to the channel, negative lag shifts the channel backwards in time (earlier), while a positive lag shifts the channel forward in time (later)


  • profile: [ ] (all profiles, default)
  • direction : up, down, or both (all available directions, default)
  • shiftfill : zeroOrderhold (default), mirror, nan or union
  • lagunits : samples (default) or seconds
  • visualize: show plot with original and processed data on specified profile(s)


  • RSK

This function shifts a channel in time by an integer number of samples or seconds in time, specified by the argument lag.  A negative lag shifts the channel backwards in time (earlier), while a positive lag shifts the channel forward in time (later).  Shifting a channel is most commonly used to align conductivity to temperature to minimize salinity spiking.  It could also be used to adjust for the time delay caused by sensors with relatively slow adjustment times (e.g., dissolved oxygen sensors).

The shiftfill parameter describes what values will replace the shifted values. The default treatment is zeroOrderhold, in which the first (or last) value is used to fill in the unknown data if the lag is positive (or negative). When shiftfill is nan, missing values are filled with NaNs. When shiftfill is mirror the edge values are mirrored to fill in the missing values. When shiftfill is union, all channels are truncated by lag samples.  The diagram below illustrates the shiftfill options.


Using RSKalignchannel to minimize salinity spiking:
Salinity is derived with an empirical formula that requires measurements of conductivity, temperature, and pressure. The conductivity, temperature, and pressure sensors all have to be aligned in time and space to achieve salinity with the highest possible accuracy. Poorly-aligned conductivity and temperature data will result in salinity spikes in regions where the temperature and salinity gradients are strong.  RSKcalculateCTlag can be used to estimate the optimal lag by minimizing the spikes in the salinity time series, or the lag can be estimated by calculating the transit time for water to pass from the conductivity sensor to the thermistor. RSKalignchannel can then be used to shift the conductivity channel by the desired lag, and then salinity needs to be recalculated using RSKderivesalinity


rsk = RSKopen('file.rsk');
rsk = RSKreadprofiles(rsk, 'profile', 1:10, 'direction', 'down'); 

%   1. Shift temperature channel of first four profiles with the same lag value.
rsk = RSKalignchannel(rsk, 'channel', 'Temperature', 'lag', 2, 'profile', 1:4);

%   2. Shift oxygen channel of first 4 profiles with profile-specific lags.
rsk = RSKalignchannel(rsk, 'channel', 'Dissolved O2', 'lag', [2 1 -1 0], 'profile',1:4);

%   3. Shift conductivity channel from all downcasts with optimal lag calculated 
%      with RSKcalculateCTlag.m.
lag = RSKcalculateCTlag(rsk);
rsk = RSKalignchannel(rsk, 'channel', 'Conductivity', 'lag', lag);