- 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 populates the current instance with the metadata.
>>> 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
- RSK.readdata(t1: Optional[np.datetime64] = None, t2: Optional[np.datetime64] = None) None ¶
Read data of an opened RSK file.
If you would like to read in only a subsection of the database, the
t2arguments can be used to enter start and end times in the form of a NumPY datetime64 object.
>>> rsk.readdata() ... # Optional arguments ... tstart = np.datetime64("2022-05-03") ... tend = np.datetime64("2022-05-04") ... rsk.readdata(tstart, tend)
- RSK.computeprofiles(pressureThreshold: float = 3.0, conductivityThreshold: float = 0.05) None ¶
Compute profiles in a time series using pressure and conductivity data (if it exists).
Detects profiles using the pressure channel in the RSK and populates
RSK.regionswith the produced metadata.
The algorithm runs through the pressure data of the RSK and finds instances of a pressure reversal that is greater than
pressureThresholdor 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
conductivityThresholdas out of the water and excludes them from the cast.
pressureThresholdof 3 dbar may be too large for short profiles. Consider using one-quarter of the pressure range as a guideline, (max(Pressure) - min(Pressure)) * 1/4.
>>> 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.getprofilesindices()to parse a time series of data into individual upcasts and downcasts.
>>> with RSK("example.rsk") as rsk: ... rsk.readdata() ... print(rsk) ... # RSK ... # ... ... # .regions is unpopulated ... # ... ... rsk.computeprofiles() ... print(rsk) ... # RSK ... # ... ... # .regions is populated with 45 elements ... # ... ... upcastIndices = rsk.getprofilesindices(direction="up") ... downcastIndices = rsk.getprofilesindices(direction="down")
- RSK.getprofilesindices(profiles: Union[int, Collection[int]] = , direction: str = 'both') List[List[int]] ¶
Get a list of indices for each profile or cast direction used to index into
List[List[int]] – a list of profile/cast indices; each element in the returned list is a list itself which may be used to index into
>>> profileIndices = rsk.getprofilesindices() ... upcastIndices = rsk.getprofilesindices(direction="up") ... firstDowncastIndices = rsk.getprofilesindices(profiles=1, direction="down")
- RSK.readprocesseddata(t1: Optional[np.datetime64] = None, t2: Optional[np.datetime64] = None) None ¶
Read the burst data of an opened RSK file.
This function reads all or a subset (determined by t1 and t2) of the burst data and writes it to the
RSK.processedDatavariable of this instance.
When a dataset has burst data, the raw high-frequency values reside in the
RSK.processedDatafield. This field is composed of one sample for each burst with a timestamp set to be the first value of each burst period; the sample is the average of the values during the corresponding burst.
>>> rsk.readprocesseddata() ... # Optional arguments ... tstart = np.datetime64("2022-05-03") ... tend = np.datetime64("2022-05-04") ... rsk.readprocesseddata(tstart, tend)
- 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
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”.
RSKclass instance populated with the given CSV data.
The function reads in a CSV file and creates an
RSKclass 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.3871564099200167,49.5725,21.8453,95.3111564099200333,49.5948,21.8752,95.237
where the first column represents the timestamp, 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.
>>> rsk = RSK.csv2rsk("example.csv") ... # Optional arguments ... rsk = RSK.csv2rsk("example.csv", model="RBRconcerto", serialID=200004)
- RSK.close() None ¶
Closes the connection made to the RSK (SQLite format) database.
NOTE: This method is automatically invoked when using the context manager approach.