swiftsimio.visualisation.projection module

Calls functions from projection_backends.

swiftsimio.visualisation.projection.project_pixel_grid(data: __SWIFTParticleDataset, boxsize: unyt_array, resolution: int, project: str | None = 'masses', region: None | unyt_array = None, mask: None | array = None, rotation_matrix: None | array = None, rotation_center: None | unyt_array = None, parallel: bool = False, backend: str = 'fast', periodic: bool = True)[source]

Creates 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 (__SWIFTParticleDataset) – The SWIFT dataset that you wish to visualise (get this from load)

  • boxsize (unyt_array) – The box-size of the simulation.

  • resolution (int) – The resolution of the image. All images returned are square, res by res, 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.

  • region (unyt_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 velociraptor catalogue, 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:

image – Projected image with units of project / length^2, of size res x res.

Return type:

unyt_array

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 imshow requires. You should transpose the array if you want it to be visualised the ‘right way up’.

swiftsimio.visualisation.projection.project_gas_pixel_grid(data: SWIFTDataset, resolution: int, project: str | None = 'masses', region: None | unyt_array = None, mask: None | array = None, rotation_matrix: None | array = None, rotation_center: None | unyt_array = None, parallel: bool = False, backend: str = 'fast', periodic: bool = True)[source]

Creates 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}).

This function is the same as project_gas but does not include units.

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, res by res, 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.

  • region (unyt_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 velociraptor catalogue, 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:

image – Projected image with dimensions of project / length^2, of size res x res.

Return type:

np.array

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 imshow requires. You should transpose the array if you want it to be visualised the ‘right way up’.

swiftsimio.visualisation.projection.project_gas(data: SWIFTDataset, resolution: int, project: str | None = 'masses', region: None | unyt_array = None, mask: None | array = None, rotation_center: None | unyt_array = None, rotation_matrix: None | array = None, parallel: bool = False, backend: str = 'fast', periodic: bool = True)[source]

Creates 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, res by res, 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.

  • region (unyt_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 velociraptor catalogue, 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:

image – Projected image with units of project / length^2, of size res x res.

Return type:

unyt_array

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 imshow requires. You should transpose the array if you want it to be visualised the ‘right way up’.