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.scatter(x: float64, y: float64, z: float64, m: float32, h: float32, res: int, box_x: float64 = 0.0, box_y: float64 = 0.0, box_z: float64 = 0.0) ndarray [source]
Creates a weighted voxel grid
Computes contributions to a voxel grid from particles with positions (x,`y`,`z`) with smoothing lengths h weighted by quantities m. This includes periodic boundary effects.
- Parameters:
x (np.array[float64]) – array of x-positions of the particles. Must be bounded by [0, 1].
y (np.array[float64]) – array of y-positions of the particles. Must be bounded by [0, 1].
z (np.array[float64]) – array of z-positions of the particles. Must be bounded by [0, 1].
m (np.array[float32]) – array of masses (or otherwise weights) of the particles
h (np.array[float32]) – array of smoothing lengths of the particles
res (int) – the number of voxels along one axis, i.e. this returns a cube of res * res * res.
box_x (float64) – box size in x, in the same rescaled length units as x, y and z. Used for periodic wrapping.
box_y (float64) – box size in y, in the same rescaled length units as x, y and z. Used for periodic wrapping.
box_z (float64) – box size in z, in the same rescaled length units as x, y and z. Used for periodic wrapping
- Returns:
voxel grid of quantity
- Return type:
np.array[float32, float32, float32]
See also
scatter_parallel
Parallel implementation of this function
slice_scatter
Create scatter plot of a slice of data
slice_scatter_parallel
Create scatter plot of a slice of data in parallel
Notes
Explicitly defining the types in this function allows for a 25-50% performance improvement. In our testing, using numpy floats and integers is also an improvement over using the numba ones.
- swiftsimio.visualisation.volume_render.scatter_parallel(x: float64, y: float64, z: float64, m: float32, h: float32, res: int, box_x: float64 = 0.0, box_y: float64 = 0.0, box_z: float64 = 0.0) ndarray [source]
Parallel implementation of scatter
Compute contributions to a voxel grid from particles with positions (x,`y`,`z`) with smoothing lengths h weighted by quantities m. This ignores boundary effects.
- Parameters:
x (array of float64) – array of x-positions of the particles. Must be bounded by [0, 1].
y (array of float64) – array of y-positions of the particles. Must be bounded by [0, 1].
z (array of float64) – array of z-positions of the particles. Must be bounded by [0, 1].
m (array of float32) – array of masses (or otherwise weights) of the particles
h (array of float32) – array of smoothing lengths of the particles
res (int) – the number of voxels along one axis, i.e. this returns a cube of res * res * res.
box_x (float64) – box size in x, in the same rescaled length units as x, y and z. Used for periodic wrapping.
box_y (float64) – box size in y, in the same rescaled length units as x, y and z. Used for periodic wrapping.
box_z (float64) – box size in z, in the same rescaled length units as x, y and z. Used for periodic wrapping
- Returns:
voxel grid of quantity
- Return type:
ndarray of float32
See also
scatter
Create voxel grid of quantity
slice_scatter
Create scatter plot of a slice of data
slice_scatter_parallel
Create scatter plot of a slice of data in parallel
Notes
Explicitly defining the types in this function allows for a 25-50% performance improvement. In our testing, using numpy floats and integers is also an improvement over using the numba ones.
- swiftsimio.visualisation.volume_render.render_gas_voxel_grid(data: SWIFTDataset, resolution: int, project: str | None = 'masses', parallel: bool = False, rotation_matrix: None | array = None, rotation_center: None | unyt_array = None, region: None | unyt_array = None, periodic: bool = True)[source]
Creates a 3D render of a SWIFT dataset, weighted by data field, in the form of a voxel grid.
- Parameters:
data (SWIFTDataset) – Dataset from which slice is extracted
resolution (int) – Specifies size of return array
project (str, optional) – Data field to be projected. Default is mass. If None then simply count number of particles
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 (np.array, optional) – Center of the rotation. If you are trying to rotate around a galaxy, this should be the most bound particle.
region (unyt_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:
Creates a resolution x resolution x resolution array and returns it, without appropriate units.
- Return type:
ndarray of float32
See also
slice_gas_pixel_grid
Creates a 2D slice of a SWIFT dataset
- swiftsimio.visualisation.volume_render.render_gas(data: SWIFTDataset, resolution: int, project: str | None = 'masses', parallel: bool = False, rotation_matrix: None | array = None, rotation_center: None | unyt_array = None, region: None | unyt_array = None, periodic: bool = True)[source]
Creates a 3D voxel grid of a SWIFT dataset, weighted by data field
- Parameters:
data (SWIFTDataset) – Dataset from which slice is extracted
resolution (int) – Specifies size of return array
project (str, optional) – Data field to be projected. Default is mass. If None then simply count number of particles
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 (np.array, optional) – Center of the rotation. If you are trying to rotate around a galaxy, this should be the most bound particle.
region (unyt_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:
a resolution x resolution x resolution array of the contribution of the projected data field to the voxel grid from all of the particles
- Return type:
ndarray of float32
See also
slice_gas
Creates a 2D slice of a SWIFT dataset with appropriate units
render_gas_voxel_grid
Creates a 3D voxel grid of a SWIFT dataset
Notes
This is a wrapper function for slice_gas_pixel_grid ensuring that output units are appropriate