swiftsimio.visualisation.slice_backends.nearest_neighbours module
Backend tools for image slices with nearest neighbour interpolation.
- swiftsimio.visualisation.slice_backends.nearest_neighbours.build_tree(x: float64, y: float64, z: float64, box_x: float, box_y: float, box_z: float) None[source]
Build the tree used for the nearest-neighbour calculations.
In the periodic case, we must make sure that all particle coordinates fall inside the box.
- Parameters:
x (array of float64) – The x-positions of the particles. Must be bounded by [0, 1].
y (array of float64) – The y-positions of the particles. Must be bounded by [0, 1].
z (array of float64) – The z-positions of the particles. Must be bounded by [0, 1].
box_x (float) – Box size in x, in the same rescaled length units as x, y and z. Used for periodic wrapping (if not 0).
box_y (float) – Box size in y, in the same rescaled length units as x, y and z. Used for periodic wrapping (if not 0).
box_z (float) – Box size in z, in the same rescaled length units as x, y and z. Used for periodic wrapping (if not 0).
- Returns:
A KD-tree built from the particle positions.
- Return type:
KDTree
- swiftsimio.visualisation.slice_backends.nearest_neighbours.slice_scatter(x: float64, y: float64, z: float64, m: float32, h: float32, z_slice: float, xres: int, yres: int, box_x: float = 0.0, box_y: float = 0.0, box_z: float = 0.0, workers: int = 1) 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 float64) – The x-positions of the particles. Must be bounded by [0, 1].
y (array of float64) – The y-positions of the particles. Must be bounded by [0, 1].
z (array of float64) – The z-positions of the particles. Must be bounded by [0, 1].
m (array of float32) – Masses (or otherwise weights) of the particles.
h (array of float32) – Smoothing lengths of the particles.
z_slice (float64) – The position at which we wish to create the slice.
xres (int) – The number of pixels in x direction.
yres (int) – The number of pixels in the y direction.
box_x (float) – Box size in x, in the same rescaled length units as x, y and z. Used for periodic wrapping (if not 0).
box_y (float) – Box size in y, in the same rescaled length units as x, y and z. Used for periodic wrapping (if not 0).
box_z (float) – Box size in z, in the same rescaled length units as x, y and z. Used for periodic wrapping (if not 0).
workers (int) – The number of workers to use for the nearest-neighbour calculations. Set to -1 to use all available cpus.
- Returns:
Output array for the slice image.
- Return type:
ndarray of 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.
- swiftsimio.visualisation.slice_backends.nearest_neighbours.slice_scatter_parallel(x: float64, y: float64, z: float64, m: float32, h: float32, z_slice: float, xres: int, yres: int, box_x: float = 0.0, box_y: float = 0.0, box_z: float = 0.0) ndarray[source]
Parallel implementation of slice_scatter.
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 float64) – The x-positions of the particles. Must be bounded by [0, 1].
y (array of float64) – The y-positions of the particles. Must be bounded by [0, 1].
z (array of float64) – The z-positions of the particles. Must be bounded by [0, 1].
m (array of float32) – Masses (or otherwise weights) of the particles.
h (array of float32) – Smoothing lengths of the particles.
z_slice (float64) – The position at which we wish to create the slice.
xres (int) – The number of pixels in x direction.
yres (int) – The number of pixels in the y direction.
box_x (float) – Box size in x, in the same rescaled length units as x, y and z. Used for periodic wrapping (if not 0).
box_y (float) – Box size in y, in the same rescaled length units as x, y and z. Used for periodic wrapping (if not 0).
box_z (float) – Box size in z, in the same rescaled length units as x, y and z. Used for periodic wrapping (if not 0).
- Returns:
Output array for the slice image.
- Return type:
ndarray of 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.