Other methods

copy

RSK.copy() RSK

Create a full deep copy of the current RSK instance. The new copy will contain all the data of, and be fully independent from, the original.

Returns:

RSK – a deep copy of the current RSK instance.

create

classmethod RSK.create(timestamps: Collection[np.datetime64], values: Collection[Collection[float]], channels: Collection[str], units: Collection[str], filename: str = 'sample.rsk', model: str = 'unknown', serialID: int = 0) RSK

Create an RSK instance from given time series data.

Parameters:
  • timestamps (Collection[np.datetime64]) – a 1D array/list of timestamps (np.datetime64 format) of size n

  • values (Collection[Collection[float]]) – a 2D array/list of data of size [n,m]

  • channels (Collection[str]) – a 1D array/list of channel names of size m

  • units (Collection[str]) – a 1D array/list of channel units of size m

  • filename (str, optional) – filename to give a general description of the data. Defaults to “sample.rsk”.

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

  • serialID (int, optional) – serial ID of the instrument from which data was collected. Defaults to 0.

Returns:

RSK – created RSK class instance with given time series data.

Creates an instance of this class containing data and channels specified by the user. For example, the data could originate from a CTD on a profiling float or a glider. The data could even come from CTDs from manufacturers. The purpose of this function is to allow users to easily apply pyRSKtools post-processing and visualisation functions to any dataset. It is particularly convenient when one needs to compare data measured with an RBR CTD to other sources (e.g., other CTDs or bottle samples).

Example:

>>> timestamps = [np.datetime64(1651550400000, "ms"),
...               np.datetime64(1651550402000, "ms"),
...               np.datetime64(1651550404000, "ms")]
... values = [[39.9973,   16.2695,   10.1034],
...           [39.9873,   16.2648,   10.1266],
...           [39.9887,   16.2553,   10.1247]]
... channels = ["conductivity","temperature","pressure"]
... units = ["mS/cm","°C","dbar"]
... rsk = RSK.create(timestamps=timestamps, values=values, channels=channels, units=units)

addchannel

RSK.addchannel(data: Collection[float], channel: str = 'unknown', units: str = 'unknown', isMeasured: int = 0, isDerived: int = 0, schedule: str = 'default', shortName: str | None = None) None

Add a new channel with a defined channel name and unit. If the new channel already exists in the current RSK instance, it will overwrite the old one.

The channel is added to the specified schedule and padded with NaN in all other schedules to maintain structural consistency across dataArrays.

For multi-schedule RSK files, the schedule must be specified explicitly.

Parameters:
  • data (Collection[float]) – Array containing the data to be added.

  • channel (str, optional) – name of the added channel. Defaults to “unknown”.

  • units (str, optional) – unit of the added channel. Defaults to “unknown”.

  • isMeasured (int, optional) – whether the added channel is directly measured. Defaults to 0.

  • isDerived (int, optional) – whether the added channel is derived from other channels. Defaults to 0.

  • schedule (str, optional) – which schedule to add data to. For multi-schedule files, an explicit schedule label must be provided (e.g., "s.CTD"). Defaults to “default”, which auto-resolves to the single available schedule.

  • shortName (str, optional) – channel-type short name for the new channel. Defaults to None; a known channel keeps its registered type, and an unknown one gets a generic count type ("cnt_00") unless a short name is given (e.g. to inherit a source channel’s type).

Example:

>>> data = gsw.SA_from_SP(rsk.data["salinity"], rsk.data["sea_pressure"], -150, 49)
... rsk.addchannel(data, "absolute_salinity", units="g/kg", isMeasured=0, isDerived=1)
... # For multi-schedule files, specify the schedule:
... rsk.addchannel(data, "absolute_salinity", units="g/kg", schedule="s.CTD")

removecasts

RSK.removecasts(direction: str = 'up') None

Remove the data elements with either an increasing or decreasing pressure.

Removes casts across all schedules using the stored profile direction metadata. Profile elements are kept aligned across schedules.

Parameters:

direction (str, optional) – cast direction of either “up” or “down”. Defaults to “up”.

NOTE: When there are only downcasts in the current RSK instance, the request to remove downcasts will not take effect. The same for upcasts.

Example:

>>> rsk.removecasts(direction="up")

appendlog

RSK.appendlog(logentry: str) None

Append the entry and current time to the log field.

Parameters:

logentry (str) – comment that will be added to the log.

Appends the entry and current time to the log field. It is frequently called by other RSK methods for record use so that the users will not lose track of what happened to the file or the data. This method can also be called by the user to record any customised behaviour.

Example:

>>> rsk.appendlog(logentry="New channel practical salinity is added.")

printchannels

RSK.printchannels() None

Display instrument information, channel names, and units in the current RSK instance.

Example:

>>> rsk.printchannels()

Example output:

Model: RBRconcerto³
Serial ID: 60662
Sampling period: 0.125 second
    index               name                  unit
    _____    ____________________________    _______

    0        'conductivity'                  'mS/cm'
    1        'temperature'                   '°C'
    2        'pressure'                      'dbar'
    3        'temperature1'                  '°C'
    4        'temperature2'                  '°C'
    5        'sea_pressure'                  'dbar'
    6        'salinity'                      'PSU'

getregionsbytypes

RSK.getregionsbytypes(types: Type[Region] | Collection[Type[Region]]) List[Region]

Retrieve all the regions from RSK.regions that match the list of Region types passed in as an argument.

NOTE: a Region type is any class that inherits from Region.

Parameters:

types (Union[Type[Region], Collection[Type[Region]]]) – a single or list of Region type(s)

Returns:

List[Region] – the filtered list of Region instances obtained from RSK.regions.