dedalus.extras.plot_tools

Module Contents

class FieldWrapper(field)

Class to mimic h5py dataset interface for Dedalus fields.

property shape
class DimWrapper(field, axis)

Wrapper class to mimic h5py dimension scales.

property label
plot_bot(dset, image_axes, data_slices, image_scales=(0, 0), clim=None, even_scale=False, cmap='RdBu_r', axes=None, figkw={}, title=None, func=None, visible_axes=True)

Plot a 2d slice of the grid data of a dset/field.

Parameters:
  • dset (h5py dset or Dedalus Field object) – Dataset to plot

  • image_axes (tuple of ints (xi, yi)) – Data axes to use for image x and y axes

  • data_slices (tuple of slices, ints) – Slices selecting image data from global data

  • image_scales (tuple of ints or strs (xs, ys)) – Axis scales (default: (0,0))

  • clim (tuple of floats, optional) – Colorbar limits (default: (data min, data max))

  • even_scale (bool, optional) – Expand colorbar limits to be symmetric around 0 (default: False)

  • cmap (str, optional) – Colormap name (default: ‘RdBu_r’)

  • axes (matplotlib.Axes object, optional) – Axes to overplot. If None (default), a new figure and axes will be created.

  • figkw (dict, optional) – Keyword arguments to pass to plt.figure (default: {})

  • title (str, optional) – Title for plot (default: dataset name)

  • func (function(xmesh, ymesh, data), optional) – Function to apply to selected meshes and data before plotting (default: None)

  • visible_axes (bool, optional) – Set to false to remove x and y ticks, ticklabels, and labels

plot_bot_2d(dset, transpose=False, **kw)

Plot the grid data of a 2d field.

Parameters:
  • field (field object) – Field to plot

  • transpose (bool, optional) – Flag for transposing plot (default: False)

  • Other keyword arguments are passed on to plot_bot.

plot_bot_3d(dset, normal_axis, normal_index, transpose=False, **kw)

Plot a 2d slice of the grid data of a 3d field.

Parameters:
  • field (field object) – Field to plot

  • normal_axis (int or str) – Index or name of normal axis

  • normal_index (int) – Index along normal direction to plot

  • transpose (bool, optional) – Flag for transposing plot (default: False)

  • Other keyword arguments are passed on to plot_bot.

class MultiFigure(nrows, ncols, image, pad, margin, scale=1.0, **kw)

An array of generic images within a matplotlib figure.

Parameters:
  • nrows, ncols (int) – Number of image rows/columns.

  • image (Box instance) – Box describing the image shape.

  • pad (Frame instance) – Frame describing the padding around each image.

  • margin (Frame instance) – Frame describing the margin around the array of images.

  • scale (float, optional) – Scaling factor to convert from provided box/frame units to figsize. Margin will be automatically expanded so that fig dimensions are integers.

  • Other keywords passed to plt.figure.

add_axes(i, j, rect, **kw)

Add axes to a subfigure.

Parameters:
  • i, j (int) – Image row/column

  • rect (tuple of floats) – (left, bottom, width, height) in fractions of image width and height

  • Other keywords passed to Figure.add_axes.

class Box(x, y)

2d-vector-like object for representing image sizes and offsets.

Parameters:

x, y (float) – Box width/height.

property xbox
property ybox
class Frame(top, bottom, left, right)

Object for representing a non-uniform frame around an image.

Parameters:

top, bottom, left, right (float) – Frame widths.

property bottom_left
property top_right
quad_mesh(x, y, cut_x_edges=False, cut_y_edges=False)

Construct quadrilateral mesh arrays from two grids. Intended for use with e.g. plt.pcolor.

Parameters:
  • x (1d array) – Grid for last axis of the mesh.

  • y (1d array) – Grid for first axis of the mesh.

  • cut_x_edges, cut_y_edges (bool, optional) – True to truncate edge quadrilaterals at x/y grid edges. False (default) to center edge quadrilaterals at x/y grid edges.

get_1d_vertices(grid, cut_edges=False)

Get vertices dividing a 1d grid.

Parameters:
  • grid (1d array) – Grid.

  • cut_edges (bool, optional) – True to set edge vertices at grid edges. False (default) to center edge segments at grid edges.

pad_limits(xgrid, ygrid, xpad=0.0, ypad=0.0, square=None)

Compute padded image limits for x and y grids.

Parameters:
  • xgrid (array) – Grid for x axis of image.

  • ygrid (array) – Grid for y axis of image.

  • xpad (float, optional) – Padding fraction for x axis (default: 0.).

  • ypad (float, optional) – Padding fraction for y axis (default: 0.).

  • square (axis object, optional) – Extend limits to have a square aspect ratio within an axis.

get_plane(dset, xaxis, yaxis, slices, xscale=0, yscale=0, **kw)

Select plane from dataset. Intended for use with e.g. plt.pcolor.

Parameters:
  • dset (h5py dataset) – Dataset

  • xaxis, yaxis (int) – Axes for plotting

  • xscale, yscale (int or str) – Corresponding axis scales

  • slices (tuple of ints, slice objects) – Selection object for dataset

  • Other keywords passed to quad_mesh