View methods¶
plotdata¶
- RSK.plotdata(channels: Union[str, Collection[str]] = [], profile: Optional[int] = 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, if no value is given it will plot all channels. Defaults to [] (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 channel 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 either useRSK.plotprofiles()
or rerun this method.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:
>>> import matplotlib.pyplot as plt ... ... fig, axes = rsk.plotdata(channels=["conductivity", "temperature", "dissolved_o2_saturation", "chlorophyll"]) ... plt.show()
This method has an option to overlay cast detection events on top 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()
plotprofiles¶
- RSK.plotprofiles(channels: Union[str, Collection[str]] = [], profiles: Union[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, if no value is given it will plot all channels. 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”, “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 channel versus selected reference, using the data elements in the data field. If no channel is 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, 8), ... direction="down", ... ) ... plt.show()
images¶
- RSK.images(channels: Union[str, Collection[str]] = [], profiles: Union[int, Collection[int]] = [], direction: str = 'down', reference: str = 'sea_pressure', showgap: bool = False, threshold: Optional[float] = None, image: Optional[Image] = 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, if no value is given it will plot all channels. 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.
Produces a heat map of any specified channel. The x-axis is always time, 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()
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. AnImage
instance contains x, y and data fields for the 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()
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()
plotTS¶
- RSK.plotTS(profiles: Optional[Union[int, Collection[int]]] = [], direction: str = 'both', isopycnal: Union[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. 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 is plotted with a different colours.
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()
plotprocesseddata¶
- RSK.plotprocesseddata(channels: Union[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()
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
- 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 color), while the lines from the second will be merged onto the first plot with a solid marker style and random color.
See
plotprocesseddata()
for example usage.