View methods

plotdata

RSK.plotdata(channels: str | Collection[str] = [], profile: int | None = None, direction: str = 'down', showcast: bool = False) Tuple[plt.Figure, List[plt.Axes]]

Plot a time series of logger data.

Parameters:
  • channels (Union[str, Collection[str]], optional) – longName of channel(s) to plot, can be multiple in a cell. Defaults to [] (plot all available channels).

  • profile (int, optional) – profile number. Defaults to None (ignores profiles and plot as time series).

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

  • showcast (bool, optional) – show cast direction when set as true. It is recommended to show the cast direction patch for time series data only. This argument will not work when pressure and sea pressure channels are not available. Defaults to False.

Returns:

Tuple[plt.Figure, List[plt.Axes]] – a two-element tuple containing the related figure and list of axes respectively.

This method plots the channels specified by channels as a time series. If a channel is not specified, then this method will plot them all. If the current RSK instance has profiles (e.g., via RSK.computeprofiles()), then users may specify a single profile and direction to plot. In this case, however, this method can only plot one cast and direction at a time. If you want to compare many profiles, then use either RSK.plotprofiles() or RSK.mergeplots().

The output tuple containing handles and axes are lists of chart line objects and axes which contain the properties of each subplot.

The command below creates the plot below it:

>>> with RSK("example.rsk") as rsk:
... rsk.readdata()
... fig, axes = rsk.plotdata(channels=["conductivity", "temperature", "dissolved_o2_saturation", "chlorophyll"])
... plt.show()
first plot data plot

The figure above is the output of RSK.plotdata(), where each subplot created relates to the labels given to RSK.data columns and the RSK.channels attribute.

This method has an option to overlay cast detection events on top of the pressure time series. This is particularly useful to ensure that the profile detection events correctly demarcate the profiles.

The command below plots a time series of pressure with cast detection events overlaid:

>>> fig, axes = rsk.plotdata(channels="pressure", showcast=True)
... plt.show()
second plot data plot

The figure above is the output of RSK.plotdata() when showcast option is on with the pressure channel.

plotprofiles

RSK.plotprofiles(channels: str | Collection[str] = [], profiles: int | Collection[int] = [], direction: str = 'both', reference: str = 'sea_pressure') Tuple[plt.Figure, List[plt.Axes]]

Plot summaries of logger data as profiles.

Parameters:
  • channels (Union[str, Collection[str]], optional) – longName of channel(s) to plot, can be multiple in a cell. Defaults to [] (all available channels).

  • profiles (Union[int, Collection[int]], optional) – profile sequence(s). Defaults to [] (all profiles).

  • direction (str, optional) – cast direction: “up”, “down”, or “both”. When choosing “both”, downcasts are plotted with solid lines and upcasts are plotted with dashed lines. Defaults to “both”.

  • reference (str, optional) – Channel plotted on the y axis for each subplot. Options are “sea_pressure”, “depth”, or “pressure”. Defaults to “sea_pressure”.

Returns:

Tuple[plt.Figure, List[plt.Axes]] – a two-element tuple containing the related figure and list of axes respectively.

Generates a subplot for each channels versus selected reference, using the data elements in the RSK.data field. If no channels are specified, it will plot them all as individual subplots.

When direction is set to ‘both’, downcasts are plotted with solid lines and upcasts are plotted with dashed lines.

The output handles is a vector of chart line objects containing the properties of each subplot.

The code below produced the plot below it:

>>> with RSK("example.rsk") as rsk:
...    rsk.readdata()
...    rsk.deriveseapressure()
...    rsk.derivesalinity()
...
...    fig, axes = rsk.plotprofiles(
...        channels=["conductivity", "temperature", "salinity"],
...        profiles=range(0, 3),
...        direction="down",
...    )
...    plt.show()
plot profiles plot

The figure above is the profiles plotted using RSK.plotprofiles(). Selecting conductivity, temperature, and salinity channels facilitates comparison.

images

RSK.images(channels: str | Collection[str] = [], profiles: int | Collection[int] = [], direction: str = 'down', reference: str = 'sea_pressure', showgap: bool = False, threshold: float | None = None, image: Image | None = None) Tuple[plt.Figure, List[plt.Axes]]

Plot profiles in a 2D plot.

Parameters:
  • channels (Union[str, Collection[str]], optional) – longName of channel(s) to plot, can be multiple in a cell. Defaults to [] (all available channels).

  • profiles (Union[int, Collection[int]], optional) – profile sequence(s). Defaults to [] (all profiles).

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

  • reference (str, optional) – Channel that will be plotted as y. Can be any channel. Defaults to “sea_pressure”.

  • showgap (bool, optional) – Plotting with interpolated profiles onto a regular time grid, so that gaps between each profile can be shown when set as true. Defaults to False.

  • threshold (float, optional) – Time threshold in seconds to determine the maximum gap length shown on the plot. Any gap smaller than the threshold will not show. Defaults to None.

  • image – (Image, optional): optional pre-computed/customized image generated by RSK.generate2D(). Defaults to None.

Returns:

