sbe.channels

Module for handling “channel” data columns within the SeaBird hex.

Functions

get_volt_indicies(n)

Calculate the HEX indices of a given voltage channel

get_voltage(hex, channel, freq_supressed)

Compute voltage for given voltage channel

get_frequency(hex, channel)

Compute frequency for given frequency channel

_sbe_time(bytes_in[, sbe_type])

Determine UTC datetime from SBE format of 4 bytes, using either scan or NMEA.

_nmeaposition(bytes_in)

Determine location from SBE format of 8-bit integers.

_sbe9core(bytes_in)

Handle the bundle of SBE9 core metadata columns: SBE9 temperature, pump status, contact switch, bottle fire, modem, modulo.

get_metadata(hex_data, cfg)

A wrapper of sorts to handle columnar metadata in the source HEX file.

Module Contents

sbe.channels.get_volt_indicies(n: int)

Calculate the HEX indices of a given voltage channel

sbe.channels.get_voltage(hex: xarray.DataArray, channel: int, freq_supressed: int)

Compute voltage for given voltage channel

sbe.channels.get_frequency(hex: xarray.DataArray, channel: int)

Compute frequency for given frequency channel

sbe.channels._sbe_time(bytes_in: xarray.DataArray, sbe_type: Literal['ScanTime', 'NmeaTime'] = 'ScanTime')

Determine UTC datetime from SBE format of 4 bytes, using either scan or NMEA.

See legacy code sbe_reader.SBEReader._sbe_time and _reverse_bytes for historical examples when ODF worked on metadata as strings.

Inputs: bytes_in: xarray DataArray of 4xn bytes. sbe_type: string of type of time to pull from (“NmeaTime” or “ScanTime”) reverse: A historical argument for reversing byte order.

Output: xarray 1xn DataArray of float64 of variable “Timestamp” in UTC. Check these values using pd.to_datetime(data_to_write.values.flatten(), utc=True)

sbe.channels._nmeaposition(bytes_in: xarray.DataArray)

Determine location from SBE format of 8-bit integers.

Requires bytes_in of 7 bytes in a DataArray or array-like format.

See legacy code sbe_reader.SBEReader._location_fix context.

Input: bytes 1 to 3: three components of Latitude bytes 4 to 6: three components of Longitude byte 7: signs (hemispheres) for lat/lon and if this location is a “new” fix

Output: DataArray of: latitude, longitude, new fix Latitude is a float Longitude is a float If it is a “new fix” it will be true, otherwise false

For byte 7: If bit 1 in byte_pos is 1, this is a new position If bit 8 in byte_pos is 1, lat is negative If bit 7 in byte_pos is 1, lon is negative

sbe.channels._sbe9core(bytes_in: xarray.DataArray)

Handle the bundle of SBE9 core metadata columns: SBE9 temperature, pump status, contact switch, bottle fire, modem, modulo.

The SBE9’s pressure temperature port gets 1.5 bytes (12 bits) The CTD status flag booleans get 0.5 bytes (4 bits) The modulo word gets 1 byte (8 bits)

sbe.channels.get_metadata(hex_data: xarray.DataArray, cfg: dict)

A wrapper of sorts to handle columnar metadata in the source HEX file.

Columns of the HEX are output in a specific order, based on configuration: —done with hex_to_f, hex_to_v— 1) Data from the instrument (written to netCDF as engineering)

  1. Frequency (3 bytes each)

  2. Voltage (12 bits each)

—this wrapper— 2) Surface Par (3 bytes) (ODF historically has limited support for this) 3) NMEA lat/lon (7 bytes) 4) NMEA depth (3 bytes) 5) NMEA time (4 bytes) (low byte first) 6) Additional Data from the instrument

  1. Pressure temp (12 bits)

  2. pump status (4 bits)

  3. modulo byte (1 byte)

  1. System time (4 bytes) (low byte first)

Information about these steps (bytes, equations) is available in SBE’s SBEDataProcessing and SeaSave manuals.

Inputs: hex_data: xarray DataArray of the entire hex file cfg: the data.xmlcon_box from the XMLCON file, indicating which features are added to the HEX rows