instrument_data.py#

Functions for processing instrument data.

seabirdscientific.instrument_data.HEX_TYPE_SYSTEM_TIME = 'system time'#

Possible lengths for hex data types

class seabirdscientific.instrument_data.HexDataTypes(*values)#

Possible data types in hex files. Deprecated. Use HEX_TYPE_* constants.

class seabirdscientific.instrument_data.InstrumentType(*values)#

The type of instrument that generated the hex file being read

class seabirdscientific.instrument_data.Sensors(*values)#

Available sensors to read hex data from

seabirdscientific.instrument_data.frequency_from_3_bytes(hex_segment: str) → float#

Convert 3 bytes to a frequency value in Hz.

Parameters:

hex_segment – 3-byte (6-character) hex string

Returns:

frequency in Hz

seabirdscientific.instrument_data.logger = <Logger seabirdscientific.instrument_data (INFO)>#

Possible data types in hex files

seabirdscientific.instrument_data.read_hex(instrument_type: InstrumentType, hex_segment: str = '', enabled_sensors: list[Sensors] | None = None, moored_mode=False, is_shallow=True, frequency_channels_suppressed=0, voltage_words_suppressed=0) → dict#

Converts an instrument data hex string into engineering units.

Parameters:
  • instrument_type – determines how units are converted

  • hex_segment – one line from a hex data file

  • enabled_sensors – mooredMode parses time for 19plus in moored mode if true

  • moored_mode – array of Sensors that are enabled. For 37 this is always temperature, conductivity, pressure. Defaults to False

Returns:

the sensor values in engineering units that were extracted from the input hex string

seabirdscientific.instrument_data.read_hex_file(filepath: Path | str, instrument_type: InstrumentType, enabled_sensors: list[Sensors], moored_mode=False, is_shallow=True, frequency_channels_suppressed=0, voltage_words_suppressed=0) → Dataset#

Reads a .hex file

Parameters:
  • filepath – path to the .hex file

  • instrument_type – the instrument that generated the .hex file

  • enabled_sensors – list of sensors that were enabled on the instrument

  • moored_mode – whether the instrument was in moored or profiling mode, defaults to False

  • is_shallow – boolean for deep or shallow seafet,

  • frequency_channels_suppressed – number of SBE911 requency channels supressed,

  • voltage_words_suppressed – number of SBE911 voltage channels suppressed,

Returns:

an xarray Dataset with the hex data

seabirdscientific.instrument_data.read_nmea_coordinates(hex_segment: str)#

Converts a 3 byte NMEA hex string to latitude or longitude

Parameters:

hex_segment – 3 byte hex string

Returns:

latitude or longitide coordinate or nan if the hex length is wrong

seabirdscientific.instrument_data.read_nmea_time(hex_segment: str)#

Convert an 8 byte hex string to the number of seconds since 2000

Parameters:

hex_segment – an 8 byte hex string

Returns:

an integer number of seconds or nan if the hex length was wrong

seabirdscientific.instrument_data.read_phyre_data(hex_segment: str, instrument_type: InstrumentType) → dict[str, int | datetime]#

Converts a pHyre or pHyreCAT hex string into raw numeric values.

Parameters:
  • hex_segment – one line from a hex data file

  • instrument_type – InstrumentType.pHyre or InstrumentType.pHyreCAT

Returns:

raw sensor values extracted from the hex string

seabirdscientific.instrument_data.read_sbe19plus_data(hex_segment: str = '', enabled_sensors: list[Sensors] | None = None, moored_mode=False) → dict[str, float | datetime]#

Converts a 19plus V2 data hex string into engineering units.

Parameters:
  • hex_segment – one line from a hex data file

  • enabled_sensors – array of Sensors that are enabled. For 37 this is always temperature, conductivity, pressure. Defaults to None

  • moored_mode – parses time for 19plus in moored mode if true. Defautls to False

Returns:

the 19plus V2 sensor values in engineering units that were extracted from the input hex string, or nan if the hex length is wrong

seabirdscientific.instrument_data.read_sbe37sm_data(hex_segment: str = '', enabled_sensors: list[Sensors] | None = None) → dict[str, int | float | datetime]#

Converts a 37 family data hex string into engineering units.

Parameters:
  • hex_segment – one line from a hex data file

  • enabled_sensors – array of Sensors that are enabled. For 37 this is always temperature, conductivity, pressure. Defaults to False

Returns:

the 37 family sensor values in engineering units that were extracted from the input hex string

seabirdscientific.instrument_data.read_sbe39plus_data(hex_segment: str = '', enabled_sensors: list[Sensors] | None = None) → dict[str, int | float | datetime]#

Converts a 39plus data hex string into engineering units.

Parameters:
  • hex_segment – one line from a hex data file

  • enabled_sensors – array of Sensors that are enabled

Returns:

the 39plus sensor values in engineering units that were extracted from the input hex string

seabirdscientific.instrument_data.read_sbe911plus_data(hex_segment: str = '', enabled_sensors: list[Sensors] | None = None, frequency_channels_suppressed: int = 0, voltage_words_suppressed: int = 0) → dict[str, int | float | datetime]#

Converts a 911Plus hex string into engineering units.

The four status bits are returned as raw bit values:

  • pump status: 1 when the pump is on

  • bottom contact status: 1 when there is no bottom contact

  • confirm status: 1 while the deck unit detects a bottle-fire confirm

  • modem status: 0 when the deck unit detects the modem carrier

Parameters:
  • hex_segment – one line from a hex data file

  • enabled_sensors – list of enabled Sensors

  • frequency_channels_suppressed – number of suppressed frequency channels

  • voltage_words_suppressed – number of suppressed voltage words

Returns:

dictionary of sensor values in engineering units

seabirdscientific.instrument_data.read_seafet_data(hex_segment: str, instrument_type: InstrumentType, is_shallow: bool = True) → dict[str, int | float | datetime]#

Converts a SeaFET2 or SeapHox2 hex string into engineering units.

Parameters:
  • hex_segment – one line from a hex data file

  • instrument_type – InstrumentType.SeaFET2 or InstrumentType.SeapHox2

  • is_shallow – if True, include internal pH and pH reference temperature

Returns:

sensor values in engineering units extracted from the hex string

seabirdscientific.instrument_data.read_status_sign(hex_segment: str)#

Converts a hex byte to the signs for NMEA latitude and longitude

Parameters:

hex_segment – 1 byte hex string

Returns:

a list of two integers (1 or -1) or nan if the hex length is wrong

seabirdscientific.instrument_data.reverse_hex_bytes(bytes_str: str) → str#

Reverse the ASCII hex byte ordering.

Parameters:

bytes_str – The ASCII hex bytes that need reordering.

Returns:

The reordered ASCII hex bytes.

seabirdscientific.instrument_data.voltages_from_3_bytes(hex_segment: str) → tuple[float, float]#

Convert 3 bytes to two voltage channels.

Each voltage channel is 12 bits; adjacent channels share a byte. Channels are suppressed in pairs, 3 bytes at a time.

Parameters:

hex_segment – 3-byte (6-character) hex string

Returns:

tuple of two voltages (voltageA, voltageB)