rubix.galaxy package#

Subpackages#

Submodules#

rubix.galaxy.alignment module#

rubix.galaxy.alignment.apply_init_rotation(positions: Float[Array, '* 3'], rotation_matrix: Float[Array, '3 3']) Float[Array, '* 3'][source]#

Apply a rotation matrix to a particle positions array.

Parameters:
  • positions (Float[Array, "* 3"]) – The particle positions.

  • rotation_matrix (Float[Array, "3 3"]) – The rotation matrix to apply.

Returns:

The rotated positions.

Return type:

Float[Array, “* 3”]

rubix.galaxy.alignment.apply_rotation(positions: Float[Array, '* 3'], alpha: float, beta: float, gamma: float) Float[Array, '* 3'][source]#

Apply an Euler-angle rotation using the combined rotation matrix.

Parameters:
  • positions (Float[Array, "* 3"]) – The positions of the particles.

  • alpha (float) – Rotation around the x-axis in degrees.

  • beta (float) – Rotation around the y-axis in degrees.

  • gamma (float) – Rotation around the z-axis in degrees.

Returns:

The rotated positions.

Return type:

Float[Array, “* 3”]

rubix.galaxy.alignment.center_particles(rubixdata: object, key: str) object[source]#

Center the stellar particles around the galaxy center.

Parameters:
  • rubixdata (object) – The RubixData object to update.

  • key (str) – Particle key, e.g. “stars” or “gas”.

Returns:

The same RubixData object with centered coordinates and

velocities.

Return type:

object

Raises:

ValueError – If the galaxy center lies outside the particle bounds.

Example

>>> from rubix.galaxy.alignment import center_particles
>>> rubixdata = center_particles(rubixdata, "stars")
rubix.galaxy.alignment.euler_rotation_matrix(alpha: float, beta: float, gamma: float) Float[Array, '3 3'][source]#

Create a 3x3 rotation matrix given Euler angles (in degrees)

Parameters:
  • alpha (float) – Rotation around the x-axis in degrees

  • beta (float) – Rotation around the y-axis in degrees

  • gamma (float) – Rotation around the z-axis in degrees

Returns:

The rotation matrix as a jnp.ndarray.

rubix.galaxy.alignment.moment_of_inertia_tensor(positions: Float[Array, '...'], masses: Float[Array, '...'], halfmass_radius: Float[Array, '...'] | float) Float[Array, '...'][source]#

Calculate the moment of inertia tensor for particles within the half-mass radius. Assumes the galaxy is already centered.

Parameters:
  • positions (Float[Array, "..."]) – Particle positions.

  • masses (Float[Array, "..."]) – Corresponding masses.

  • halfmass_radius (Union[Float[Array, "..."], float]) – The half-mass radius of the galaxy used to filter particles.

Returns:

Moment of inertia tensor.

Return type:

Float[Array, “…”]

Example

>>> from rubix.galaxy.alignment import moment_of_inertia_tensor
>>> I = moment_of_inertia_tensor(
...     rubixdata.stars.coords,
...     rubixdata.stars.mass,
...     rubixdata.galaxy.halfmassrad_stars,
... )
rubix.galaxy.alignment.rotate_galaxy(positions: Float[Array, '...'], velocities: Float[Array, '...'], positions_stars: Float[Array, '...'], masses_stars: Float[Array, '...'], halfmass_radius: Float[Array, '...'] | float, alpha: float, beta: float, gamma: float, key: str) tuple[Float[Array, '* 3'], Float[Array, '* 3']][source]#

Orientate the galaxy by rotating the particle coordinates by Euler angles.

Parameters:
  • positions (Float[Array, "..."]) – Particle positions.

  • velocities (Float[Array, "..."]) – Particle velocities.

  • positions_stars (Float[Array, "..."]) – Star particle positions.

  • masses_stars (Float[Array, "..."]) – Star particle masses.

  • halfmass_radius (Union[Float[Array, "..."], float]) – Radius used for the moment of inertia calculation.

  • alpha (float) – Rotation around the x-axis in degrees.

  • beta (float) – Rotation around the y-axis in degrees.

  • gamma (float) – Rotation around the z-axis in degrees.

  • key (str) – Dataset key (“IllustrisTNG” or “NIHAO”).

Returns:

Rotated positions and

velocities.

Return type:

Tuple[Float[Array, “* 3”], Float[Array, “* 3”]]

Raises:

ValueError – If key is not supported.

rubix.galaxy.alignment.rotation_matrix_from_inertia_tensor(I: Float[Array, '...']) Float[Array, '...'][source]#

Calculate the 3x3 rotation matrix by diagonalizing the moment of inertia tensor.

Parameters:

I (Float[Array, "..."]) – The moment of inertia tensor.

Returns:

The rotation matrix.

Return type:

Float[Array, “…”]

Module contents#