pynbody.analysis.halo.shape#
- pynbody.analysis.halo.shape(sim, nbins=100, rmin=None, rmax=None, bins='equal', ndim=3, max_iterations=10, tol=0.001, justify=False)[source]#
Calculates the shape of the provided particles in homeoidal shells, over a range of nbins radii.
Homeoidal shells maintain a fixed area (ndim=2) or volume (ndim=3). Note that all provided particles are used in calculating the shape, so e.g. to measure dark matter halo shape from a halo with baryons, you should pass only the dark matter particles.
The simulation must be pre-centred, e.g. using
center()
.The algorithm is sensitive to substructure, which should ideally be removed.
Caution is advised when assigning large number of bins and radial ranges with many particles, as the algorithm becomes very slow.
- Parameters:
nbins (int) – The number of homeoidal shells to consider. Shells with few particles will take longer to fit.
rmin (float) – The minimum radial bin in units of sim[‘pos’]. By default this is taken as rout/1000. Note that this applies to axis a, so particles within this radius may still be included within homeoidal shells.
rmax (float) – The maximum radial bin in units of sim[‘pos’]. By default this is taken as the largest radial value in the halo particle distribution.
bins (str) – The spacing scheme for the homeoidal shell bins. ‘equal’ initialises radial bins with equal numbers of particles, with the exception of the final bin which will accomodate remainders. This number is not necessarily maintained during fitting. ‘log’ and ‘lin’ initialise bins with logarithmic and linear radial spacing.
ndim (int) – The number of dimensions to consider; either 2 or 3 (default). If ndim=2, the shape is calculated in the x-y plane. If using ndim=2, you may wish to make a cut in the z direction before passing the particles to this routine (e.g. using
pynbody.filt.BandPass
).max_iterations (int) – The maximum number of shape calculations (default 10). Fewer iterations will result in a speed-up, but with a bias towards spheroidal results.
tol (float) – Convergence criterion for the shape calculation. Convergence is achieved when the axial ratios have a fractional change <=tol between iterations.
justify (bool) – Align the rotation matrix directions such that they point in a single consistent direction aligned with the overall halo shape. This can be useful if working with slerps.
- Returns:
rbin (SimArray) – The radial bins used for the fitting
axis_lengths (SimArray) – A nbins x ndim array containing the axis lengths of the ellipsoids in each shell
num_particles (np.ndarray) – The number of particles within each bin
rotation_matrices (np.ndarray) – The rotation matrices for each shell