r2r_ctd.derived

Functions that take some existing data, and either extract from or transform it

e.g. the get_longitude() function tries to extract the longitude information from the hdr file

Attributes

Functions

_parse_coord(→ float | None)

Parses a spaced separated DDM coordinate with hemisphere to decimal degrees

get_longitude(→ float | None)

Get the cast longitude from NMEA header

get_latitude(→ float | None)

Get the cast latitude from NMEA header

_normalize_date_strings(→ str)

Try to make the date strings in sbe hdr files have a consistent format

get_time(→ datetime.datetime | None)

Gets the time from the hdr file

make_con_report(ds)

Runs ConReport.exe on the xmlcon file in the dataset

get_model(→ str | None)

Given a configuration report, get the SBE model string

_con_report_extract_sensors(→ list[str])

Extract a list of sensors from a configuration report, adds some virtual sensors if NMEA information was added to the data

get_con_report_sn(→ set[str])

Get the serial numbers for instruments from the configuration report (XMLCON).

get_hdr_sn(→ str | None)

Get an instruments serial number from the .hdr file.

make_derive_psa(→ bytes)

Makes the derive psa config file for derive.exe based on the configuration report, will add second density calculation if dual channel

make_binavg_psa(→ bytes)

Get the binage psa config from r2r_ctd.sbe.binavg_template() and return it unmodified.

make_datcnv_psa(→ bytes)

Make the datcnv psa config based on the configuration report, populating the CalcArray element

make_cnvs(→ dict[str, xarray.Dataset])

Makes the derived cnv files

Module Contents

r2r_ctd.derived.logger
r2r_ctd.derived._parse_coord(coord: str) float | None

Parses a spaced separated DDM coordinate with hemisphere to decimal degrees

>>> _parse_coord("32 52.02 N")
32.867
>>> _parse_coord("117 15.435 W")
-117.25725
r2r_ctd.derived.get_longitude(ds: xarray.Dataset) float | None

Get the cast longitude from NMEA header

WHOI Divergence

The original code from WHOI tries to also get this from the ** Longitude line but I think the ** means it is a comment and can be anything the user puts in.

r2r_ctd.derived.get_latitude(ds: xarray.Dataset) float | None

Get the cast latitude from NMEA header

WHOI Divergence

The original code from WHOI tries to also get this from the ** Latitude line but I think the ** means it is a comment and can be anything the user puts in.

r2r_ctd.derived._normalize_date_strings(date: str) str

Try to make the date strings in sbe hdr files have a consistent format

There can be variable whitespace between time elements, this function tries to remove them so we can use the normal strptime method.

>>> _normalize_date_strings("Oct 09 2019  17:05:53")
'Oct 09 2019 17:05:53'
r2r_ctd.derived.get_time(ds: xarray.Dataset) datetime.datetime | None

Gets the time from the hdr file

In the following priority order: * NMEA UTC (Time) * System UTC * System Upload Time

r2r_ctd.derived.make_con_report(ds: xarray.Dataset)

Runs ConReport.exe on the xmlcon file in the dataset

r2r_ctd.derived.get_model(con_report: str) str | None

Given a configuration report, get the SBE model string

Uses string matching and doesn’t parse/transform the model lines in the config report.

r2r_ctd.derived._con_report_extract_sensors(con_report: str) list[str]

Extract a list of sensors from a configuration report, adds some virtual sensors if NMEA information was added to the data

This is looking for lines in the form of:

1) channel type, sensor name

eg:

1) Frequency 0, Temperature

Then extracting the “sensor name” part of that line.

If “NMEA position data added” is “yes”, virtual latitude and longitude sensors are added to the list. If “NMEA time added” is “yes”, a virtual “ETime” sensor is added to the list. If the model of the instrument is an SBE911, a “pump” sensor is added to the list.

r2r_ctd.derived.get_con_report_sn(con_report: str, instrument: str) set[str]

Get the serial numbers for instruments from the configuration report (XMLCON).

r2r_ctd.derived.get_hdr_sn(hdr: str, instrument: str) str | None

Get an instruments serial number from the .hdr file.

That this serial number intersects with the set generated by get_con_report_sn() is reported in the QA.

r2r_ctd.derived.make_derive_psa(con_report: str) bytes

Makes the derive psa config file for derive.exe based on the configuration report, will add second density calculation if dual channel

r2r_ctd.derived.make_binavg_psa(con_report: str) bytes

Get the binage psa config from r2r_ctd.sbe.binavg_template() and return it unmodified.

r2r_ctd.derived.make_datcnv_psa(con_report: str) bytes

Make the datcnv psa config based on the configuration report, populating the CalcArray element

r2r_ctd.derived.make_cnvs(ds: xarray.Dataset) dict[str, xarray.Dataset]

Makes the derived cnv files

Creates all the various configuration files, then passes everything off to the companion container to actually be processed.