swiftsimio.visualisation.slice module

Sub-module for slice plots in SWFITSIMio.

swiftsimio.visualisation.slice.kernel(r: float | float32, H: float | float32)[source]

Kernel implementation for swiftsimio.

Parameters:
  • r (float or float32) – Distance from particle

  • H (float or 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.slice_scatter(x: float64, y: float64, z: float64, m: float32, h: float32, z_slice: float64, res: int, box_x: float64 = 0.0, box_y: float64 = 0.0, box_z: float64 = 0.0) ndarray[source]

Creates a scatter plot of the given quantities for a particles in a data slice including periodic boundary effects.

Parameters:
  • x (array of float64) – x-positions of the particles. Must be bounded by [0, 1].

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

  • z (array of float64) – 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

  • res (int) – the number of pixels.

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

output array for scatterplot image

Return type:

ndarray of float32

See also

scatter

Create 3D scatter plot of SWIFT data

scatter_parallel

Create 3D scatter plot of SWIFT data in parallel

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.slice.slice_scatter_parallel(x: float64, y: float64, z: float64, m: float32, h: float32, z_slice: float64, res: 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 float64) – x-positions of the particles. Must be bounded by [0, 1].

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

  • z (array of float64) – 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

  • res (int) – the number of pixels.

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

output array for scatterplot image

Return type:

ndarray of float32

See also

scatter

Create 3D scatter plot of SWIFT data

scatter_parallel

Create 3D scatter plot of SWIFT data in parallel

slice_scatter

Create 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.

swiftsimio.visualisation.slice.slice_gas_pixel_grid(data: SWIFTDataset, resolution: int, z_slice: unyt_quantity | None = None, 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 2D slice of a SWIFT dataset, weighted by data field, in the form of a pixel grid.

Parameters:
  • data (SWIFTDataset) – Dataset from which slice is extracted

  • resolution (int) – Specifies size of return array

  • z_slice (unyt_quantity) – Specifies the location along the z-axis where the slice is to be extracted, relative to the rotation center or the origin of the box if no rotation center is provided. If the perspective is rotated this value refers to the location along the rotated z-axis.

  • 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 slice perpendicular to 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) if it is not None. It should have a length of four, and take the form:

    [x_min, x_max, y_min, y_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 array and returns it, without appropriate units.

Return type:

ndarray of float32

See also

render_gas_voxel_grid

Creates a 3D voxel grid from a SWIFT dataset

swiftsimio.visualisation.slice.slice_gas(data: SWIFTDataset, resolution: int, z_slice: unyt_quantity | None = None, 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 2D slice of a SWIFT dataset, weighted by data field

Parameters:
  • data (SWIFTDataset) – Dataset from which slice is extracted

  • resolution (int) – Specifies size of return array

  • z_slice (unyt_quantity) – Specifies the location along the z-axis where the slice is to be extracted, relative to the rotation center or the origin of the box if no rotation center is provided. If the perspective is rotated this value refers to the location along the rotated z-axis.

  • project (str, optional) – Data field to be projected. Default is mass. If None then simply count number of particles

  • parallel (bool, optional) – 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 slice perpendicular to 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 (array, optional) –

    determines where the image will be created (this corresponds to the left and right-hand edges, and top and bottom edges) if it is not None. It should have a length of four, and take the form:

    [x_min, x_max, y_min, y_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 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_pixel

render_gas

Creates a 3D voxel grid of a SWIFT dataset with appropriate units

Notes

This is a wrapper function for slice_gas_pixel_grid ensuring that output units are appropriate