pynbody.analysis.halo.center

Contents

pynbody.analysis.halo.center#

pynbody.analysis.halo.center(sim, mode=None, return_cen=False, with_velocity=True, cen_size='1 kpc', cen_num_particles=10000, move_all=True, wrap=False, **kwargs)[source]#

Transform the ancestor snapshot so that the provided snapshot is centred

The centering scheme is determined by the mode keyword. As well as the position, the velocity can also be centred.

The following centring modes are available:

  • pot: potential minimum

  • com: center of mass

  • ssc: shrink sphere center

  • hyb: for most halos, returns the same as ssc, but works faster by starting iteration near potential minimum

Before the main centring routine is called, the snapshot is translated so that the halo is already near the origin. The box is then wrapped so that halos on the edge of the box are handled correctly.

Parameters:
  • sim (SimSnap) – The simulation snapshot from which to derive a centre. The ancestor snapshot is then transformed.

  • mode (str or function, optional) – The method to use to determine the centre. If None, the default is taken from the configuration. Accepted values are discussed above. A function returning the centre, or a pair of centres (position and velocity) can also be passed.

  • cen_size (str or float, optional) – The size of the sphere to use for the velocity centering. Default is 1 kpc. Note that this is only used if velocity centring is requested but the underlying method does not return a velocity centre. For example, if using the ‘ssc’ method, the cen_num_particles keyword should be used instead.

  • cen_num_particles (int, optional) – The number of particles to use for the velocity centering. Default is 5000. This is passed to the ‘ssc’ method, which then finds the sphere with approximately this number of particles in it for the velocity centering.

  • with_velocity (bool, optional) – If True, also center the velocity. Default is True.

  • return_cen (bool, optional) – If True, only return the center without actually centering the snapshot. Default is False.

  • move_all (bool, optional) – If True (default), move the entire snapshot. Otherwise only move the particles in the halo/subsnap passed into this function.

  • vel (bool, optional) – Deprecated alias for with_velocity. Default is True.

  • retcen (bool, optional) – If True, only return the center without centering the snapshot. Default is False.

Returns:

Normally, a transformation object that can be used to revert the transformation. However, if return_cen is True, a SimArray containing the center coordinates is returned instead, and the snapshot is not transformed.

Return type:

Transformation | SimArray