Plotting

plotting

Warning

Experimental. Used by some scripts

Warning

Matplotlib backend rules

  • For library / plotting modules

    • These modules assume the backend has already been configured.

    • So they import matplotlib.pyplot normally.

  • For scripts (CLI / entrypoints)

    • Configure matplotlib backend before any plotting. You can use sgs_tools.scripts.plotting.configure_matplotlib_backend() to configure at runtime or import time.

    • To allow using CLI programmatically, do not import matplotlib.pyplot at module level, and run configure_matplotlib_backend as first thing in main.

class field_plot_kwargs(label, tcoord, zcoord, hcoords, vrange, cmap)[source]

a collection of field-specific plotting decorations

arrays_equal(a, b)[source]

Robustly compare two arrays for equality, supporting numeric and non-numeric types. Uses allclose for numeric, array_equal otherwise.

plot_vertical_prof_time_slice_compare_sims_slice(da_collection, plot_kwargs, x_lbl, tcoord, zcoord, with_markers=False)[source]

Plot a row of plots with a different time in each panel. Compare simulations from da_collection in each panel.

Parameters:
  • da_collection (Mapping[str, DataArray]) – a dictionary of 2d xr.DataArrays to be plotted. Will use the keys to pick plotting style from plot_kwargs.

  • plot_kwargs (Mapping[str, Any]) – a dictionary of plotting style parameters for each simulation.

  • x_lbl (str) – a display label for the plotted field, on the x-axis

  • tcoord (str) – name of time coordinate – will generate one panel per time index

  • zcoord (str) – name of y-coordinate, leave as None for default

  • with_markers – general flag to add markers to the plotted lines.

Return type:

Figure

plot_horizontal_slice_tseries(da_collection, tcoord, cmap, field_lbl, zcoord)[source]

Plot a grid of horizontal slices in each panel each row corresponds to a different simulation each column corresponds to a different time.

Parameters:
  • da_collection (Mapping[str, DataArray]) – a dictionary of 3d xr.DataArrays to be plotted. One of the dimensions must be tcoord

  • tcoord (str) – name of time coordinate – will generate one column per time index

  • cmap (str) – colormap to use for plotting

  • field_lbl (str) – a display label for the plotted field

Return type:

Figure

plot_vertical_prof_time_slice_compare_fields(ds, fields, reduction, zcoord, tslice=None, field_lbls=['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''], les_reference=None, zmax=1000000.0, ds_label='')[source]

Plot a row of plots with a time slice in each panel. Compare fields in each panel.

tslice : selection of times in minutes. if None will default to hourly schedule from 1 to 16 hours. reduction: ‘mean’ or ‘median’

Return type:

Figure

..automodule:: sgs_tools.plotting.handle_figure
members:

Plot style template file
[{
  "label": "string",
  "linestyle": "string",
  "color": "string",
  "linewdith": "float",
  "marker": "string"
  }
]