Cython Helper Functions

Contains relevant Cython helper functions

class cython_helpers.helper_class.CythonHelpers[source]

Bases: object

ZHEEVR(H, double[:] eigvals, double complex[::1, :] Z, int nrows)[source]

Computes the eigenvalues and eigenvectors of a dense Hermitian matrix.

Eigenvectors are returned in Z.

Parameters
  • H (Fortran-ordered 2D double complex memoryview) – Hermitian matrix

  • eigvals (double array like) – Input array to store eigenvalues

  • Z (Fortran-ordered 2D double complex memoryview) – Output array of eigenvectors

  • nrows (int) – Number of rows = number of columns in H

Raises

Exception if not converged

calcCoM(nns, float[:] masses, float[:] com)[source]

Return center of mass (COM)

Parameters
  • nns ((N,3) floats) – positions of cloud particles

  • masses ((N,) floats) – masses of cloud particles

  • com ((3,) floats) – COM array to be filled

Returns

COM

Return type

(3,) floats

calcDensProfBruteForceEll(xyz, float[:, :] xyz_princ, float[:] masses, float[:] center, float r_200, float[:] a, float[:] b, float[:] c, float[:, :] major, float[:, :] inter, float[:, :] minor, float[:] dens_prof, int[:] shell)[source]

Calculates ellipsoidal shell-based density profile for one object with coordinates xyz and masses masses

Parameters
  • xyz ((N,3) floats) – positions of cloud particles

  • xyz_princ ((N,3) floats) – position arrays transformed into principal frame (varies from shell to shell)

  • masses ((N,) floats) – masses of cloud particles

  • center – center of the object

  • r_200 (float) – R200 value of the object

  • a ((N2+1,) floats) – major axis eigenvalue interpolated at radial bin edges

  • b ((N2+1,) floats) – intermediate axis eigenvalue interpolated at radial bin edges

  • c ((N2+1,) floats) – minor axis eigenvalue interpolated at radial bin edges

  • major ((N2,3) floats) – major axis eigenvector interpolated at radial bin centers

  • inter ((N2,3) floats) – inter axis eigenvector interpolated at radial bin centers

  • minor ((N2,3) floats) – minor axis eigenvector interpolated at radial bin centers

  • dens_prof ((N2,) floats) – array to store result in

  • shell ((N,) int array) – array used for the calculation

Returns

density profile

Return type

float array

calcDensProfBruteForceSph(xyz, float[:] masses, float[:] center, float r_200, float[:] bin_edges, float[:] dens_prof, int[:] shell)[source]

Calculates spherically averaged density profile for one object with coordinates xyz and masses masses

Parameters
  • xyz ((N,3) floats) – positions of cloud particles

  • masses ((N,) floats) – masses of cloud particles

  • center – center of the object

  • r_200 (float) – R200 value of the object

  • bin_edges ((N2+1,) floats) – radial bin edges at whose centers the density profiles should be calculated, normalized by R200

  • dens_prof ((N2,) floats) – array to store result in

  • shell ((N,) int array) – array used for the calculation

Returns

density profile

Return type

float array

calcKTilde(r, float r_i, float h_i)[source]

Angle-averaged normalized Gaussian kernel for kernel-based density profile estimation

Parameters
  • r (float) – radius in Mpc/h at which to calculate the local, spherically-averaged density

  • r_i (float) – radius of point i whose contribution to the local, spherically-averaged density shall be determined

  • h_i (float) – width of Gaussian kernel for point i

Returns

angle-averaged normalized Gaussian kernel

Return type

float

calcLocalSpread(nns)[source]

Calculate local spread (2nd moment) around center of volume of point cloud

Parameters

nns ((N,3) floats) – positions of cloud particles

Returns

local spread

Return type

float

calcMenclsBruteForceEll(xyz, float[:, :] xyz_princ, float[:] masses, float[:] center, float[:] a, float[:] b, float[:] c, float[:, :] major, float[:, :] inter, float[:, :] minor, float[:] Mencl, int[:] ellipsoid)[source]

Calculates ellipsoid-based mass profile for one object with coordinates xyz and masses masses

Parameters
  • xyz ((N,3) floats) – positions of cloud particles

  • xyz_princ ((N,3) floats) – position arrays transformed into principal frame (varies from shell to shell)

  • masses ((N,) floats) – masses of cloud particles

  • center – center of the object

  • a ((N2+1,) floats) – major axis eigenvalue interpolated at radial bin edges

  • b ((N2+1,) floats) – intermediate axis eigenvalue interpolated at radial bin edges

  • c ((N2+1,) floats) – minor axis eigenvalue interpolated at radial bin edges

  • major ((N2,3) floats) – major axis eigenvector interpolated at radial bin centers

  • inter ((N2,3) floats) – inter axis eigenvector interpolated at radial bin centers

  • minor ((N2,3) floats) – minor axis eigenvector interpolated at radial bin centers

  • Mencl (float array) – array to store result in

  • ellipsoid (int array) – array used for the calculation

Returns

enclosed mass profile

Return type

float array

calcMenclsBruteForceSph(xyz, float[:] masses, float[:] center, float r_200, float[:] ROverR200, float[:] Mencl, int[:] ellipsoid)[source]

Calculates spherically averaged enclosed mass profile for one object with coordinates xyz and masses masses

Parameters
  • xyz ((N,3) floats) – positions of cloud particles

  • masses ((N,) floats) – masses of cloud particles

  • center – center of the object

  • r_200 (float) – R200 value of the object

  • ROverR200 (float array) – radii at which the density profiles should be calculated, normalized by R200

  • Mencl (float array) – array to store result in

  • ellipsoid (int array) – array used for the calculation

Returns

enclosed mass profile

Return type

float array

calcShapeTensor(nns, int[:] select, double complex[::1, :] shape_tensor, float[:] masses, float[:] center, int nb_pts, bool reduced, float[:] r_ell=None)[source]

Calculate shape tensor for point cloud

Parameters
  • nns ((N,3) floats) – positions of cloud particles

  • select ((N1,3) ints) – indices of cloud particles to consider

  • shape_tensor ((3,3) complex) – shape tensor array to be filled

  • masses ((N,) floats) – masses of cloud particles

  • center ((3,) floats) – COM of point cloud

  • nb_pts (int) – number of points in select to consider

  • reduced (boolean) – whether or not reduced shape tensor (1/r^2 factor)

  • r_ell ((N,) floats) – semi-major axis a of the ellipsoid surface on which each particle lies (only if reduced == True)

Returns

shape tensor

Return type

(3,3) complex

cython_abs(x)[source]

Absolute value of float

Parameters

x (float) – float value of interest

Returns

absolute value

Return type

float

respectPBCNoRef(xyz, float L_BOX)[source]

Modify xyz inplace so that it respects the box periodicity.

If point distro xyz has particles separated in any Cartesian direction by more than L_BOX/2, reflect those particles along L_BOX/2

Parameters
  • xyz ((N^3x3) floats) – coordinates of particles of type 1 or type 4

  • L_BOX (float) – periodicity of box (0.0 if non-periodic)

Returns

updated coordinates of particles of type 1 or type 4

Return type

(N^3x3) floats