diskpy.plot package

Module contents

init for diskpy.plot

Created on Thu Jul 16 11:25:15 2015

@author: ibackus

diskpy.plot.gridplot(nrows, ncols=1, square=False)[source]

Creates a grid of tightly-packed subplots and returns them as a numpy array, shape (nrows,ncols). If nrows=ncols=1, a single subplot is made. Currently not fully implemented for a 2D array

diskpy.plot.heatmap(x, y, z, bins=10, plot=True, output=False)[source]

Creates a pcolor heatmap for z evaluated at (x,y). z is binned and averaged according to x and y. x, y, and z should be 1-D arrays with the same length.

IF bins = N, a pcolor plot of shape (N,N) is returned IF bins = (M,N) [a tuple], a pcolor plot of shape (M,N) is returned

IF plot = True (default) a plot is created.

* RETURNS * IF output = False, nothing is returned (default)

IF output = True:

Returns x_mesh, y_mesh, z_binned

x_mesh, y_mesh are the meshgrid x,y edges z is evaluted in. z_binned is the average of z for each bin.

diskpy.plot.lineanimate(x, y, *args, **kwargs)[source]

Makes an animation of a line vs time and saves as .mp4 file. Uses matplotlib.animation.

Parameters:

x : 1D array like

x points (same at every time step)

y : 2D array like

y points (change at each time step). y[i] is plotted at frame i

*args

Optional additional arguments passed to matplotlib.plot

**kwargs

Optional keyword args. The Some are used in movieplot, all others are passed to matplotlib

Returns:

None

diskpy.plot.waterfall(power, t=None, m=None, log=True, normalize=True, cmap=’cubehelix’, vmin=None, vmax=None, colorbar=True)[source]

Generates a waterfall plot for power spectrum vs time for a simulation

Parameters:

power : array, SimArray

2D shape (nt, nm) array of power spectrum

t : array, SimArray

(optional) time points. 1D array

m : array, SimArray

(optional) Fourier mode numbers. 1D array

log: bool

logscale the colors

normalize : bool

Normalize by the DC component at each time step

cmap : str or colormap

colormap to use

vmin, vmax : float

limits

colorbar : bool

Display colorbar

Examples

>>> flist = diskpy.pychanga.get_fnames('snapshot')
>>> m, power = diskpy.disk.powerspectrum_t(flist, spacing='log')
>>> waterfall(power)
diskpy.plot.colorCodedImage(sim, qtys, width=60, resolution=500, z_camera=None, av_zs=(False, False), cmap=’Reds’, vmins=(None, None), vmaxs=(None, None), logs=(True, True))[source]

Generates an image as with pynbody.plot.sph.image with brightness set by one quantity and color set by a second quantity.

Parameters:

sim : SimSnap

Snapshot or sub-snap to render

qtys : list or tuple

A tuple/list of 2 quantities (strings) to render. The quantity are SimSnap keys, e.g. ‘rho’, ‘temp’, ‘mass’, etc. The first quantity sets the brightness of the image, the second sets the color

width : number

Width of the plot to render

resolution : int

Number of pixels to render along each axis

z_camera : number

z-camera location (see pynbody.plot.sph.image)

av_zs : tuple

Average along line-of-sight (see pynbody.plot.sph.image). If True, volume averating is used. If a string averaging is over that qty. E.g., mass averaging can be acheived by using av_zs = (‘rho’, ‘rho’)

cmap : str or cmap

colormap to use for color-coding

vmins, vmaxs : list/tuples

vmin, vmax for the quantities (one for each quantity)

logs : list/tuple

List or tuple of booleans. Defines whether color should use a log scale.

Returns:

im : array

The rendered RGB image used

diskpy.plot.colorCodeArray(x1, x2, cmap=’Reds’)[source]

Get a color-coded array from x1 (brightess) and x2 (color). x1 and x2 are assumed to be normalized (0 to 1). x1 defines the brightness, x2 defines the color. Returns an RGB array

diskpy.plot.normalizeArray(x, log=True, vmin=None, vmax=None)[source]

Normalize an array. Values below/above the thresholds of vmin/vmax are set to 0/1