swiftsimio.visualisation.volume_render_backends.scatter module

Basic volume render for SPH data.

Takes the 3D positions of the particles and projects them onto a grid.

swiftsimio.visualisation.volume_render_backends.scatter.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]

Create 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.ndarray[np.float64]) – Array of x-positions of the particles. Must be bounded by [0, 1].

  • y (np.ndarray[np.float64]) – Array of y-positions of the particles. Must be bounded by [0, 1].

  • z (np.ndarray[np.float64]) – Array of z-positions of the particles. Must be bounded by [0, 1].

  • m (np.ndarray[np.float32]) – Array of masses (or otherwise weights) of the particles.

  • h (np.ndarray[np.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 (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:

Voxel grid of quantity.

Return type:

np.ndarray[np.float32, np.float32, np.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 np.ones.

swiftsimio.visualisation.volume_render_backends.scatter.scatter_limited_z(x: float64, y: float64, z: float64, m: float32, h: float32, res: int, res_ratio_z: int, box_x: float64 = 0.0, box_y: float64 = 0.0, box_z: float64 = 0.0) ndarray[source]

Create 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.ndarray[np.float64]) – Array of x-positions of the particles. Must be bounded by [0, 1].

  • y (np.ndarray[np.float64]) – Array of y-positions of the particles. Must be bounded by [0, 1].

  • z (np.ndarray[np.float64]) – Array of z-positions of the particles. Must be bounded by [0, 1].

  • m (np.ndarray[np.float32]) – Array of masses (or otherwise weights) of the particles.

  • h (np.ndarray[np.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.

  • res_ratio_z (int) – The number of voxels along the x and y axes relative to the z axis. If this is, for instance, 8, and the res is 128, then the output np.array will be 128 x 128 x 16.

  • 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:

Voxel grid of quantity.

Return type:

np.ndarray[np.float32, np.float32, np.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 np.ones.

swiftsimio.visualisation.volume_render_backends.scatter.scatter_parallel(x: float64, y: float64, z: float64, m: float32, h: float32, res: int, res_ratio_z: int = 1, 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 (np.array of np.float64) – Array of x-positions of the particles. Must be bounded by [0, 1].

  • y (np.array of np.float64) – Array of y-positions of the particles. Must be bounded by [0, 1].

  • z (np.array of np.float64) – Array of z-positions of the particles. Must be bounded by [0, 1].

  • m (np.array of np.float32) – Array of masses (or otherwise weights) of the particles.

  • h (np.array of np.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.

  • res_ratio_z (int) – The number of voxels along the x and y axes relative to the z.

  • 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:

Voxel grid of quantity.

Return type:

np.ndarray of np.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 np.ones.