swiftsimio.visualisation.projection module
Calls functions from projection_backends.
- swiftsimio.visualisation.projection.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.projection.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.