Density Profiling
Classes for Density Profiling
The dens_profs_classes
module defines the DensProfs
and DensProfsGadget
classes that provide density profiling capabilities. They inherit from the DensProfsBase
class (not relevant for the user).
- class dens_profs.dens_profs_classes.DensProfsBase[source]
Bases:
CosmicBase
Class for density profile calculations
Its public methods are
getR200()
,getIdxCat()
,getXYZMasses()
,getMassesCenters()
,_getMassesCenters()
,estDensProfs()
,fitDensProfs()
,estConcentrations()
,plotDensProfs()
,getObjInfo()
.- Parameters
xyz ((N2,3) floats, N2 >> N1) – positions of all simulation particles in Mpc/h (internal length units)
masses ((N2,) floats) – masses of all simulation particles in 10^10 M_sun/h
idx_cat ((N3,) integers) – contains indices of particles belonging to an object
r200 ((N1,) floats) – R_200 radii of the parent halos in Mpc/h (internal length units)
obj_size ((N1,) integers) – indicates how many particles are in each object
SNAP (string) – snapshot identifier, e.g. ‘024’
L_BOX (float) – simulation box side length in Mpc/h (internal length units)
MIN_NUMBER_PTCS (int) – minimum number of particles for object to qualify for morphology calculation
CENTER (str) – shape quantities will be calculated with respect to CENTER = ‘mode’ (point of highest density) or ‘com’ (center of mass) of each halo
VIZ_DEST (string) – visualization folder
CAT_DEST (string) – catalogue destination
SUFFIX (string) – either ‘_dm_’ or ‘_gx_’ or ‘_’ (latter for CosmicProfsDirect)
- __init__()[source]
- Parameters
xyz ((N2,3) floats, N2 >> N1) – positions of all simulation particles in Mpc/h (internal length units)
masses ((N2,) floats) – masses of all simulation particles in 10^10 M_sun/h
idx_cat ((N3,) integers) – contains indices of particles belonging to an object
r200 ((N1,) floats) – R_200 radii of the parent halos in Mpc/h (internal length units)
obj_size ((N1,) integers) – indicates how many particles are in each object
SNAP (string) – snapshot identifier, e.g. ‘024’
L_BOX (float) – simulation box side length in Mpc/h (internal length units)
MIN_NUMBER_PTCS (int) – minimum number of particles for object to qualify for morphology calculation
CENTER (str) – shape quantities will be calculated with respect to CENTER = ‘mode’ (point of highest density) or ‘com’ (center of mass) of each halo
VIZ_DEST (string) – visualization folder
CAT_DEST (string) – catalogue destination
SUFFIX (string) – either ‘_dm_’ or ‘_gx_’ or ‘_’ (latter for CosmicProfsDirect)
- estConcentrations()[source]
Get best-fit concentration values of objects from density profile fitting
- Parameters
dens_profs ((N3, r_res) floats) – density profiles whose concentrations are to be determined, in units of config.OutUnitMass_in_g/config.OutUnitLength_in_cm**3
r_over_r200 ((r_res,) floats) – normalized radii at which
dens_profs
are definedmethod (dictionary, method[‘profile’] is either einasto, alpha_beta_gamma, hernquist, nfw, minimum requirement) – describes density profile model assumed for fitting, if parameter should be kept fixed during fitting then it needs to be provided, e.g. method[‘alpha’] = 0.18
obj_numbers (list of int) – list of object indices of interest
- Returns
best-fit concentration for each object
- Return type
(N3,) floats
- estDensProfs()[source]
Estimate density profiles
- Parameters
r_over_r200 ((r_res,) floats) – normalized radii at which to-be-estimated density profiles are defined
obj_numbers (list of int) – list of object indices of interest
direct_binning (boolean) – whether or not direct binning approach or kernel-based approach should be used
spherical (boolean) – whether or not spherical shell-based or ellipsoidal shell-based should be used, ignored if
direct_binning
= Falsekatz_config (dictionary) – dictionary with parameters to the Katz algorithm, with fields ‘ROverR200’, ‘IT_TOL’, ‘IT_WALL’, ‘IT_MIN’, ‘REDUCED’, ‘SHELL_BASED’
- Returns
density profiles in units of config.OutUnitMass_in_g/config.OutUnitLength_in_cm**3
- Return type
(N2, r_res) floats
- fitDensProfs()[source]
Get best-fit results for density profile fitting
- Parameters
dens_profs ((N3, r_res) floats) – density profiles to be fit, in units of config.OutUnitMass_in_g/config.OutUnitLength_in_cm**3
r_over_r200 ((r_res,) floats) – normalized radii at which
dens_profs
are definedmethod (dictionary, method[‘profile’] is either einasto, alpha_beta_gamma, hernquist, nfw, minimum requirement) – describes density profile model assumed for fitting, if parameter should be kept fixed during fitting then it needs to be provided, e.g. method[‘alpha’] = 0.18
obj_numbers (list of int) – list of object indices of interest
- Returns
best-fits for each object
- Return type
structured array, containing (N3, n) floats, where n is the number of free parameters in the model
method
- getIdxCat()[source]
Fetch catalogue
- Return idx_cat
contains indices of particles belonging to an object, obj_size: number of particles in each object
- Return type
(N3) integers and (N1,) integers
- getMassesCenters()[source]
Calculate total mass and centers of objects
Note that the units will be in config.OutUnitLength_in_cm and config.OutUnitMass_in_g.
- Parameters
obj_numbers (list of int) – list of object indices of interest
- Return centers, m
centers in config.OutUnitLength_in_cm and masses in config.OutUnitMass_in_g
- Return type
structured array, containing (N,3) and (N,) floats
- getXYZMasses()[source]
Retrieve positions and masses of particles
- Return xyz, masses
positions in config.OutUnitLength_in_cm and masses in config.OutUnitMass_in_g
- Return type
(N2,3) floats, (N2,) floats
- plotDensProfs()[source]
Draws some simplistic density profiles
- Parameters
dens_profs ((N2, r_res) floats) – estimated density profiles, in units of config.OutUnitMass_in_g/config.OutUnitLength_in_cm**3
r_over_r200 ((r_res,) floats) – radii at which
dens_profs
are defineddens_profs_fit ((N2, r_res2) floats) – density profiles to be fit, in units of config.OutUnitMass_in_g/config.OutUnitLength_in_cm**3
r_over_r200_fit ((r_res2,) floats) – radii at which best-fits shall be calculated
method (dictionary, method[‘profile’] is either einasto, alpha_beta_gamma, hernquist, nfw, minimum requirement) – describes density profile model assumed for fitting, if parameter should be kept fixed during fitting then it needs to be provided, e.g. method[‘alpha’] = 0.18
nb_bins (int) – Number of mass bins to plot density profiles for
obj_numbers (list of int) – list of object indices of interest
- class dens_profs.dens_profs_classes.DensProfsGadget[source]
Bases:
DensProfsBase
- Parameters
xyz ((N2,3) floats, N2 >> N1) – positions of all simulation particles in Mpc/h (internal length units)
masses ((N2,) floats) – masses of all simulation particles in 10^10 M_sun/h
idx_cat ((N3,) integers) – contains indices of particles belonging to an object
r200 ((N1,) floats) – R_200 radii of the parent halos in Mpc/h (internal length units)
obj_size ((N1,) integers) – indicates how many particles are in each object
SNAP (string) – snapshot identifier, e.g. ‘024’
L_BOX (float) – simulation box side length in Mpc/h (internal length units)
MIN_NUMBER_PTCS (int) – minimum number of particles for object to qualify for morphology calculation
CENTER (str) – shape quantities will be calculated with respect to CENTER = ‘mode’ (point of highest density) or ‘com’ (center of mass) of each halo
VIZ_DEST (string) – visualization folder
CAT_DEST (string) – catalogue destination
SUFFIX (string) – either ‘_dm_’ or ‘_gx_’ or ‘_’ (latter for CosmicProfsDirect)
Density profile estimation algorithms
The dens_profs_algos
module contains the direct-binning and the kernel-based density profile estimation algorithms.
- dens_profs.dens_profs_algos.calcDensProfsEllDirectBinning(float[:, :] xyz, float[:] masses, float[:] r200s, float[:] ROverR200, float[:, :] a, float[:, :] b, float[:, :] c, float[:, :, :] major, float[:, :, :] inter, float[:, :, :] minor, int[:] idx_cat, int[:] obj_size, float L_BOX, unicode CENTER)[source]
Calculates ellipsoidal shell-based density profiles for objects defined by indices found in idx_cat
Note: To calculate enclosed mass profiles, envoke
CythonHelpers.calcMenclsBruteForceEll()
instead ofCythonHelpers.calcDensProfBruteForceEll()
- Parameters
xyz ((N2,3) floats, N2 >> N1) – positions of all simulation particles
masses ((N2,) floats) – masses of all simulation particles
r200s ((N1,) floats) – R200 values of the objects
ROverR200 ((r_res,) float array) – radii at which the density profiles should be calculated, normalized by R200
idx_cat ((N3,) integers) – contains indices of particles belonging to an object
obj_size ((N1,) integers) – indicates how many particles are in each object
L_BOX (float) – box size
CENTER (str) – density profiles will be calculated with respect to CENTER = ‘mode’ (point of highest density) or ‘com’ (center of mass) of each halo
a ((N1,D_BINS+1,) floats) – major axis eigenvalues
b ((N1,D_BINS+1,) floats) – intermediate axis eigenvalues
c ((N1,D_BINS+1,) floats) – minor axis eigenvalues
major ((N1,D_BINS+1,3) floats) – major axis eigenvectors
inter ((N1,D_BINS+1,3) floats) – inter axis eigenvectors
minor ((N1,D_BINS+1,3) floats) – minor axis eigenvectors
- Returns
density profiles defined at ROverR200
- Return type
(N1, r_res) float array
- dens_profs.dens_profs_algos.calcDensProfsKernelBased(float[:, :] xyz, float[:] masses, float[:] r200s, float[:] ROverR200, int[:] idx_cat, int[:] obj_size, float L_BOX, unicode CENTER)[source]
Calculates kernel-based density profiles for objects defined by indices found in idx_cat
Note: For background on this kernel-based method consult Reed et al. 2003, https://arxiv.org/abs/astro-ph/0312544.
- Parameters
xyz ((N2,3) floats, N2 >> N1) – positions of all simulation particles
masses ((N2,) floats) – masses of all simulation particles
r200s ((N1,) floats) – R200 values of the objects
ROverR200 ((r_res,) float array) – radii at which the density profiles should be calculated, normalized by R200
idx_cat ((N3,) integers) – contains indices of particles belonging to an object
obj_size ((N1,) integers) – indicates how many particles are in each object
L_BOX (float) – box size
CENTER (str) – density profiles will be calculated with respect to CENTER = ‘mode’ (point of highest density) or ‘com’ (center of mass) of each halo
- Returns
density profiles defined at ROverR200
- Return type
(N1, r_res) float array
- dens_profs.dens_profs_algos.calcDensProfsSphDirectBinning(float[:, :] xyz, float[:] masses, float[:] r200s, float[:] ROverR200, int[:] idx_cat, int[:] obj_size, float L_BOX, unicode CENTER)[source]
Calculates spherical shell-based density profiles for objects defined by indices found in idx_cat
Note: To calculate enclosed mass profiles, envoke
CythonHelpers.calcMenclsBruteForce()
instead ofCythonHelpers.calcDensProfBruteForce()
- Parameters
xyz ((N2,3) floats, N2 >> N1) – positions of all simulation particles
masses ((N2,) floats) – masses of all simulation particles
r200s ((N1,) floats) – R200 values of the objects
ROverR200 ((r_res,) float array) – radii at which the density profiles should be calculated, normalized by R200
idx_cat ((N3,) integers) – contains indices of particles belonging to an object
obj_size ((N1,) integers) – indicates how many particles are in each object
L_BOX (float) – box size
CENTER (str) – density profiles will be calculated with respect to CENTER = ‘mode’ (point of highest density) or ‘com’ (center of mass) of each halo
- Returns
density profiles defined at ROverR200
- Return type
(N1, r_res) float array
- dens_profs.dens_profs_algos.calcMassesCenters(float[:, :] xyz, float[:] masses, int[:] idx_cat, int[:] obj_size, float L_BOX, unicode CENTER)[source]
Calculate total mass and centers of objects
- Parameters
xyz ((N2,3) floats, N2 >> N1) – positions of all simulation particles
masses ((N2,) floats) – masses of all simulation particles
idx_cat ((N3,) integers) – contains indices of particles belonging to an object
obj_size ((N1,) integers) – indicates how many particles are in each object
L_BOX (float) – box size
CENTER (str) – density profiles will be calculated with respect to CENTER = ‘mode’ (point of highest density) or ‘com’ (center of mass) of each halo
- Return centers, m
centers and masses
- Return type
(N,3) and (N,) floats
Density profile fitting and plotting
The dens_profs_tools
module provides density profile models such as the NFW profile as well as density profile fitting and plotting tools.
- dens_profs.dens_profs_tools.drawDensProfs(VIZ_DEST, SNAP, r200s, dens_profs_fit, ROverR200_fit, dens_profs, ROverR200, obj_masses, obj_centers, method, nb_bins, start_time, MASS_UNIT, suffix='_')[source]
Create a series of plots to analyze object shapes
Plot intertial tensor axis ratios, triaxialities and ellipticity histograms.
- Parameters
VIZ_DEST (string) – visualisation folder destination
SNAP (string) – e.g. ‘024’
r200s (N2-long float array) – catalogue of virial radii (of parent halos) in Mpc/h
dens_profs_fit ((N, r_res2) floats) – density profiles, defined at
ROverR200
, in M_sun*h^2/(Mpc)**3ROverR200_fit ((r_res2,) floats) – normalized radii at which the mass-decomposed density profile fits shall be calculated
dens_profs ((N, r_res1) floats) – density profiles, defined at
ROverR200
, in M_sun*h^2/(Mpc)**3ROverR200 ((N, r_res1) floats) – normalized radii at which
dens_profs
are definedobj_masses ((N,) floats) – masses of objects in 10^10*M_sun/h
obj_centers ((N,3) floats) – centers of objects, each coordinate in Mpc/h
method (dictionary, method[‘profile’] is either einasto, alpha_beta_gamma, hernquist, nfw, minimum requirement) – describes density profile model assumed for fitting, if parameter should be kept fixed during fitting then it needs to be provided, e.g. method[‘alpha’] = 0.18
nb_bins (int) – Number of mass bins to plot density profiles for
start_time (float) – time of start of shape analysis
MASS_UNIT (float) – conversion factor from previous mass unit to M_sun/h, usually 10^10
suffix (string) – either ‘_dm_’ or ‘_gx_’ or ‘_’ (latter for CosmicProfsDirect)
- dens_profs.dens_profs_tools.fitDensProf(ROverR200, method, median_r200_obj_nb)[source]
Fit density profile according to model provided
Note that
median
which is defined atROverR200
must be in units of M_sun*h^2/(Mpc)**3.r200
must be in units of Mpc/h.- Parameters
ROverR200 ((N,) floats) – normalized radii where
median
is defined and fitting should be carried outmethod (dictionary, method[‘profile’] is either einasto, alpha_beta_gamma, hernquist, nfw, minimum requirement) – describes density profile model assumed for fitting, if parameter should be kept fixed during fitting then it needs to be provided, e.g. method[‘alpha’] = 0.18
median_r200_obj_nb (tuple of (N,) floats, float, int) – density profile (often a median of many profiles combined, in units of M_sun*h^2/(Mpc)**3), virial radius (of parent halo in units of Mpc/h) and object number
- Return best_fit, obj_nb
best-fit results, object number
- Return type
(n,) floats, int
- dens_profs.dens_profs_tools.fitDensProfHelper(dens_profs, ROverR200, r200s, method)[source]
Helper function to carry out density profile fitting
- Parameters
dens_profs ((N,r_res) floats) – array containing density profiles in units of M_sun*h^2/(Mpc)**3
ROverR200 ((r_res,) floats) – normalized radii where density profile is defined and fitting should be carried out
r200s ((N,) floats) – R200 values of parent halos in units of Mpc/h
method (dictionary, method[‘profile’] is either einasto, alpha_beta_gamma, hernquist, nfw, minimum requirement) – describes density profile model assumed for fitting, if parameter should be kept fixed during fitting then it needs to be provided, e.g. method[‘alpha’] = 0.18
- Return best_fits
best-fit results
- Return type
(N,n) floats
- dens_profs.dens_profs_tools.getAlphaBetaGammaProf(r, model_pars)[source]
Get alpha-beta-gamma density profile at radius
r
- Parameters
r (float) – radius of interest
model_pars ((n,) float array) – model parameters
- Returns
profile value at
r
- Return type
float
- dens_profs.dens_profs_tools.getEinastoProf(r, model_pars)[source]
Get Einasto density profile at radius
r
- Parameters
r (float) – radius of interest
model_pars ((n,) float array) – model parameters
- Returns
profile value at
r
- Return type
float