Read methods

open

RSK.open() None

Open an RBR RSK file and read any available metadata.

Makes a connection to an RSK (SQLite format) database as obtained from an RBR data logger and reads in the instrument’s metadata. It creates a structure that contains the metadata.

Example:

>>> rsk = RSK("example.rsk", readHiddenChannels=True)
... rsk.open()

This method is automatically invoked when using the RSK class context manager:

>>> with RSK("example.rsk") as rsk:
...    # rsk is open here

readdata

RSK.readdata(t1: Optional[np.datetime64] = None, t2: Optional[np.datetime64] = None) None

Read data of an opened RSK file.

Parameters
  • t1 (np.datetime64, optional) – start time for the range of data to be read. Defaults to None.

  • t2 (np.datetime64, optional) – end time for the range of data to be read. Defaults to None.

Retrieves data values from the .rsk file and adds a single, populated data field. If data already contains values and timestamps, the newly queried values replace the data field.

If you would like to read in only a subsection of the database, the t1 and t2 arguments can be used to enter start and end times in the form of np.datetime64.

Example:

>>> rsk.readdata()
... # Optional arguments
... tstart = np.datetime64("2022-05-03")
... tend = np.datetime64("2022-05-04")
... rsk.readdata(tstart, tend)

computeprofiles

RSK.computeprofiles(pressureThreshold: float = 3.0, conductivityThreshold: float = 0.05) None

Find profiles in a time series using pressure and conductivity data (if it exists).

Parameters
  • pressureThreshold (float, optional) – pressure threshold. Defaults to 3.0.

  • conductivityThreshold (float, optional) – conductivity threshold. Defaults to 0.05.

Detects profiles using the pressure channel in the RSK and produces a profiles field containing profile metadata.

The algorithm runs through the pressure data of the RSK and finds instances of a pressure reversal that is greater than pressureThreshold or 5% of the pressure differential of the last profile (whichever is greater). If it detects a pressure reversal it goes back to find the minimum or maximum pressure since the last event and records it as the beginning of the upcast or downcast, depending on the direction of the reversal.

When a conductivity channel is available, the algorithm records the samples where the conductivity is less than conductivityThreshold as out of the water and excludes them from the cast.

The default pressureThreshold of 3dbar may be too large for short profiles. Consider using one-quarter of the pressure range as a guideline, (max(Pressure)-min(Pressure))*1/4.

Example:

>>> rsk.computeprofiles()
... # Optional arguments
... rsk.computeprofiles(pressureThreshold=5.0, conductivityThreshold=0.06)

This next example illustrates how to use this method in combination with RSK.computeprofiles() to parse a time series of data into individual upcasts and downcasts.

TODO: show the output of each print(rsk) below and add extra lines to show profiles/casts being added to data

>>> with RSK("example.rsk") as rsk:
...     rsk.readdata()
...     print(rsk)
...     rsk.computeprofiles()
...     print(rsk)

getprofilesindices

RSK.getprofilesindices(profiles: Union[int, Collection[int]] = [], direction: str = 'both') List[List[int]]

TODO: _summary_

Parameters
  • profiles (Union[int, Collection[int]], optional) – _description_. Defaults to [].

  • direction (str, optional) – _description_. Defaults to “both”.

Returns

List[List[int]] – _description_

readprocesseddata

RSK.readprocesseddata(t1: Optional[np.datetime64] = None, t2: Optional[np.datetime64] = None) None

Read the burst data tables from events.

Parameters
  • t1 (np.datetime64, optional) – start time for range of burst data to be read. Defaults to None.

  • t2 (np.datetime64, optional) – end time for range of burst data to be read. Defaults to None.

This function reads all or a subset (determined by t1 and t2) of the burst data and writes it to the “processedData” variable of this class.

When a dataset has processedData, the raw high frequency values reside in the processedData field. The data field is composed of one sample for each burst with time stamp set to be the first value of each burst period; the sample is the average of the values during the corresponding burst.

Example:

>>> rsk.readprocesseddata()
... # Optional arguments
... tstart = np.datetime64("2022-05-03")
... tend = np.datetime64("2022-05-04")
... rsk.readprocesseddata(tstart, tend)

readcalibrations

RSK.readcalibrations() None

Read the calibrations table of a .rsk file.

Each sensor has a calculated set of calibration coefficients stored in the logger. This method adds a calibrations field to the current RSK instance, which contains the most current calibration coefficients.

Within the calibrations field there are many other fields:

  • calibrationID : Identifies the calibration.

  • channelOrder: Indicates which channel (sensor) is associated with which coefficients.

  • type: Describes how the coefficients were calculated. The most common is ‘factory’. That means RBR calculated the coefficients.

  • tstamp: The time of the calibration calculation in datenum.

  • equation: The calibration equation used to calculate the coefficients.

  • c0…c23, x0…x10, n0…n3: The coefficients values.

Example:

>>> rsk.readcalibrations()

csv2rsk

classmethod RSK.csv2rsk(fname: str, model: str = 'unknown', serialID: int = 0, firmwareVersion: str = 'NA', firmwareType: int = 103, partNumber: str = 'unknown') RSK

Convert a CSV file into an RSK class instance.

Parameters
  • fname (str) – name of the CSV file

  • model (str, optional) – instrument model from which data was collected. Defaults to “unknown”.

  • serialID (int, optional) – serial ID of the instrument. Defaults to 0.

  • firmwareVersion (str, optional) – firmware version of the instrument, e.g., 1.135. Defaults to “NA”.

  • firmwareType (int, optional) – firmware type of the instrument, e.g., 103. Defaults to 103.

  • partNumber (str, optional) – instrument part number. Defaults to “unknown”.

Returns

RSK – instantiated RSK class instance populated with the given CSV data.

The function reads in a CSV file and creates an RSK class instance. The header of the CSV file must follow exactly the format below to make the function work:

“timestamp (ms)”,”conductivity (mS/cm)”,”temperature (°C)”,”pressure (dbar)”
1564099200000,49.5392,21.8148,95.387
1564099200167,49.5725,21.8453,95.311
1564099200333,49.5948,21.8752,95.237

where the first column represents time stamp, which is milliseconds elapsed since Jan 1 1970 (i.e. UNIX time or POSIX time). The header for each column is comprised with channel name followed by space and unit (with parentheses) with double quotes.

Example:

>>> rsk = RSK.csv2rsk("example.csv")
... # Optional arguments
... rsk = RSK.csv2rsk("example.csv", model="RBRconcerto", serialID=200004)

close

RSK.close() None

Closes the connection made to the RSK (SQLite format) database.

Example:

>>> rsk.close()

NOTE: This method is automatically invoked when using the context manager approach.