pynbody.plot.sph.image#
- pynbody.plot.sph.image(sim, qty='rho', width='10 kpc', resolution=None, units=None, log=True, vmin=None, vmax=None, weight=False, z_camera=None, clear=True, cmap=None, title=None, colorbar_label=None, qtytitle=None, show_cbar=True, axes=None, noplot=False, filename=None, return_image=False, return_array=False, fill_nan=True, fill_val=0.0, linthresh=None, restrict_depth=False, kernel_type='spline', **kwargs)[source]#
Make an image of the given simulation, using SPH or denoised-SPH interpolation.
- Parameters:
sim (pynbody.snapshot.simsnap.SimSnap) – The simulation snapshot to plot. The image is generated in the plane z=0, or projected along the z axis.
qty (str | pynbody.array.SimArray) – The name of the array to interpolate. Default is ‘rho’, which gives a density image. Alternatively, an array can be passed in.
width (str or float, optional) – The overall width and height of the plot. If a float, it is assumed to be in units of sim[‘pos’]. It can also be passed in as a string indicating the units, e.g. ‘10 kpc’. (Default is ‘10 kpc’)
resolution (int, optional) – The number of pixels wide and tall. (Default is determined by the configuration file.)
units (str or pynbody.units.Unit, optional) – The units of the output. Default is None, in which case the units of the input quantity are used. If the units correspond to integrating the quantity along a spatial dimension, the output is a projected image. For example, if the units are ‘Msol kpc^-2’, and the quantity is ‘rho’, the output is a projected image of the surface density.
log (bool, optional) – If True, the image is log-scaled. (Default is True)
vmin (float, optional) – The minimum value for the color scale. If None, the minimum value of the image.
vmax (float, optional) – The maximum value for the color scale. If None, the maximum value of the image.
weight (bool or str, optional) – If True, the requested quantity is volume-averaged down the line of sight. If a string, the requested quantity is averaged down the line of sight weighted by the named array (e.g. use ‘rho’ for density-weighted quantity).
restrict_depth (bool, optional) – If True, restrict the depth of the image to the width of the image. (Default is False)
z_camera (float, optional) – If set, a perspective image is rendered, as though the camera is a pinhole camera at (0,0,z_camera). The frustrum is defined by the width of the image in the plane z=0.
clear (bool, optional) – Whether to clear the axes before plotting. (Default is True)
cmap (matplotlib.colors.Colormap or str, optional) – Colormap to use. If None, the default colormap is used.
title (str, optional) – Plot title.
colorbar_label (str, optional) – Colorbar label. If not provided, one will be generated from the quantity name and units.
show_cbar (bool, optional) – Whether to automatically plot the colorbar. (Default is True)
axes (matplotlib.axes.Axes, optional) – Axes instance on which the image will be shown; if None, the current pyplot figure is used. (Default is False)
noplot (bool, optional) – If True, the image is not displayed, only the image array is returned. This option therefore implies return_array = True.
filename (str, optional) – If set, the image will be saved in a file.
return_image (bool, optional) – If True, the image instance returned by imshow is returned. (Default is False)
return_array (bool, optional) – If True, the numpy array of the image is returned. (Default is False)
fill_nan (bool, optional) – If any of the image values are NaN, replace with fill_val. (Default is True)
fill_val (float, optional) – The fill value to use when replacing NaNs. (Default is 0.0)
linthresh (float, optional) – If the image has negative and positive values and a log scaling is requested, the part between -linthresh and linthresh is shown on a linear scale to avoid divergence at 0.
kernel_type (str, optional) – SPH kernel to use for smoothing. Defaults to a cubic spline, but can also be set to ‘wendlandC2’. (Default is ‘spline’)
approximate_fast (bool, optional) – If True, speed up the image-making by rendering large kernels onto a lower-resolution image first, which is then interpolated to the final resolution. (Default is set in the config file).
threaded (bool, optional) – If True, use threads to parallelise the rendering. (Default is set in the config file).
qtytitle (str, optional) – Deprecated alias for colorbar_label.
av_z (bool or str, optional) – Deprecated alias for weight.
- Returns:
matplotlib.image.AxesImage – The image instance returned by imshow, if return_image is True.
numpy.ndarray – The image array, if return_array is True or noplot is True.