swiftsimio.visualisation.slice_backends.sph module
Backend tools for image slices weightd by SPH kernel.
- swiftsimio.visualisation.slice_backends.sph.kernel(r: float | float32, H: float | float32) float[source]
Kernel implementation for swiftsimio.
- Parameters:
r (float or np.float32) – Distance from particle.
H (float or np.float32) – Kernel width (i.e. radius of compact support of kernel).
- Returns:
Contribution to density by particle at distance r.
- Return type:
float
Notes
Swiftsimio uses the Wendland-C2 kernel as described in [1].
References
- swiftsimio.visualisation.slice_backends.sph.slice_scatter(x: float64, y: float64, z: float64, m: float32, h: float32, z_slice: float64, xres: int, yres: int, box_x: float64 = 0.0, box_y: float64 = 0.0, box_z: float64 = 0.0) ndarray[source]
Create a 2D image slice through a volume.
Creates a 2D numpy array (image) of the given quantities of all particles in a data slice including periodic boundary effects.
- Parameters:
x (array of np.float64) – The x-positions of the particles. Must be bounded by [0, 1].
y (array of np.float64) – The y-positions of the particles. Must be bounded by [0, 1].
z (array of np.float64) – The z-positions of the particles. Must be bounded by [0, 1].
m (array of np.float32) – Masses (or otherwise weights) of the particles.
h (array of np.float32) – Smoothing lengths of the particles.
z_slice (np.float64) – The position at which we wish to create the slice.
xres (int) – The number of pixels in the x-direction.
yres (int) – The number of pixels in the y-direction.
box_x (np.float64) – Box size in x, in the same rescaled length units as x, y and z. Used for periodic wrapping.
box_y (np.float64) – Box size in y, in the same rescaled length units as x, y and z. Used for periodic wrapping.
box_z (np.float64) – Box size in z, in the same rescaled length units as x, y and z. Used for periodic wrapping.
- Returns:
Output array for the slice image.
- Return type:
np.ndarray of np.float32
See also
scatterCreate 3D scatter plot of SWIFT data.
scatter_parallelCreate 3D scatter plot of SWIFT data in parallel.
slice_scatter_parallelCreate 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.slice_backends.sph.slice_scatter_parallel(x: float64, y: float64, z: float64, m: float32, h: float32, z_slice: float64, xres: int, yres: int, box_x: float64 = 0.0, box_y: float64 = 0.0, box_z: float64 = 0.0) ndarray[source]
Parallel implementation of slice_scatter.
Creates a scatter plot of the given quantities for a particles in a data slice including periodic boundary effects.
- Parameters:
x (array of np.float64) – The x-positions of the particles. Must be bounded by [0, 1].
y (array of np.float64) – The y-positions of the particles. Must be bounded by [0, 1].
z (array of np.float64) – The z-positions of the particles. Must be bounded by [0, 1].
m (array of np.float32) – Masses (or otherwise weights) of the particles.
h (array of np.float32) – Smoothing lengths of the particles.
z_slice (np.float64) – The position at which we wish to create the slice.
xres (int) – The number of pixels in the x-direction.
yres (int) – The number of pixels in the y-direction.
box_x (np.float64) – Box size in x, in the same rescaled length units as x, y and z. Used for periodic wrapping.
box_y (np.float64) – Box size in y, in the same rescaled length units as x, y and z. Used for periodic wrapping.
box_z (np.float64) – Box size in z, in the same rescaled length units as x, y and z. Used for periodic wrapping.
- Returns:
Output array for the slice image.
- Return type:
np.ndarray of np.float32
See also
scatterCreate 3D scatter plot of SWIFT data.
scatter_parallelCreate 3D scatter plot of SWIFT data in parallel.
slice_scatterCreate scatter plot of a slice of data.
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.