ctdproc.io.CTDHex

class ctdproc.io.CTDHex(filename)[source]

Bases: object

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

Parses a Seabird .hex data file and its companion .xmlcon calibration file into time series of physical sensor values.

Parameters:

filename (str or pathlib.Path) – Path to the .hex file. The matching .xmlcon file must be in the same directory.

Variables:
  • filename (pathlib.Path) – Path to the source hex file.

  • cfgp (munch.Munch) – Parsed sensor configuration from the xmlcon file.

  • dataraw (pandas.DataFrame) – Raw voltage and frequency data.

  • data (pandas.DataFrame) – Sensor data converted to physical units (populated by physicalunits()).

Examples

>>> c = CTDHex("path/to/cast.hex")
>>> ds = c.to_xarray()

Notes

Outstanding gaps: oxygen hysteresis correction, fluorometer voltage conversion.

__init__(filename)[source]

Methods

__init__(filename)

mattime_to_datetime64(dtnum)

Convert Matlab time format to numpy datetime64 time format.

mattime_to_sbetime(dt)

Convert matlab time format to SBE time format.

parse_hex()

Parse the hex file into a raw frequency/voltage DataFrame.

physicalunits()

Convert raw frequencies and voltages into physical units.

read_xml_config()

Parse the companion .xmlcon calibration file into self.cfgp.

sbetime_to_mattime(dt)

Convert SBE time format to matlab time format.

to_mat(matname)

Save the converted time series to a MATLAB .mat file.

to_xarray()

Convert data into xarray.Dataset.

mattime_to_datetime64(dtnum)[source]

Convert Matlab time format to numpy datetime64 time format.

mattime_to_sbetime(dt)[source]

Convert matlab time format to SBE time format.

parse_hex()[source]

Parse the hex file into a raw frequency/voltage DataFrame.

Reads the binary-encoded sensor words for the five frequency channels (pressure, two temperature, two conductivity), the eight voltage channels, the mod-count, the timestamp, SPAR, ship position, and CTD status into self.dataraw. Called automatically by physicalunits().

physicalunits()[source]

Convert raw frequencies and voltages into physical units.

Applies the calibration coefficients in self.cfgp to the contents of self.dataraw and stores the result in self.data as a munch.Munch of named time series: pressure (dbar), temperature (deg C), conductivity (mS/cm), salinity, oxygen (ml/L), altimeter, transmissivity, PAR, SPAR, fluorescence, and time.

read_xml_config()[source]

Parse the companion .xmlcon calibration file into self.cfgp.

Locates the xmlcon file alongside the hex file, parses the SensorArray block, and converts coefficient strings to floats. Sensors not in the supported set are skipped.

sbetime_to_mattime(dt)[source]

Convert SBE time format to matlab time format.

to_mat(matname)[source]

Save the converted time series to a MATLAB .mat file.

Parameters:

matname (str or pathlib.Path) – Output .mat filename.

to_xarray()[source]

Convert data into xarray.Dataset.

Returns:

ds – CTD time series in Dataset format.

Return type:

xarray.Dataset