Export methods

RSK2CSV

RSK.RSK2CSV(channels: str | Collection[str] = [], profiles: int | Collection[int] | None = None, direction: str = 'both', outputDir: str = '.', comment: str | None = None, schedules: str | Collection[str] = 'all') None

Write one or more CSV files of logger data and metadata.

Parameters:
  • channels (Union[str, Collection[str]], optional) – longName of channel(s) for output files, if no value is given it will output all channels. Defaults to [] (all available channels).

  • profiles (Union[int, Collection[int]], optional) – profile number(s) for output files. If not specified, data will not be exported in profiles. Specify [] for all profiles. Defaults to None.

  • direction (str, optional) – cast direction of either “up”, “down”, or “both” for output files. Defaults to “both”.

  • outputDir (str, optional) – directory for output files. Defaults to “.” (current working directory).

  • comment (str, optional) – extra comments to attach to the end of the header. Defaults to None.

  • schedules (Union[str, Collection[str]], optional) – schedule label(s) to export. Can be “all”, a single label string, or a list of label strings. Defaults to “all”, which exports every available schedule.

Outputs channel data and metadata from the RSK into one or more CSV files. The CSV file header contains logger metadata. The data table starts with a row of variable names and units above each column of channel data. If the profiles number is specified as an argument, then one file will be written for each profile. Furthermore, an extra column called “cast_direction” will be included. The column will contain ‘d’ or ‘u’ to indicate whether the sample is part of the downcast or upcast, respectively.

Users can customise which channel, profile for outputs, output directory and comments are attached to the end of the header.

Example:

>>> with RSK("example.rsk") as rsk:
...     rsk.computeprofiles()
...     rsk.RSK2CSV(channels=["conductivity","pressure","dissolved_o2_concentration"], profiles = range(0,3), outputDir="/users/decide/where", comment="My data")

Example of a CSV file created by this method:

// Creator: RBR Ltd.
// Create time: 2022-05-20T19:54:26
// Instrument model firmware and serialID: RBRmaestro 12.03 80217
// Sample period: 0.167 second
// Processing history:
//     /rsk_files/080217_20220919_1417.rsk opened using RSKtools v1.0.0.
//     Sea pressure calculated using an atmospheric pressure of 10.1325 dbar.
// Comment: My data

// timestamp(yyyy-mm-ddTHH:MM:ss.FFF),  conductivity(mS/cm),   pressure(dbar),   dissolved_o2_concentration(%)
2015-09-19T08:32:16.000,                 34.6058,           12.6400,          694.7396
2015-09-19T08:32:16.167,                 34.6085,           12.4154,          682.4502
2015-09-19T08:32:16.333,                 34.6130,           12.4157,          666.1949

RSK2RSK

RSK.RSK2RSK(outputDir: str = '.', suffix: str | None = None) str

Write the current RSK instance into a new RSK file.

Parameters:
  • outputDir (str, optional) – directory for output RSK file. Defaults to “.” (current working directory).

  • suffix (str, optional) – string to append to output rsk file name. Defaults to None (current time in the format of YYYYMMDDTHHMM).

Returns:

str – file name of output RSK file.

Writes a new RSK file containing the data and various metadata from the current RSK instance. It is designed to store post-processed data in a SQLite file that is readable by Ruskin. The new rsk file is in “EPdesktop” format, which is the simplest Ruskin table schema. This method effectively provides a convenient method for Python users to easily share post-processed RBR logger data with others without recourse to CSV, MAT, or ODV files.

The tables created by this method include (among others):

  • dbInfo, instruments, deployments, epochs

  • channels, data, burstData

  • schedules (continuous, burst, wave, tide, average, directional)

  • calibrations, coefficients

  • region, regionCal, regionCast, regionComment, regionExclude, regionGeoData, regionPlateau, regionProfile, regionAtmosphere

  • instrumentChannels, instrumentSensors, ranging

  • parameters, parameterKeys, appSettings, power

Only supports the v2 schema and always writes the EPdesktop format. A 3.0.0+ RSK (which includes every multi-schedule file) raises SchemaError; use RSK.RSK2RSKFULL() to export those, preserving their original schema.

Example:

>>> with RSK("example.rsk") as rsk:
...     rsk.readdata()
...     rsk.computeprofiles()
...     outputfilename = rsk.RSK2RSK(outputDir="/users/decide/where", suffix="processed")

RSK2RSKFULL

RSK.RSK2RSKFULL(inputPath: str, outputDir: str = '.', suffix: str | None = None) str

Write the current changes in RSK instance into a new RSK file, preserving the original schema and all metadata.

Supports RSK schema version 3.0.0 and 3.2.0. The output file preserves the original schema version (including the data table structure: v3.0.0 uses rowid with id/datasetId/sampleIndex columns, v3.2.0 uses WITHOUT ROWID with a (scheduleId, timestamp) primary key).

Parameters:
  • inputPath (str, required) – path to the original RSK file the current instance was read from.

  • outputDir (str, optional) – directory for output RSK file. Defaults to “.” (current working directory).

  • suffix (str, optional) – string to append to output rsk file name. Defaults to None (current time in the format of YYYYMMDDTHHMM).

Returns:

str – file name of output RSK file.

It is designed to store post-processed data in a SQLite file that is readable by Ruskin. The difference between this and RSK2RSK is that this function will retain all the information contained in the original RSK file, while adding changes such as post-processing made during the current session. This function requires the original RSK file to exist when the function is called, and only supports RSK schema version 3.0.0 or higher. As multi-schedule datasets only exist in 3.0.0 and higher RSK files, to export those RSKs RSK2RSKFULL is required.

This function retains all tables in the original RSK file, but updates the following tables that RSKtools usually changes during post-processing:

  • channel (schema-aware: introspects actual columns, handles both v3.0.0 and v3.2.0)

  • instrumentChannel (updates labels, inserts rows for new derived channels)

  • data (all entries in dataArrays for multi-schedule RSK)

  • region

  • regionCal

  • regionCast

  • regionComment

  • regionExclude

  • regionGeoData

  • regionPlateau

  • regionProfile

  • regionAtmosphere

The dataDownsample* cache tables are dropped during export, while the rows in downsample_caches are deleted (the table itself is retained), as their column structure may no longer match after post-processing. Ruskin regenerates these on open.

Example:

>>> with RSK("example.rsk") as rsk:
...     rsk.readdata()
...     rsk.derivesalinity()
...     outputfilename = rsk.RSK2RSKFULL(inputPath="example.rsk", outputDir="./users/decide/where", suffix="processed")