Tuple[plt.Figure, List[plt.Axes]] – a two-element tuple containing the related figure and list of axes respectively.

This function produces a heat map of any specified channel. The x-axis is always time, and the y-axis is the reference channel argument, which is commonly depth or sea_pressure, but can be any channel (default is sea_pressure). Each profile must be gridded onto the same reference channel, which is accomplished with RSK.binaverage().

Example:

>>> fig, axes = rsk.images(channels="chlorophyll", direction="up")
... plt.show()
first images plot

The cmocean toolbox (link) provides colormaps like the one used in the plot above. This one is designed to plot cholorophyll.

Users can customize the length of the time gaps over which the data are interpolated with the threshold input parameter. This method calls RSK.generate2D() to generate data for visualization unless the user provides one via the image argument. An Image instance contains x, y and data fields for users’ convenience to render the plot as they like.

Below are two examples of how to use the showgap parameter.

To plot the data with the gaps intact:

>>> fig, axes= rsk.images(channels="temperature", direction="down", showgap=True)
... plt.show()
second images plot

To fill all of the gaps longer than 6 minutes with interpolated values:

>>> fig, axes = rsk.images(channels="temperature", direction="down", showgap=True, threshold=360.0)
... plt.show()
third images plot

plotTS

RSK.plotTS(profiles: int | Collection[int] | None = [], direction: str = 'both', isopycnal: int | Collection[int] = 5) Tuple[plt.Figure, plt.Axes]

Plot a TS diagram in terms of Practical Salinity and Potential Temperature.

Parameters:
  • profiles (Union[int, Collection[int]], optional) – profile number(s). Defaults to [] (all available profiles).

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

  • isopycnal (Union[int, Collection[int]], optional) – number of isopycnals to show on the plot, or a list containing desired isopycnals. Defaults to 5.

Returns:

Tuple[plt.Figure, plt.Axes] – a two-element tuple containing the related figure and axes of the plot.

Plots potential temperature as a function of Practical Salinity using 0 dbar as a reference. Potential density anomaly contours are drawn automatically. RSK.plotTS() requiresTEOS-10 GSW toolkit. If the data is stored as a time series, then each point will be coloured according to the time and date it was taken. If the data is organized into profiles, then each profile is plotted with a different colour.

NOTE: Absolute Salinity is computed internally because it is required for potential temperature and potential density. Here it is assumed that the Absolute Salinity (SA) anomaly is zero so that SA = SR (Reference Salinity). This is probably the best approach in many coastal regions where the Absolute Salinity anomaly is not well known (see http://www.teos-10.org/pubs/TEOS-10_Primer.pdf).

Example:

>>> fig, axes = rsk.plotTS(profiles=range(3), direction="down", isopycnal=10)
... plt.show()
plotTS plot

The figure above is T-S diagram plotted using RSK.plotTS(), where each downcast is plotted with a different colour. RSK.plotTS() outputs handles to the line objects so that users can customize the curves.

plotprocesseddata

RSK.plotprocesseddata(channels: str | Collection[str] = []) Tuple[plt.Figure, List[plt.Axes]]

Plot summaries of logger burst data.

Parameters:

channels (Union[str, Collection[str]], optional) – longName of channel(s) to plot, can be multiple in a cell, if no value is given it will plot all channels. Defaults to [] (all available channels).

Returns:

Tuple[plt.Figure, List[plt.Axes]] – a two-element tuple containing the related figure and list of axes respectively.

Plots the processedData initially read by RSK.readprocesseddata().

It creates a subplot for every channel available, unless the channel argument is used to select a subset.

The code below provides example usage and a resulting plot.

>>> with RSK("example.rsk") as rsk:
...     t1, t2 = np.datetime64("2020-10-03T11:30:00"), np.datetime64("2020-10-03T19:20:00")
...     rsk.readdata(t1=t1, t2=t2)
...     rsk.readprocesseddata(t1=t1, t2=t2)
...
...     fig, axes = rsk.mergeplots(
...         rsk.plotprocesseddata(channels="pressure"),
...         rsk.plotdata(channels="pressure"),
...     )
...     plt.show()
plot burst data plot

In the figure above, the blue line shows the values in the RSK.processedData field and the purple line shows those from the RSK.data field.

mergeplots

static RSK.mergeplots(plottuple1: Tuple[Figure, List[Axes]], plottuple2: Tuple[Figure, List[Axes]]) Tuple[Figure, List[Axes]]

Merge two plots via their associated figure and axes objects.

Parameters:
  • plottuple1 (Tuple[plt.Figure, List[plt.Axes]]) – tuple containing the figure and axes list of the first plot

  • plottuple2 (Tuple[plt.Figure, List[plt.Axes]]) – tuple containing the figure and axes list of the second plot

Returns:

Tuple[plt.Figure, List[plt.Axes]] – an updated figure and axes list relating to the merged plot

Expects two tuples, each of which contains a figure as its first tuple-element and a list of axes as its second element. The lines from the first plot will be maintained (including their marker style and colour), while the lines from the second will be merged onto the first plot with a solid marker style and random colour.

See plotprocesseddata() for example usage.