pynbody.analysis.angmom.align

Contents

pynbody.analysis.angmom.align#

pynbody.analysis.angmom.align(h, vec_to_xform, disk_size='5 kpc', move_all=True, already_centered=False, center_kwargs=None)[source]#

Reposition and rotate the ancestor of h to place the angular momentum into a specified orientation.

The routine first calls the center routine to reposition the halo (unless already_centered is True). If there are a sufficient number of star particles (more than 100), only the star particles are used for centering; if there is an offset between dark matter and baryons, it is better to centre on the baryons.

Then, it determines the disk orientation using the angular momentum vector of the gas particles within a specified radius of the halo center. If there are less than 5 gas particles within this radius, the routine falls back first to stellar particles, and then to all particles.

Finally, the angular momentum vector is converted into a rotation matrix using the vec_to_xform function, and the rotation is applied.

See also

Convenient wrappers around this routine are provided to either align a disk side-on or face-on; see sideon() and faceon().

Changed in version 2.3.1: The routine previously checked the total number of gas particles to determine whether to use gas for angular momentum determination, but now actually checks particles in the specified radius. This prevents an issue where there could be enough gas particles overall but none in the specified radius, leading the routine to fail.

Additionally, the docstring regarding choice of particles for centring has been clarified.

Parameters:
  • h (SimSnap) – The portion of the simulation from which to extract a centre and orientation. Typically this is a galaxy halo.

  • vec_to_xform (function) – The function to use to calculate the rotation matrix from the measured angular momentum vector.

  • disk_size (str | float, optional) – The size of the disk to use for calculating the angular momentum vector. Default is “5 kpc”.

  • move_all (bool, optional) – If True, the ancestor simulation of h is transformed. If False, only h is moved. Default is True.

  • already_centered (bool, optional) – If True, the simulation is assumed to be already centered. Default is False.

  • center_kwargs (dict, optional) – Dictionary of additional keyword arguments to pass to the centering routine.