swiftsimio.visualisation package
Visualisation sub-module for swiftismio.
- swiftsimio.visualisation.project_gas(data: SWIFTDataset, resolution: int, project: str | None = 'masses', region: cosmo_array | None = None, mask: ndarray | None = None, rotation_center: cosmo_array | None = None, rotation_matrix: ndarray | None = None, parallel: bool = False, backend: str = 'fast', periodic: bool = True) cosmo_array[source]
Create a 2D projection of a gas particle-carried field onto a 2D grid.
Create a 2D projection of a SWIFT dataset, projected by the “project” variable (e.g. if project is Temperature, we return: bar{T} = sum_j T_j W_{ij}).
Default projection variable is mass. If it is None, then we don’t weight with anything, providing a number density image.
- Parameters:
data (SWIFTDataset) – The SWIFT dataset that you wish to visualise (get this from
load).resolution (int) – The resolution of the image. All images returned are square,
resbyres, pixel grids.project (str, optional) – Variable to project to get the weighted density of. By default, this is mass. If you would like to mass-weight any other variable, you can always create it as
data.gas.my_variable = data.gas.other_variable * data.gas.masses. The result is comoving if this is comoving, else it is physical.region (cosmo_array, optional) – Region, 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 or six, and take the form:
[x_min, x_max, y_min, y_max, {z_min, z_max}].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
velociraptorcatalogue, or if you only want to visualise e.g. star forming particles. This boolean mask is applied just before visualisation.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.
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 projection along the z axis.parallel (bool, optional) – Defaults to
False, whether or not to create the image in parallel. The parallel version of this function uses significantly more memory.backend (str, optional) – Backend to use. See documentation for details. Defaults to ‘fast’.
periodic (bool, optional) – Account for periodic boundary conditions for the simulation box? Defaults to
True.
- Returns:
Projected image with units of project / length^2, of size
resxres. Comoving ifprojectdata are comoving, else physical.- Return type:
Notes
Particles outside of this range are still considered if their smoothing lengths overlap with the range.
The returned array has x as the first component and y as the second component, which is the opposite to what
imshowrequires. You should transpose the array if you want it to be visualised the ‘right way up’. Also use origin=”lower” with imshow.
- swiftsimio.visualisation.project_pixel_grid(data: __SWIFTGroupDataset, resolution: int, project: str | None = 'masses', region: cosmo_array | None = None, mask: ndarray | None = None, rotation_matrix: ndarray | None = None, rotation_center: cosmo_array | None = None, parallel: bool = False, backend: str = 'fast', periodic: bool = True) cosmo_array[source]
Create a 2D projection of a particle-carried field onto a 2D grid.
Create a 2D projection of a SWIFT dataset, projected by the “project” variable (e.g. if project is Temperature, we return: bar{T} = sum_j T_j W_{ij}).
Default projection variable is mass. If it is None, then we don’t weight with anything, providing a number density image.
- Parameters:
data (__SWIFTGroupDataset) – The SWIFT dataset that you wish to visualise (get this from
load).resolution (int) – The resolution of the image. All images returned are square,
resbyres, pixel grids.project (str, optional) – Variable to project to get the weighted density of. By default, this is mass. If you would like to mass-weight any other variable, you can always create it as
data.gas.my_variable = data.gas.other_variable * data.gas.masses. The result is comoving if this is comoving, else it is physical.region (cosmo_array, optional) – Region, 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 or six, and take the form:
[x_min, x_max, y_min, y_max, {z_min, z_max}].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
velociraptorcatalogue, or if you only want to visualise e.g. star forming particles. This boolean mask is applied just before visualisation.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 projection along 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.
parallel (bool, optional) – Defaults to
False, whether or not to create the image in parallel. The parallel version of this function uses significantly more memory.backend (str, optional) – Backend to use. See documentation for details. Defaults to ‘fast’.
periodic (bool, optional) – Account for periodic boundary conditions for the simulation box? Defaults to
True.
- Returns:
Projected image with units of project / length^2, of size
resxres. Comoving ifprojectdata are comoving, else physical.- Return type:
Notes
Particles outside of this range are still considered if their smoothing lengths overlap with the range.
The returned array has x as the first component and y as the second component, which is the opposite to what
imshowrequires. You should transpose the array if you want it to be visualised the ‘right way up’. Also use origin=”lower” with imshow.
- swiftsimio.visualisation.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) cosmo_array[source]
Create a data field-weighted 2D slice through 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
Nonethen 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.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.np.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.
- Returns:
Slice image with units of project / length^2, of size
resxres. Comoving ifprojectdata are comoving, else physical.- Return type:
See also
render_gas_voxel_gridCreates a 3D voxel grid from a SWIFT dataset.
- swiftsimio.visualisation.render_gas(data: SWIFTDataset, resolution: int, project: str | None = 'masses', parallel: bool = False, rotation_matrix: ndarray | None = None, rotation_center: cosmo_array | None = None, region: cosmo_array | None = None, periodic: bool = True) cosmo_array[source]
Create a data-field weighted 3D render of a SWIFT dataset as a voxel grid.
- Parameters:
data (SWIFTDataset) – Dataset from which render is extracted.
resolution (int) – Specifies size of return np.array.
project (str, optional) – Data field to be projected. Default is
"mass". IfNonethen 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.array, optional) – Rotation matrix (3x3) that describes the rotation of the box around
rotation_center. In the default case, this provides a volume render viewed along 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, and front and back edges) if it is not None. It should have a length of six, and take the form:
[x_min, x_max, y_min, y_max, z_min, z_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:
Voxel grid with units of project / length^3, of size
resolutionxresolutionxresolution. Comoving ifprojectdata are comoving, else physical.- Return type:
See also
slice_gas_pixel_gridCreates a 2D slice of a SWIFT dataset.
- swiftsimio.visualisation.generate_smoothing_lengths(obj: object, *args: tuple[Any], **kwargs: dict[str, Any]) object
Subpackages
- swiftsimio.visualisation.projection_backends package
- Submodules
- swiftsimio.visualisation.projection_backends.fast module
- swiftsimio.visualisation.projection_backends.gpu module
- swiftsimio.visualisation.projection_backends.histogram module
- swiftsimio.visualisation.projection_backends.kernels module
- swiftsimio.visualisation.projection_backends.reference module
- swiftsimio.visualisation.projection_backends.renormalised module
- swiftsimio.visualisation.projection_backends.subsampled module
- swiftsimio.visualisation.projection_backends.subsampled_extreme module
- Submodules
- swiftsimio.visualisation.slice_backends package
- swiftsimio.visualisation.smoothing_length package
- swiftsimio.visualisation.tools package
- swiftsimio.visualisation.volume_render_backends package