swiftsimio.visualisation.slice module

Create image slices through a volume.

swiftsimio.visualisation.slice.slice_pixel_grid(data: __SWIFTGroupDataset, resolution: int, z_slice: cosmo_quantity | None = None, project: str | None = 'masses', parallel: bool = False, rotation_matrix: ndarray | None = None, rotation_center: cosmo_array | None = None, region: cosmo_array | None = None, backend: str = 'sph', periodic: bool = True, mask: ndarray | None = None) cosmo_array[source]

Create a data field-weighted 2D slice through a particle dataset as a pixel grid.

Parameters:
  • data (__SWIFTGroupDataset) – Particle dataset to slice (e.g. data.gas, data.dark_matter).

  • resolution (int) – Specifies size of return np.array.

  • z_slice (cosmo_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. The result is comoving if this is comoving, else it is physical.

  • 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.ndarray, 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 (cosmo_array, optional) – Center of the rotation. If you are trying to rotate around a galaxy, this should be the most bound particle.

  • region (cosmo_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.

  • backend (str, optional) – Backend to use. Choices are “sph” (default) for interpolation using kernel weights or “nearest_neighbours” for nearest neighbour interpolation.

  • periodic (bool, optional) – Account for periodic boundaries for the simulation box? Default is True.

  • mask (np.array, optional) – Allows only a sub-set of the particles in data to be visualised. Useful in cases where you have read data out of a velociraptor catalogue, or if you only want to visualise e.g. star forming particles. This boolean mask is applied just before visualisation.

Returns:

Slice image with units of project / length^2, of size res x res. Comoving if project data are comoving, else physical.

Return type:

cosmo_array

See also

project_pixel_grid

Creates a 2D projection of a particle dataset.

render_voxel_grid

Creates a 3D voxel grid from a particle dataset.

slice_gas

Convenience wrapper for slicing gas particles.

swiftsimio.visualisation.slice.slice_gas(data: SWIFTDataset, resolution: int, z_slice: cosmo_quantity | None = None, project: str | None = 'masses', parallel: bool = False, rotation_matrix: ndarray | None = None, rotation_center: cosmo_array | None = None, region: cosmo_array | None = None, backend: str = 'sph', periodic: bool = True, mask: ndarray | None = None) cosmo_array[source]

Create a data field-weighted 2D slice through the gas of a SWIFT dataset as a pixel grid.

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

  • resolution (int) – Specifies size of return np.array.

  • z_slice (cosmo_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. The result is comoving if this is comoving, else it is physical.

  • 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.ndarray, 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 (cosmo_array, optional) – Center of the rotation. If you are trying to rotate around a galaxy, this should be the most bound particle.

  • region (cosmo_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.

  • backend (str, optional) – Backend to use. Choices are “sph” (default) for interpolation using kernel weights or “nearest_neighbours” for nearest neighbour interpolation.

  • periodic (bool, optional) – Account for periodic boundaries for the simulation box? Default is True.

  • mask (np.array, optional) – Allows only a sub-set of the particles in data to be visualised. Useful in cases where you have read data out of a velociraptor catalogue, or if you only want to visualise e.g. star forming particles. This boolean mask is applied just before visualisation.

Returns:

Slice image with units of project / length^2, of size res x res. Comoving if project data are comoving, else physical.

Return type:

cosmo_array

See also

slice_pixel_grid

Slices any particle type, not just gas.

render_voxel_grid

Creates a 3D voxel grid from a particle dataset.