Utilities¶
rsktime2datetime¶
datetime2rsktime¶
formatchannelname¶
- utils.formatchannelname() str ¶
Take a given channel name and return a formatted version adhering to the standard used by pyRSKtools.
- Parameters:
unformattedChannelName¶ (str) – the unformatted channel.
- Returns:
str – the input channel formatted.
Example:
>>> formatchannelname("Conductivity") # = "conductivity" ... formatchannelname("Dissolved O₂ saturation") # = "dissolved_o2_saturation" ... formatchannelname("1/10 wave height") # = "one_tenth_wave_height"
createuniquechannelname¶
- utils.createuniquechannelname(existingChannelNames: Collection[str]) str ¶
Format the given channel name using
formatchannelname()
and, if needed, alter it further to make sure it is unique against the list of existing channel names.This method is most useful when you already have an established list of channel names (e.g.,
RSK.channelNames
) and want to append an additional channel.- Parameters:
- Returns:
str – the original channel name but properly formatted/unique.
The example below outputs
"conductivity1"
if the channel exists inrsk.channelNames
, or"conductivity"
if the channel does not exist in the list.Example:
>>> createuniquechannelname("Conductivity", rsk.channelNames)
intoarray¶
- utils.intoarray(dtype: str = 'float64') ndarray[Any, dtype[_ScalarType_co]] ¶
Tries to transform any given value into a 1-D NumPY array with the specified data type.
- Parameters:
- Raises:
ValueError – if the given value could not be transformed into a NumPY array.
- Returns:
npt.NDArray – the 1-D NumPY array containing the passed-in values.
Example:
>>> intoarray(1) ... intoarray([1, 2, 3]) ... intoarray(range(3))