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(value)#

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

class seabirdscientific.instrument_data.InstrumentType(value)#

The type of instrument that generated the hex file being read

seabirdscientific.instrument_data.SECONDS_BETWEEN_EPOCH_AND_2000 = 946684800#

Possible data types in hex files

class seabirdscientific.instrument_data.Sensors(value)#

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.read_cnv_file(filepath: Path | str) Dataset#

Import the data from a .cnv file and put it into an xarray Dataset. Duplicate varioable names will have a number appended. For example, the second “depSM” becomes “depSM_1”.

Parameters:

filepath – the path to the .cnv file to be imported

Returns:

the imported data from the .cnv file

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

Raises:

RuntimeWarning – raised if the hex string is the wrong length

Returns:

latitude or longitide coordinate

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

Raises:

RuntimeWarning – raised if the hex string is the wrong length

Returns:

_description_

seabirdscientific.instrument_data.read_sbe19plus_format_0(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

Raises:

RuntimeWarning – if the hex string length does not match the expected length

seabirdscientific.instrument_data.read_sbe37sm_format_0(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_format_0(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_format_0(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.

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_format_0(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

Raises:
  • RuntimeWarning – raised if the hex string is the wrong length

  • RuntimeWarning – raised when the signs are converted incorrectly

Returns:

a list of two integers (1 or -1)

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)