swiftsimio.visualisation.volume_render module
Basic volume render for SPH data.
This takes the 3D positions of the particles and projects them onto a grid.
- swiftsimio.visualisation.volume_render.render_gas(data: SWIFTDataset, resolution: int, project: str | None = 'masses', parallel: bool = False, rotation_matrix: ndarray | None = None, rotation_center: cosmo_array | None = None, region: cosmo_array | None = None, periodic: bool = True) cosmo_array[source]
Create a data-field weighted 3D render of a SWIFT dataset as a voxel grid.
- Parameters:
data (SWIFTDataset) – Dataset from which render is extracted.
resolution (int) – Specifies size of return np.array.
project (str, optional) – Data field to be projected. Default is
"mass". IfNonethen simply count number of particles. The result is comoving if this is comoving, else it is physical.parallel (bool) – Used to determine if we will create the image in parallel. This defaults to False, but can speed up the creation of large images significantly at the cost of increased memory usage.
rotation_matrix (np.array, optional) – Rotation matrix (3x3) that describes the rotation of the box around
rotation_center. In the default case, this provides a volume render viewed along the z axis.rotation_center (cosmo_array, optional) – Center of the rotation. If you are trying to rotate around a galaxy, this should be the most bound particle.
region (cosmo_array, optional) –
Determines where the image will be created (this corresponds to the left and right-hand edges, and top and bottom edges, and front and back edges) if it is not None. It should have a length of six, and take the form:
[x_min, x_max, y_min, y_max, z_min, z_max]
Particles outside of this range are still considered if their smoothing lengths overlap with the range.
periodic (bool, optional) – Account for periodic boundaries for the simulation box? Default is
True.
- Returns:
Voxel grid with units of project / length^3, of size
resolutionxresolutionxresolution. Comoving ifprojectdata are comoving, else physical.- Return type:
See also
slice_gas_pixel_gridCreates a 2D slice of a SWIFT dataset.
- swiftsimio.visualisation.volume_render.render_voxels_to_array(data: array, center: float, width: float) array[source]
Insert voxel values into a 2D image grid.
Handles a single render function (call multiple times for multiple render functions).
- Parameters:
data (np.ndarray) – The 3D voxel array.
center (float) – The center of the rendering function.
width (float) – The width of the rendering function.
- Returns:
The 2D image array.
- Return type:
np.ndarray
- swiftsimio.visualisation.volume_render.visualise_render(render: ndarray, centers: list[float], widths: list[float] | float, cmap: str = 'viridis', return_type: Literal['all', 'lighten', 'add'] = 'lighten', norm: list[plt.Normalize] | plt.Normalize | None = None) tuple[list[np.ndarray] | np.ndarray, list[plt.Normalize]][source]
Visualise a render with multiple centers and widths.
- Parameters:
render (np.array) – The render to visualise. You should scale this appropriately before using this function (e.g. use a logarithmic transform!) and pass in the ‘value’ np.array, not the original cosmo_array or unyt_array.
centers (list[float]) – The centers of your rendering functions.
widths (list[float] | float) – The widths of your rendering functions. If a single float, all functions will have the same width.
cmap (str) – The colormap to use for the rendering functions.
return_type (Literal["all", "lighten", "add"]) – The type of return. If “all”, all images are returned. If “lighten”, the maximum of all images is returned. If “add”, the sum of all images is returned.
norm (list[plt.Normalize] | plt.Normalize | None) – The normalisation to use for the rendering functions. If a single normalisation, all functions will use the same normalisation.
- Returns:
list[np.array] | np.array – The images of the rendering functions. If return_type is “all”, this will be a list of images. If return_type is “lighten” or “add”, this will be a single image.
list[plt.Normalize] – The normalisations used for the rendering functions.
- swiftsimio.visualisation.volume_render.visualise_render_options(centers: list[float], widths: list[float] | float, cmap: str = 'viridis') tuple[plt.Figure, plt.Axes][source]
Create a figure of your rendering options.
The y-axis is the output value of the rendering function. The x-axis is your input quantity. You may wish to plot a histogram on top of this figure; this is why the figure axes and figure are returned.
- Parameters:
centers (list[float]) – The centers of your rendering functions.
widths (list[float] | float) – The widths of your rendering functions. If a single float, all functions will have the same width.
cmap (str) – The colormap to use for the rendering functions.
- Returns:
plt.Figure – The matplotlib figure object used for the plot.
plt.Axes – The matplotlib axes object used for the plot.