xoa.plot.plot_ts#
- xoa.plot.plot_ts(temp, sal, dens=True, ref_dens=0, pres=None, potential=None, absolute=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 salinity (practical or absolute) 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, it will be converted into potential if potential=None or potential=False. Note that if temp is not potential and contains a z or depth coordinate, it is converted to z with
xoa.coords.get_z()to compute pres with gsw.p_from_z if necessarysal (xarray.DataArray) – Salinity (practical or absolute). If not absolute, it will be converted into absolute salinity if the potential temperature needs to be computed.
dens (bool) – Add contours of density. The density is by default computed with function
gsw.density.sigma0()(ref_dens=0).ref_dens (integer, 0) – choice of reference for density calculation (between 0 and 4) ref_dens=0 will consider func:gsw.density.sigma0, etc..
pres (xarray.DataArray, None) – Pressure to compute potential temperature and absolute salinity.
potential (bool, None) – Is the temperature potential? If None, infer from attributes.
absolute (bool, None) – Is the salinity absolute? 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
add_colorbar(). The colorbar is shrunk and labelled from the scatter color array by default.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
# Load the Mercator data In [1]: file_name = xoa.get_data_sample("MODELS/CMEMS-IBI/ibi-argo-7900573.nc") In [2]: ds = xr.open_dataset(file_name) In [3]: temp = ds.thetao In [4]: sal = ds.so In [5]: depth = ds.depth.broadcast_like(temp) # Plot In [6]: plot_ts(temp, sal, potential=True, scatter_c=depth, contour_linewidths=0.2, clabel_fontsize=8, cmap="cmo.deep_r") Out[6]: {'axes': <Axes: xlabel='Salinity', ylabel='Temperature [°C]'>, 'scatter': <matplotlib.collections.PathCollection at 0x738beb206210>, 'colorbar': <matplotlib.colorbar.Colorbar at 0x738beb1e9550>, 'contour': <matplotlib.contour.QuadContourSet at 0x738beb254910>, 'clabel': <a list of 6 text.Text objects>}