ctdproc.proc.phase_correct

ctdproc.proc.phase_correct(ds)[source]

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

Estimates the thermistor time constant tau and the t/c sensor lag L for each (temperature, conductivity) pair by fitting an arctan model to the cross-spectral phase, then applies the correction in the frequency domain. Operates over the pressure range stored in ds.attrs["tcfit"] (see add_tcfit_default()). This is the most expensive step in run_all() and is critical for accurate salinity.

Parameters:

ds (xarray.Dataset) – CTD time series for a single cast (down or up). Required attrs: tcfit; optional plot_spectra and plot_path for diagnostic output.

Returns:

ds – Time series with t1, t2, c1, c2 replaced by their phase-corrected, low-pass-filtered counterparts.

Return type:

xarray.Dataset