Plotting Functions

Here’s a reference of pyharm’s internal plotting functions, should any prove useful in new contexts. Everything on this page is imported to the global pyharm.plots namespace, so you don’t have to remember what is in which file.

Plotting from Dump Files

2D plots of variables over different slices of a simulation domain. This file handles plotting of any particular variable on a particular matplotlib.Axis object. For full figures with default annotations, variable choices, etc, see figures.py

pyharm.plots.plot_dumps._decorate_plot(ax, dump, var, bh=True, xticks=None, yticks=None, frame=True, cbar=True, cbar_ticks=None, cbar_label=None, label=None, **kwargs)

Add any extras to plots which are not dependent on data or slicing. Accepts arbitrary extra arguments for compatibility – they are passed nowhere.

Parameters:
  • bh – Add the BH silhouette
  • xticks – If not None, set all xticks to specified list
  • yticks – If not None, set all yticks to specified list
  • frame – whether to show the plot axes/border at all
  • cbar – Add a colorbar
  • cbar_ticks – If not None, set colorbar ticks to specified list
  • cbar_label – If not None, set colorbar label
  • label – If not None, set plot title
pyharm.plots.plot_dumps.plot_slices(ax1, ax2, dump, var, field_overlay=False, nlines=10, **kwargs)

Make adjacent plots with plot_xy and plot_xz, using the given pair of axes. Assumes axes are arranged left-to-right ax1, ax2

pyharm.plots.plot_dumps.plot_thphi(ax, dump, var, at_r=None, at_i=None, cmap='jet', vmin=None, vmax=None, window=None, xlabel=True, ylabel=True, native=False, log=False, projection='mercator', shading='gouraud', **kwargs)

Plot a theta-phi slice at index at_i Note this function also accepts all keyword arguments to _decorate_plot()

Parameters:
  • ax – Axes object to paint on
  • dump – fluid state object
  • vmax (vmin,) – colorbar minimum and maximum, ‘None’ auto-detects
  • window – view window in X,Z coordinates, measured in r_g/c^2, 0 in BH center.
  • ylabel (xlabel,) – whether to mark X/Y labels with reasonable titles
  • native – Plot in native coordinates X1/X2 as plot X/Y axes respectively
  • log – plot a signed quantity in logspace with symlog() above
  • projection
    “mercator”: default, project theta on Y-axis and phi on X-axis. Differs from ‘native’ due to midplane compression.
    ”polar”: view down from +z. Or with ‘bottom’, view up from -Z.
    ”flattened_polar”: reinterpret as polar coordinates, theta -> r, phi -> phi
  • shading
pyharm.plots.plot_dumps.plot_xy(ax, dump, var, vmin=None, vmax=None, window=None, xlabel=True, ylabel=True, native=False, log=False, cmap='jet', shading='gouraud', at=None, average=False, sum=False, cbar=True, log_r=True, **kwargs)

Plot a toroidal or X1/X3 slice of a dump file. Note this function also accepts all keyword arguments to _decorate_plot()

Parameters:
  • ax – Axes object to paint on
  • dump – fluid state object
  • vmax (vmin,) – colorbar minimum and maximum, ‘None’ auto-detects
  • window – view window in X,Z coordinates, measured in r_g/c^2, 0 in BH center.
  • ylabel (xlabel,) – whether to mark X/Y labels with reasonable titles
  • native – Plot in native coordinates X1/X2 as plot X/Y axes respectively
  • log – plot a signed quantity in logspace with symlog() above
pyharm.plots.plot_dumps.plot_xz(ax, dump, var, vmin=None, vmax=None, window=(-40, 40, -40, 40), xlabel=True, ylabel=True, native=False, log=False, half_cut=False, cmap='jet', shading='gouraud', at=None, average=False, sum=False, cbar=True, log_r=False, **kwargs)

Plot a poloidal or X1/X2 slice of a dump file. Note this function also accepts all keyword arguments to _decorate_plot()

Parameters:
  • ax – Axes object to paint on
  • dump – fluid state object
  • vmax (vmin,) – colorbar minimum and maximum
  • window – view window in X,Z coordinates, measured in r_g/c^2, 0 in BH center.
  • ylabel (xlabel,) – whether to mark X/Y labels with reasonable titles
  • native – Plot in native coordinates X1/X2 as plot X/Y axes respectively
  • log – plot a signed quantity in logspace with symlog() above

Plotting from Analysis Results

Functions for plotting analysis results (AnaResults object). This and result_figures are very WIP

pyharm.plots.plot_results.plot_hst(ax, diag, var, tline=None, xticklabels=None, xlabel=None, **kwargs)

Plot a scalar vs t, optionally marking with a red line representing current time

Plotting Emission Origin and Non-FluidDump Data

Plots related to zone-based data recorded by e.g. ipole, not a full fluid dump. The primary function plots data recorded by ipole in “histo” mode, which records any intensity changes in a bin corresponding to the nearest zone. This illustrates where observed emission tends to originate. The other functions plot properties of the spacetime or illustrate geometry such as the observer angle.

pyharm.plots.origin.plot_emission_origin(ax, grid, Inu, window=None, sz=6, log=False, vmin=None, vmax=None)

Plot the origin of emission, as recorded by ipole in a 3D histogram of emission count/zone Inu. Normalizes by zone area on the plot in order to show true emission density.

Plotting Utilities

Generic utilities and plot types – anything plotting-related which is potentially useful (or indeed stolen from) outside pyharm

pyharm.plots.plot_utils.pcolormesh_log(ax, X, Y, Z, vmax=None, vmin=None, cmap='jet', cbar=True, **kwargs)

Wrapper for matplotlib’s pcolormesh that uses it sensibly, instead of the defaults.

If not specified, vmax is set automatically In order to keep colors sensible, vmin is overridden unless set alone.

pyharm.plots.plot_utils.pcolormesh_symlog(ax, X, Y, Z, vmax=None, vmin=None, linthresh=None, decades=4, linscale=0.01, cmap='RdBu_r', cbar=True, **kwargs)

Wrapper for matplotlib’s pcolormesh that uses it sensibly, instead of the defaults.

If linthresh is not specified, it defaults to vmax*10**(-decades), i.e. showing that number of decades each of positive and negative values.

If not specified, vmax is set automatically In order to keep colors sensible, vmin is overridden unless set alone.