Plotting

This module contains functions related to generating figures and gifs with SWAMPE.

SWAMPE.plotting.fmt(x, pos)

Generates the format for scientific notation in axis and colorbar labels.

SWAMPE.plotting.gif_helper(fig, dpi=200)

Converts the figure to image format for gif generation.

Parameters:
  • fig (matplotlib figure) – figure

  • dpi (int, optional) – resolution, defaults to 200

Returns:

image

Return type:

numerical image

SWAMPE.plotting.mean_zonal_wind_plot(plotdata, mus, timestamp, units='hours', customtitle=None, customxlabel=None, savemyfig=False, filename=None, custompath=None, color=None)

Generates a plot of mean zonal winds (averaged across all longitudes).

Parameters:
  • plotdata (array of float) – Wind data, ususally U, of size (J,I).

  • mus (array of float) – Array of Gaussian latitudes of length J.

  • timestamp (float) – time of snapshot

  • units (str, optional) – units of timestamp, defaults to ‘hours’

  • customtitle (string, optional) – option to change the title, defaults to None

  • customxlabel (str, optional) – option to change the label of the x-axis, defaults to None

  • savemyfig (bool, optional) – option to save the figure, defaults to False

  • filename (str, optional) – file name for saving the figure, defaults to None

  • custompath (str, optional) – path for saving the figure, defaults to None

  • color (str, optional) – option to change the color of the plot, defaults to None

Returns:

figure

Return type:

matplotlib figure

SWAMPE.plotting.quiver_geopot_plot(U, V, Phi, lambdas, mus, timestamp, sparseness=4, minlevel=None, maxlevel=None, units='hours', customtitle=None, savemyfig=False, filename=None, custompath=None, axlabels=False, colormap=None)

Generates a quiver plot with the geopotential field and overlayed wind vectors.

Parameters:
  • U (array of float) – lat-lon zonal wind component, (J,I)

  • V (array of float) – lat-lon meridional wind component, (J,I)

  • Phi (array of float) – lat-lon geopotential field, (J,I)

  • lambdas (array of float) – Uniformly spaced longitudes of length I.

  • mus (array of float) – Gaussian latitudes of length J.

  • timestamp (float) – time of snapshot

  • sparseness (int, optional) – spacing of overlayed wind vector field, defaults to 4

  • minlevel (float, optional) – colorbar minimum for geopotential plotting, defaults to minimum of Phi

  • maxlevel (float, optional) – colorbar maximum for geopotential plotting, defaults to maximum of Phi

  • units (str, optional) – units of timestamp, defaults to ‘hours’

  • customtitle (string, optional) – option to change the title, defaults to None

  • savemyfig (bool, optional) – option to save the figure, defaults to False

  • filename (str, optional) – file name for saving the figure, defaults to None

  • custompath (str, optional) – path for saving the figure, defaults to None

  • axlabels (bool, optional) – option to display axis labels for latitude and longitude, defaults to False

  • colormap (matplotlib colormap, optional) – option to change the colormap, defaults to nipy.spectral

Returns:

figure

Return type:

matplotlib figure

SWAMPE.plotting.spinup_plot(plotdata, dt, units='hours', customtitle=None, customxlabel=None, customylabel=None, savemyfig=False, filename=None, custompath=None, color=None, legendflag=True, customlegend=None)

Generates a plot of RMS winds and minimal winds over time. Can be useful for monitoring spinup.

Parameters:
  • plotdata (array of float) – Spinup winds, of size (2,tmax).

  • dt (float) – timestep length, in seconds

  • units (str, optional) – units of timestamp, defaults to ‘hours’

  • customtitle (string, optional) – option to change the title, defaults to None

  • customxlabel (str, optional) – option to change the label of the x-axis, defaults to None

  • customylabel (str, optional) – option to change the label of the y-axis, defaults to None

  • savemyfig (bool, optional) – option to save the figure, defaults to False

  • filename (str, optional) – file name for saving the figure, defaults to None

  • custompath (str, optional) – path for saving the figure, defaults to None

  • color (array of string, optional) – option to specify array of two colors [“color1”, “color2”], defaults to None

  • legendflag (bool, optional) – option to display legend, defaults to True

  • customlegend (array of string, optional) – option to customize the legend, defaults to None

Returns:

figure

Return type:

matplotlib figure

SWAMPE.plotting.write_quiver_gif(lambdas, mus, Phidata, Udata, Vdata, timestamps, filename, frms=5, sparseness=4, dpi=200, minlevel=None, maxlevel=None, units='hours', customtitle=None, custompath=None, axlabels=False, colormap=None)

Writes a gif generated from a series of geopotential quiver plots.

Parameters:
  • lambdas (array of float) – Uniformly spaced longitudes of length I.

  • mus (array of float) – Gaussian latitudes of length J.

  • Phidata (array of float) – array of geopotential snapshots (num_snapshots,J,I)

  • Udata (array of float) – array of zonal wind component snapshots (num_snapshots,J,I)

  • Vdata (array of float) – array of meridional wind component snapshots (num_snapshots,J,I)

  • timestamps (array of float) – array of timestamps for the snapshots, length corresponding to (num_snapshots)

  • filename (str) – name of the gif file, should end in “.gif”

  • frms (int, optional) – frames per second, defaults to 5

  • sparseness (int, optional) – spacing of the wind vector field, defaults to 4

  • dpi (int, optional) – resolution, defaults to 200

  • minlevel (float, optional) – colorbar minimum for geopotential plotting, defaults to minimum of Phi

  • maxlevel (float, optional) – colorbar maximum for geopotential plotting, defaults to maximum of Phi

  • units (str, optional) – units of timestamp, defaults to ‘hours’

  • customtitle (string, optional) – option to change the title, defaults to None

  • custompath (str, optional) – path for saving the figure, defaults to None

  • axlabels (bool, optional) – option to display axis labels for latitude and longitude, defaults to False

  • colormap (matplotlib colormap, optional) – option to change the colormap, defaults to nipy.spectral