API reference

The public API is the four submodules re-exported from ctdproc. The sections below group entries by their role in the processing pipeline (ctdproc.proc.run_all()).

Pipeline orchestration

ctdproc.proc.run_all(ds)

Run all standard processing steps on raw CTD time series.

ctdproc.proc.split_updn(ds)

Split a cast into downcast and upcast at the pressure maximum.

ctdproc.proc.bincast(ds, dz, zmin, zmax)

Depth-bin CTD time series.

Cleaning

ctdproc.proc.cleanup(ds)

Clean up CTD raw time series.

ctdproc.proc.cleanup_ud(ds)

Clean a single down- or up-cast and calculate derived variables.

ctdproc.proc.despike(da, spike_threshold)

Set spikes to NaN where the absolute first difference exceeds a threshold.

ctdproc.proc.remove_out_of_bounds(da, bmin, bmax)

Replace out-of-bounds values with NaN.

ctdproc.proc.preen_ctd(ds)

Replace out-of-range values in p, t1, t2, c1, c2.

ctdproc.proc.rmloops(ds)

Eliminate depth loops in CTD data based on sinking velocity.

ctdproc.proc.wsink(p, Ts, Fs)

Compute sinking velocity from pressure record.

Phase correction

ctdproc.proc.phase_correct(ds)

Bring temperature and conductivity into phase via FFT-based fit.

ctdproc.proc.add_tcfit_default(ds)

Set the default pressure range used for the t/c phase fit.

Thermodynamic calculations

ctdproc.calcs.swcalcs(data)

Calculate SA, s, CT, theta, sigma, oxygen, depth, z

ctdproc.calcs.calc_sal(data)

Add absolute and practical salinity for both sensor pairs.

ctdproc.calcs.calc_temp(data)

Add conservative and potential temperature for both sensor pairs.

ctdproc.calcs.calc_sigma(data)

Add potential density anomaly for both sensor pairs.

ctdproc.calcs.calc_depth(data)

Add a depth coordinate (m, positive down) computed from pressure.

ctdproc.calcs.calc_allsal(c, t, p, lon, lat)

Calculate absolute and practical salinity.

I/O

ctdproc.io.CTDHex(filename)

Converter for Seabird 9/11 CTD data in hex format.

ctdproc.io.CTDx(filename)

Convenience wrapper that returns a ready-to-process xarray Dataset.

ctdproc.io.add_default_proc_params(ds)

Attach the default processing parameters to ds.attrs in place.

ctdproc.io.prof_to_mat(matname, datad, datau)

Save processed down- and up-cast Datasets to a single MATLAB file.

Low-level utilities

ctdproc.helpers.findsegments(ibad)

Find contiguous segments in an array of indices.

ctdproc.helpers.inearby(ibad, inearm, inearp, n)

Find indices left and right of given indices and add them to the index array.

ctdproc.helpers.interpbadsegments(x, ibad)

Interpolate over segments of bad data.

ctdproc.helpers.glitchcorrect(x, diffx, prodx)

Remove glitches/spikes in array.

ctdproc.helpers.preen(x, xmin, xmax)

Eliminate values outside given range and interpolate.

ctdproc.helpers.unique_arrays(*arrays)

Find unique elements in more than one numpy array.

ctdproc.helpers.mtlb2datetime(matlab_datenum)

Convert Matlab datenum format to python datetime.

ctdproc.helpers.datetime2mtlb(dt)

Convert a numpy datetime64 array to MATLAB datenum.