Plotting functions — aeolus 0.4.9+9.g5a71939.dirty documentation

# Plotting functions

class aeolus.plot.CloudPlotter(cubelist)

  Bases: `object`

  Factory to create a composite plot of low, medium, high cloud area fractions.

  __init__(cubelist)

    Initialise CloudPlotter from iris.cube.CubeList containing cloud fractions.

  scale_data(threshold=0.1)

    Scale cloud levels and add them together to make a composite cloud field.

    Values below threshold are set to zero.

  get_all(nsteps=10, cmap=None)

    Get cloud types cube and kwargs for external plotting.

  pcolormesh(ax, xy=(), nsteps=10, cmap=None, cb_kwargs={}, **pc_kwargs)

    Display composite cloud plot using matplotlib.pyplot.pcolormesh.

    Parameters

      - ax (matplotlib axes object) – Axes where to create the plot in

      - xy (tuple, optional) – Sequence of X and Y coordinate arrays (passed to pcolormesh)

      - nsteps (integer, optional) – Number of colour steps for each of cloud category

      - cmap (matplotlib.colors.ListedColormap, optional) – Colormap instance. If not given, custom cloud colormap is used.

      - cb_kwags (dict, optional) – Dictionary of kwargs passed to colorbar

      - **pc_kwargs (optional) – additional pcolormesh arguments

    Returns

      - h (matplotlib.collections.QuadMesh) – pcolormesh instance

      - cb (matplotlib.colorbar.Colorbar) – colorbar

class aeolus.plot.GeoAxesGrid(fig, rect, nrows_ncols, projection, **axesgrid_kw)

  Bases: `mpl_toolkits.axes_grid1.axes_grid.ImageGrid`

  Grid of cartopy axes.

  A subclass of `mpl_toolkits.axes_grid1.AxesGrid` representing a grid of maps with the same projection `Projection`.

  - axes_class is defined automatically

  - The `AxesGrid` built-in labelling is always switched off, and instead a standard procedure of creating grid lines and labels should be used.

  __init__(fig, rect, nrows_ncols, projection, **axesgrid_kw)

    Initialise GeoAxesGrid.

    Build a `GeoAxesGrid` instance with a grid nrows*ncols `GeoAxes` with a projection `Projection` in `Figure` fig with rect=[left, bottom, width, height] (in `Figure` coordinates) or the subplot position code (e.g., “121”).

aeolus.plot.label_global_map_gridlines(fig, ax, xticks=[], yticks=[], xoff=- 10, yoff=- 10, degree=False, **text_kw)

  Label gridlines of a global cartopy map.

  Parameters

    - fig (matplotlib.figure.Figure) – Figure object.

    - ax (cartopy.mpl.geoaxes.GeoAxesSubplot) – Cartopy axes.

    - xticks (array-like, optional) – Sequence of longitude ticks.

    - yticks (array-like, optional) – Sequence of latitude ticks.

    - xoff (float, optional) – Longitude label offset from the axis (units are points). If negative (by default), the labels are drawn at the east boundary, otherwise at the west boundary.

    - yoff (float, optional) – Latitude label offset from the axis (units are points). If negative (by default), the labels are drawn at the south boundary, otherwise at the north boundary.

    - degree (bool, optional) – Add a degree symbol to tick labels.

    - **text_kw (dict, optional) – Label text properties.

aeolus.plot.add_custom_legend(ax, styles_and_labels, **leg_kw)

  Add a custom legend to matplotlib axes.

  Parameters

    - ax (matplotlib.axes._subplots.AxesSubplot) – Axes where to put the legend.

    - styles_and_labels (dict) – Dictionary with labels as keys and a dictionary of plot keywords as values.

    - leg_kw (dict, optional) – Keyword arguments passed to legend() function.

  Example

      >>> import matplotlib.pyplot as plt
      >>> ax = plt.axes()
      >>> my_dict = dict(foo=dict(color='C0', marker="X"),
                         bar=dict(color='C1', marker="o"))
      >>> add_custom_legend(ax, my_dict, loc=2, title="blah")

## PyVista interface

aeolus.plot.pv.grid_for_scalar_cube_sph(cube, z_scale=1, z_offset=0, grid=None, label='scalar3d', model=<class 'aeolus.model.base.Model'>(80 fields))

  Create a pyvista grid for an iris cube (2D or 3D) in spherical coordinates.

  Parameters

    - cube (iris.cube.Cube) – 2D or 3D cube with (longitude, latitude, [level_height]) coordinates.

    - z_scale (float, optional) – Scaling factor for the vertical level dimension.

    - z_offset (float, optional) – Scaling offset for the vertical level dimension.

    - grid (pyvista.StructuredGrid, optional) – If given, add data to the existing grid, otherwise create a new one from the input cube’s coordinates.

    - label (str, optional) – Label for the data within the grid.

    - model (aeolus.model.Model, optional) – Model class with relevant variable names.

  Returns

    PyVista grid with data in cell_arrays.

  Return type

    pyvista.StructuredGrid

aeolus.plot.pv.grid_for_vector_cubes_sph(u, v, w, vector_scale=1, vertical_wind_scale=1, z_scale=1, z_offset=0, xstride=1, ystride=1, grid=None, label='vector3d', model=<class 'aeolus.model.base.Model'>(80 fields))

  Take wind vectors in spherical coordinates and create a pyvista grid for them.

  Parameters

    - u (iris.cube.Cube) – 2D or 3D cube of x-wind component (zonal wind).

    - v (iris.cube.Cube) – 2D or 3D cube of y-wind component (meridional wind).

    - w (iris.cube.Cube) – 2D or 3D cube of z-wind component (vertical wind).

    - vector_scale (float, optional) – Scaling factor for vectors.

    - vertical_wind_scale (float, optional) – Scaling factor for the vertical wind component (for better visibility).

    - z_scale (float, optional) – Scaling factor for the vertical level dimension.

    - z_offset (float, optional) – Scaling offset for the vertical level dimension.

    - xstride (float, optional) – Stride along the longitude axis.

    - ystride (float, optional) – Stride along the latitude axis.

    - grid (pyvista.StructuredGrid, optional) – If given, add data to the existing grid, otherwise create a new one from the input cube’s coordinates.

    - label (str, optional) – Label for the data within the grid.

    - model (aeolus.model.Model, optional) – Model class with relevant variable names.

  Returns

    PyVista grid with vector data in point_arrays.

  Return type

    pyvista.StructuredGrid