Plotting functions

In addition to accessing plotting capabilities through the tsp.core.TSP class and subclasses, the plotting functions can be accessed directly. These functions are datasource-agnostic, so they can be used independently of any other functions or classes in this package.

Trumpet Curves

tsp.plots.static.trumpet_curve(depth, t_max, t_min, t_mean, title: str = '', max_depth: float | None = None, t_units: str = C', d_units: str = 'm', data_completeness=None, min_completeness: float | None = None) Figure

Plot a trumpet curve

The function returns a matplotlib Figure object. To show the figure, you must call the show() method.

Parameters:
  • depth (numpy.ndarray) – A d-length array of depths at which temperature values are

  • t_max (numpy.ndarray) – A d-length array of temperature values representing the maximum temperatures over the period at each of the depths.

  • t_min (numpy.ndarray) – A d-length array of temperature values representing the minimum temperatures over the period at each of the depths.

  • t_mean (str) – A d-length array of temperature values representing the mean temperatures over the period at each of the depths.

  • title (str, optional) – A title for the figure, by default “”

  • max_depth (float, optional) – If provided, limits the maximum y-axis extent of the plot, by default None

  • t_units (unicode, optional) – Units for the x-axis (assumed to be temperature), by default u’° C’

  • d_units (str, optional) – Units for the y axis (depth), by default “m”

  • data_completeness (numpy.ndarray) – A d-length array of representing data completeness as a fraction (e.g. 0 to 1) for each of the averaging periods ()

  • min_completeness (float) – Minimum data completeness to be included in the temperature envelope

Returns:

A matplotlib Figure. Note that to show the figure you must call the show() method or matplotlib.pyplot.show().

Return type:

Figure

Raises:

ValueError – _description_

Time Series

tsp.plots.static.time_series(depths, times, values, title='', d_units='m', t_units= C', legend=True) Figure

Create a time-series plot

Using time as the X axis and data values as the y axis. Depths are plotted as their own lines.

Parameters:
  • depths (numpy.ndarray) – 1-d list or array of datetimes with length d.

  • times (numpy.ndarray) – 1-d list or array of datetimes with length t.

  • values (array) – An array of data values with shape (t,d).

  • title (str, optional) – A title for the plot, by default ‘’

  • d_units (str, optional) – Units of the depths variable, by default ‘m’

  • t_units (str, optional) – Units of the temperature variable, by default u’° C’

Returns:

A matplotlib Figure. Note that to show the figure you must call the show() method or matplotlib.pyplot.show().

Return type:

Figure

Colour-Contour Plots

tsp.plots.static.colour_contour(depths, times, values, title='', colours: str | list = 'symmetric', contour: list = [], label_contour=False, max_depth=None, gap_fill=False, d_units='m', **kwargs) Figure

Create a colour-contour plot.

The x-axis is time and the y-axis is depth. Data values are interpolated and coloured.

Parameters:
  • depths (numpy.ndarray) – A d-length array of depths at which measurements are collected.

  • times (numpy.ndarray) – A t-length array of python datetimes at which measurements are collected

  • values (numpy.ndarray) – An array with shape (t,d) of values at each depth-time coordinate

  • title (str, optional) – A title for the figure, by default “”

  • colours (Union[str, list], optional) – Either a list of colours to be used for the colour bar, or one of: * symmetric: ensure colour switch is centered at 0C * dynamic: Maximize dynamic range * basic: distinguish unfrozen, warm (>-2C) and ,by default ‘symmetric’

  • contour (list, optional) – A list of float values. If provided, draw contours at each of those values, by default []

  • label_contour (bool, optional) – Whether or not to label contour lines. Ignored if contour is empty, by default False

  • max_depth (float, optional) – If provided, limits the maximum y-axis extent of the plot, by default None

  • gap_fill (bool, optional) – _description_, by default False

  • d_units (str, optional) – Units for the y axis (depth), by default “m”

Returns:

A matplotlib Figure. Note that to show the figure you must call the show() method or matplotlib.pyplot.show().

Return type:

Figure