xoa.plot.plot_ts

xoa.plot.plot_ts(temp, sal, dens=True, pres=None, potential=None, axes=None, scatter_kwargs=None, contour_kwargs=None, clabel=True, clabel_kwargs=None, colorbar=None, colorbar_kwargs=None, **kwargs)[source]

Plot a TS diagram

A TS diagram is a scatter plot with absolute salinity as X axis and potential temperature as Y axis. The density is generally added as background contours.

Parameters:
  • temp (xarray.DataArray) – Temperature. If not potential temperature, please set potential=True.

  • sal (xarray.DataArray) – Salinity

  • dens (bool) – Add contours of density. The density is computed with function gsw.density.sigma0().

  • pres (xarray.DataArray, None) – Pressure to compute potential temperature.

  • potential (bool, None) – Is the temperature potential? If None, infer from attributes.

  • clabel (bool) – Add labels to density contours

  • clabel_kwargs (dict, None) – Parameters that are passed to clabel().

  • colorbar (bool, None) – Should we add the colorbar? If None, check if scatter plot color is a data array.

  • colorbar_kwargs (dict, None) – Parameters that are passed to colorbar().

  • contour_kwargs (dict, None) – Parameters that are passed to contour().

  • axes (None) – Matplotlib axes instance

  • kwargs (dict) – Extra parameters are filtered by xoa.misc.dict_filter() and passed to the plot functions.

See also

gsw.density, gsw.conversions

Returns:

dict – With the following keys, depending on what is plotted: axes, scatter, colorbar, contour, clabel.

Example

# Register the main xoa accessor
In [1]: xoa.register_accessors()

# Load the CROCO meridional section
In [2]: ds = xoa.open_data_sample("croco.south-africa.meridional.nc")

In [3]: ds = ds.isel(eta_rho=slice(40))

In [4]: temp = ds.xoa.get('temp')     # requests are based...

In [5]: sal = ds.xoa.get('sal')       # ...on the generic name

In [6]: depth = ds.xoa.get_depth(ds)  # or xoa.coords.get_depth(ds)

# Plot
In [7]: plot_ts(temp, sal, potential=True, scatter_c=depth, contour_linewidths=0.2, clabel_fontsize=8)
Out[7]: 
{'axes': <Axes: xlabel='Salinity', ylabel='Potential Temperature [Celsius]'>,
 'scatter': <matplotlib.collections.PathCollection at 0x7f37bd863190>,
 'colorbar': <matplotlib.colorbar.Colorbar at 0x7f37bd840550>,
 'contour': <matplotlib.contour.QuadContourSet at 0x7f37be209e50>,
 'clabel': <a list of 6 text.Text objects>}
../_images/api.plot.plot_ts.png