galaxychop.utils package

Utilities module.

galaxychop.utils.potential(galaxy, backend='numpy')[source]

Potential energy calculation.

Given the positions and masses of particles, calculate their specific gravitational potential energy.

Parameters

galaxy (Galaxy class object) –

Returns

galaxy – A new galaxy object with the specific potential energy of particles calculated.

Return type

new Galaxy class object

galaxychop.utils.center(galaxy)[source]

Particle centring.

Centers the position of all galaxy particles respect to the position of the lowest potential particle.

Parameters

galaxy (Galaxy class object) –

Returns

galaxy – A new galaxy object with centered positions respect to the position of the lowest potential particle.

Return type

new Galaxy class object

galaxychop.utils.is_centered(galaxy, rtol=1e-05, atol=1e-08)[source]

Validate if the galaxy is centered.

Parameters
  • galaxy (Galaxy class object) –

  • rtol (float) – Relative tolerance. Default value = 1e-05.

  • atol (float) – Absolute tolerance. Default value = 1e-08.

Returns

True if galaxy is centered respect to the position of the lowest potential particle, False otherwise.

Return type

bool

galaxychop.utils.star_align(galaxy, *, r_cut=None)[source]

Align the galaxy.

Rotates the positions, velocities and angular momentum of the particles so that the total angular moment of the stars particles coincides with the z-axis. Optionally, only stars particles within a cutting radius (r_cut) can be used to calculate the rotation matrix.

Parameters
  • galaxy (Galaxy class object) –

  • r_cut (float, optional) – Default value = None. If it’s provided, it must be positive and the rotation matrix A is calculated from the particles with radii smaller than r_cut.

Returns

galaxy – A new galaxy object with their total angular momentum aligned with the z-axis.

Return type

new Galaxy class object

galaxychop.utils.is_star_aligned(galaxy, *, r_cut=None, rtol=1e-05, atol=1e-08)[source]

Validate if the galaxy is aligned.

Parameters
  • galaxy (Galaxy class object) –

  • r_cut (float, optional) – Default value = None. If it’s provided, it must be positive and the rotation matrix A is calculated from the particles with radii smaller than r_cut.

  • rtol (float) – Relative tolerance. Default value = 1e-05.

  • atol (float) – Absolute tolerance. Default value = 1e-08.

Returns

True if the total angular momentum of the galaxy is aligned with the z-axis, False otherwise.

Return type

bool

class galaxychop.utils.JCirc(normalized_star_energy, normalized_star_Jz, eps, eps_r, x, y)[source]

Bases: object

Circularity information about the stars particles of a galaxy.

Parameters
  • normalized_star_energy (np.array) – Normalized specific energy of stars.

  • normalized_star_Jz (np.array) – z-component normalized specific angular momentum of the stars.

  • eps (np.array) – Circularity parameter (eps : J_z/J_circ).

  • eps_r (np.array) – Projected circularity parameter (eps_r: J_p/J_circ).

  • x (np.array) – Normalized specific energy for the particle with the maximum z-component of the normalized specific angular momentum per bin.

  • y (np.array) – Maximum value of the z-component of the normalized specific angular momentum per bin.

classmethod circularity_attributes()[source]

Retrieve all the circularity attributes stored in the JCirc class.

This method returns a tuple of str ignoring those that are marked as “asdict=False”.

as_dict()[source]

Convert the instance to a dict.

Attributes are ignored if they are marked as “asdict=False”.

isfinite()[source]

Return a mask of which elements are finite in all attributes.

Attributes are ignored if they are marked as “asdict=False”.

galaxychop.utils.jcirc(galaxy, bin0=0.05, bin1=0.005, runtime_warnings='ignore')[source]

Calculate galaxy stars particles circularity information.

Calculation of Normalized specific energy of the stars, z-component normalized specific angular momentum of the stars, circularity parameter, projected circularity parameter, and the points to build the function of the circular angular momentum.

Parameters
  • galaxy (Galaxy class object) –

  • bin0 (float. Default=0.05) – Size of the specific energy bin of the inner part of the galaxy, in the range of (-1, -0.1) of the normalized energy.

  • bin1 (float. Default=0.005) – Size of the specific energy bin of the outer part of the galaxy, in the range of (-0.1, 0) of the normalized energy.

  • runtime_warnings (Any warning filter action (default "ignore")) – jcirc usually launches RuntimeWarning during the eps calculation because there may be some particle with jcirc=0. By default the function decides to ignore these warnings. runtime_warnings can be set to any valid “action” in the python warnings module.

Returns

Circularity attributes of the star components of the galaxy

Return type

JCirc

Notes

The x and y are calculated from the binning in the normalized specific energy. In each bin, the particle with the maximum value of z-component of standardized specific angular momentum is selected. This value is assigned to the y parameter and its corresponding normalized specific energy pair value to x.

Examples

This returns the normalized specific energy of stars (E_star_norm), the z-component normalized specific angular momentum of the stars (Jz_star_norm), the circularity parameters (eps : J_z/J_circ and eps_r: J_p/J_circ), and the normalized specific energy for the particle with the maximum z-component of the normalized specific angular momentum per bin (x) and the maximum value of the z-component of the normalized specific angular momentum per bin (y).

>>> import galaxychop as gchop
>>> galaxy = gchop.Galaxy(...)
>>> E_star_norm, Jz_star_norm, eps, eps_r, x, y =
>>>        galaxy.jcir(bin0=0.05, bin1=0.005)
galaxychop.utils.doc_inherit(parent)[source]

Inherit the ‘parent’ docstring.

Returns a function/method decorator that, given parent, updates the docstring of the decorated function/method based on the numpy style and the corresponding attribute of parent.

Parameters

parent (Union[str, Any]) – The docstring, or object of which the docstring is utilized as the parent docstring during the docstring merge.

Notes

This decorator is a thin layer over py:function:custom_inherit.doc_inherit decorator.

Check: <github https://github.com/rsokl/custom_inherit>__