CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
cbl::measure::stackprofile::StackedDensityProfile Class Reference

The class StackedDensityProfile. More...

#include <StackedDensityProfile.h>

Inheritance diagram for cbl::measure::stackprofile::StackedDensityProfile:
Collaboration diagram for cbl::measure::stackprofile::StackedDensityProfile:

Public Member Functions

Constructors/destructors
 StackedDensityProfile ()=default
 default constructor
 
virtual ~StackedDensityProfile ()=default
 default destructor
 
 StackedDensityProfile (cosmology::Cosmology cosm, const catalogue::Catalogue gal_cat, const catalogue::Catalogue clu_cat, const double delta_redshift, std::vector< double > z_binEdges, std::vector< std::vector< double >> proxy_binEdges, const double rad_min, const double rad_max, const int nRad, const bool log_rad, const double SN_min, const double pix_size, const std::vector< std::vector< double >> multiplicative_calibration_stats={}, const std::vector< std::vector< double >> multiplicative_calibration_zEdges={}, const double rad_alpha=1., const double obs_gamma=1.)
 constructor performing the stacking by reading a .fits galaxy file and a cluster file More...
 
Member functions to measure the stacked profile
void set_colour_selection (const std::string colour_space, const int z_bin, const double C1, const double C2, const double C3, const double C4, const double z_min)
 Set the colour selection in the i-th cluster redshift bin. More...
 
void set_colour_selection (const std::string colour_space, const double C1, const double C2, const double C3, const double C4, const double z_min)
 Set the colour selection in all cluster redshift bins. More...
 
void set_zphot_selection (const int z_bin, const double deltaz, const double zgal_min, const double zgal_max, const double ODDS_min)
 Set the redshift selection in the i-th cluster redshift bin. More...
 
void set_zphot_selection (const double deltaz, const double zgal_min, const double zgal_max, const double ODDS_min)
 Set the redshift selection in all cluster redshift bins. More...
 
void set_logic_selection (const int z_bin, const std::string sel)
 Set the logic operator linking redshift and colour selections in the i-th cluster redshift bin. More...
 
void set_logic_selection (const std::string sel)
 Set the logic operator linking redshift and colour selections in the all the cluster redshift bins. More...
 
void measure (const std::vector< int > z_proxy_bin, const std::string output_dir, const std::string output_file_root, const ErrorType errorType=ErrorType::_Bootstrap_, const int n_resampling=10000, const bool write_background=false)
 measure the stacked profiles in all the bins of redshift and mass proxy, providing in output the stacked profile in the redshift and proxy bins chosen through the parameter z_proxy_bin. More...
 
input/output member functions (customized in all the derived classes)
void write (const std::string dir, const std::string file)
 write on file the measure in a given bin of redshift and mass proxy More...
 
- Public Member Functions inherited from cbl::measure::Measure
 Measure ()=default
 default constructor
 
virtual ~Measure ()=default
 default destructor
 
virtual std::shared_ptr< data::Datadataset () const
 get the protected member dataset More...
 

Protected member functions and members to measure the cluster stacked density profile

and the relative covariance matrix

bool m_write_background
 if true, create the folder containing the background galaxies indices
 
std::shared_ptr< cosmology::Cosmologym_cosm
 input cosmology
 
std::shared_ptr< catalogue::Cataloguem_galData
 input galaxy catalogue
 
std::shared_ptr< catalogue::Cataloguem_cluData
 input cluster catalogue
 
std::vector< bool(StackedDensityProfile::*)(const int, const int)> m_colourSel
 vector of pointers to the colour selection function s
 
std::vector< bool(StackedDensityProfile::*)(const int, const int, const int)> m_photzSel
 vector of pointers to the photo-z selection functions
 
std::vector< std::function< bool(const std::vector< bool >)> > m_logicSel
 logic operator between colour and photo-z selection
 
std::vector< bool > m_isSet_colourSel
 vector for checking if the colour selection is set in all the z bins
 
std::vector< bool > m_isSet_photzSel
 vector for checking if the photo-z selection is set in all the z bins
 
std::vector< bool > m_isSet_logicSel
 vector for checking if the logic selection linking colour and z selections is set in all the z bins
 
std::vector< std::vector< int > > m_background_idx_z
 vector of indices of the background galaxies selected through the redshift selection
 
std::vector< std::vector< int > > m_background_idx_colour
 vector of indices of the background galaxies selected through the colour selection
 
bool m_measure_is_read
 bool stating if the measure is read from file
 
double m_delta_redshift
 minimum interval between the cluster and the source redshifts
 
double m_SN_min
 minimum signal-to-noise
 
double m_pix_size
 pixel size (in deg)
 
std::vector< std::vector< double > > m_m_calib
 the multiplicative calibration bias mean and standard deviation in the z bins
 
std::vector< std::vector< double > > m_m_calib_zEdges
 the redshift edges within which the multiplicative calibration bias is evaluated
 
double m_n_resampling
 number of regions for the resampling
 
std::vector< std::string > m_inputs_to_str
 vector of the inputs stored as strings
 
double m_rad_alpha
 slope for the observable weighted mean
 
double m_obs_gamma
 gamma slope for lensing-weighted observables
 
std::vector< std::vector< double > > m_colour_sel_pars
 the parameters for the colour selection
 
std::vector< std::vector< double > > m_zphot_sel_pars
 the parameters for the redshift selection
 
std::vector< std::vector< std::string > > m_logic_sel_par
 the logic selection linking redshift and colour selections
 
std::vector< double > m_rad_arr
 radius bin edges
 
std::vector< double > m_z_binEdges
 phot-z bin edges
 
std::vector< std::vector< double > > m_proxy_binEdges
 mass proxy bin edges
 
std::vector< std::vector< int > > m_first
 a "first" for each pixel
 
std::vector< std::vector< int > > m_last
 a "last" for each pixel
 
std::vector< int > m_next
 a "next" for each galaxy
 
std::vector< std::vector< double > > m_nClu_inBin
 number of clusters in a bin of z and mass proxy
 
std::vector< int > m_ngal_arr
 number of galaxies for annulus
 
std::vector< std::vector< std::vector< std::vector< int > > > > m_single_ngal_arr
 number of galaxies for annulus for cluster
 
std::vector< std::vector< std::vector< int > > > m_stacked_ngal_arr
 stacked number of galaxies for annulus
 
std::vector< double > m_deltasigma_t
 tangential surface density
 
std::vector< std::vector< std::vector< std::vector< double > > > > m_single_deltasigma_t
 tangential surface density, stored for each single cluster
 
std::vector< std::vector< std::vector< double > > > m_stacked_deltasigma_t
 tangential stacked surface density
 
std::vector< std::vector< std::vector< double > > > m_stacked_deltasigma_t_err
 tangential stacked surface density error
 
std::vector< double > m_deltasigma_x
 cross surface density
 
std::vector< std::vector< std::vector< std::vector< double > > > > m_single_deltasigma_x
 cross surface density, stored for each single cluster
 
std::vector< std::vector< std::vector< double > > > m_stacked_deltasigma_x
 cross stacked surface density
 
std::vector< std::vector< std::vector< double > > > m_stacked_deltasigma_x_err
 cross stacked surface density error
 
std::vector< double > m_deltasigma_err
 error on the surface density
 
std::vector< std::vector< std::vector< std::vector< double > > > > m_single_deltasigma_err
 error on the surface density, stored for each single cluster
 
std::vector< std::vector< std::vector< double > > > m_stacked_deltasigma_err
 error on the stacked surface density
 
std::vector< double > m_wetasquareSum
 wetasquareSum
 
std::vector< std::vector< std::vector< double > > > m_stacked_wetasquareSum
 stacked wetasquareSum
 
std::vector< double > m_wSum
 wSum
 
std::vector< std::vector< std::vector< double > > > m_stacked_wSum
 stacked wSum
 
std::vector< double > m_wetaSum
 wetaSum
 
std::vector< std::vector< std::vector< double > > > m_stacked_wetaSum
 stacked wetaSum
 
std::vector< double > m_deltasigmaSum
 deltasigmaSum
 
std::vector< std::vector< std::vector< double > > > m_stacked_deltasigmaSum
 stacked deltasigmaSum
 
std::vector< std::vector< std::vector< double > > > m_stacked_deltasigma_wei
 stacked deltasigma_wei
 
std::vector< double > m_rad_eff_arr
 effective radii
 
std::vector< std::vector< std::vector< double > > > m_stacked_rad_eff_arr
 stacked effective radii
 
std::vector< double > m_rad_sigma_arr
 effective radii errors
 
std::vector< std::vector< std::vector< double > > > m_stacked_rad_sigma_arr
 stacked effective radii errors
 
double m_sigma_fac
 constant factor for lensing quantities (c*c/(4piG) in M_sun/Mpc)
 
double m_ra_start
 starting RA
 
double m_dec_start
 starting Dec
 
std::vector< int > m_nPix
 number of pixels in RA and Dec
 
std::vector< std::vector< double > > m_proxy_eff
 effective mass proxy linked to the stacked signal
 
std::vector< std::vector< double > > m_proxy_sigma
 error on the effective mass proxy linked to the stacked signal
 
std::vector< std::vector< double > > m_z_eff
 effective redshift linked to the stacked signal
 
std::vector< std::vector< double > > m_z_sigma
 error on the effective redshift linked to the stacked signal
 
std::vector< std::vector< std::vector< std::vector< double > > > > m_deltasigma_cov_matr
 Bootstrap covariance matrix for the stacked signal.
 
void m_set_multiplicative_calib ()
 set the multiplicative shear calibration, m
 
bool m_colourSelection_gri (const int i_gal, const int clu_zbin)
 colour selection function in the colour-colour space ( \(r-i\)) vs ( \(g-r\)) More...
 
bool m_photzSelection (const int i_clu, const int i_gal, const int clu_zbin)
 redshift selection function More...
 
void m_check_catalogue_variables ()
 check if all the necessary variables in the galaxy and cluster catalogues are set
 
void m_resize (const double rad_min, const double rad_max, const int nRad, const bool log_rad)
 resize the private member arrays More...
 
void m_linked_list ()
 linked galaxy list
 
void m_add_galaxy (const int i_gal, const int clu_index, const double coscludec, const double clu_dist)
 add galaxies to profiles More...
 
void m_profile (const int clu_index)
 compute a single cluster profile More...
 
void m_stacker ()
 perform the stacking
 
std::shared_ptr< data::Datam_make_bootstrap (const std::vector< int > z_proxy_bin)
 bootstrap resampling to retrieve the covariance matrix of the stacked signal, providing the stacked profile measurement in output More...
 
bool m_check_file (const std::string checked_file, const std::vector< int > z_proxy_bin)
 check if the results obtained from the stacking have already been written to a file More...
 
void m_write (const std::string output_dir, const std::string output_file)
 write the results obtained from the stacking on file More...
 

Additional Inherited Members

- Protected Attributes inherited from cbl::measure::Measure
std::shared_ptr< data::Datam_dataset
 the dataset of the measure
 

Detailed Description

The class StackedDensityProfile.

"Headers/StackedDensityProfile.h"

Class used to measure the stacked surface density profiles of galaxy clusters, i.e. \(\Delta\Sigma(r)\) [ \(h\) M \(_\odot\)/pc \(^2\)]. Cosmological units are forced.

Definition at line 70 of file StackedDensityProfile.h.

Constructor & Destructor Documentation

◆ StackedDensityProfile()

cbl::measure::stackprofile::StackedDensityProfile::StackedDensityProfile ( cosmology::Cosmology  cosm,
const catalogue::Catalogue  gal_cat,
const catalogue::Catalogue  clu_cat,
const double  delta_redshift,
std::vector< double >  z_binEdges,
std::vector< std::vector< double >>  proxy_binEdges,
const double  rad_min,
const double  rad_max,
const int  nRad,
const bool  log_rad,
const double  SN_min,
const double  pix_size,
const std::vector< std::vector< double >>  multiplicative_calibration_stats = {},
const std::vector< std::vector< double >>  multiplicative_calibration_zEdges = {},
const double  rad_alpha = 1.,
const double  obs_gamma = 1. 
)

constructor performing the stacking by reading a .fits galaxy file and a cluster file

Parameters
cosmcosmological model
gal_catcatalogue of galaxies
clu_catcatalogue of galaxy clusters
delta_redshiftminimum interval between the cluster and the source redshifts. That is, it is \(\Delta_z\) in the equation \(z_g>z_c+\Delta_z\), where \(z_g\) and \(z_c\) are the galaxy and cluster mean redshifts, respectively. This condition must be satisfied along with \(p(z)\) or/and color conditions.
z_binEdgesredshift bin edges
proxy_binEdgesproxy bin edges
rad_minminimum distance from the cluster centre considered (in Mpc/h)
rad_maxmaximum distance from the cluster centre considered (in Mpc/h)
nRadnumber of cluster radial bins
log_radif true, the radial bins are logarithmically spaced. Otherwise, a linear binning is used
SN_minminimum signal-to-noise considered for the clusters
pix_sizepixel size in deg
multiplicative_calibration_statsa vector of vectors containing mean and standard deviation of the multiplicative shear calibration parameter, usually denoted as m, in all the redshift bins where it is evaluated. If not provided, the galaxy-by-galaxy values of m are used
multiplicative_calibration_zEdgesvector of vectors containing the lower and upper edge of the redshift bins for each estimate of the multiplicative shear calibration parameter, m
rad_alphaslope for the observable weighted mean
obs_gammagamma slope for lensing-weighted observables

Cluster stacked density profile

Definition at line 882 of file StackedDensityProfile.cpp.

Member Function Documentation

◆ m_add_galaxy()

void cbl::measure::stackprofile::StackedDensityProfile::m_add_galaxy ( const int  i_gal,
const int  clu_index,
const double  coscludec,
const double  clu_dist 
)
protected

add galaxies to profiles

Parameters
i_galgalaxy index
clu_indexcluster index
coscludeccos of cluster Dec
clu_distcluster angular diameter distance

Definition at line 275 of file StackedDensityProfile.cpp.

◆ m_check_file()

bool cbl::measure::stackprofile::StackedDensityProfile::m_check_file ( const std::string  checked_file,
const std::vector< int >  z_proxy_bin 
)
protected

check if the results obtained from the stacking have already been written to a file

Parameters
checked_filethe file to be checked
z_proxy_binvector containing the redshift and proxy bins to be stored, respectively
Returns
true if the stacking file already exists

Definition at line 538 of file StackedDensityProfile.cpp.

◆ m_colourSelection_gri()

bool cbl::measure::stackprofile::StackedDensityProfile::m_colourSelection_gri ( const int  i_gal,
const int  clu_zbin 
)
protected

colour selection function in the colour-colour space ( \(r-i\)) vs ( \(g-r\))

Parameters
i_galgalaxy index
clu_zbinindex of the redshift bin of the lensing cluster
Returns
true if the galaxy satisfies the conditions, otherwise it returns false

Definition at line 212 of file StackedDensityProfile.cpp.

◆ m_make_bootstrap()

std::shared_ptr< data::Data > cbl::measure::stackprofile::StackedDensityProfile::m_make_bootstrap ( const std::vector< int >  z_proxy_bin)
protected

bootstrap resampling to retrieve the covariance matrix of the stacked signal, providing the stacked profile measurement in output

Parameters
z_proxy_binvector containing the redshift and proxy bins to be stored, respectively
Returns
a shared pointer to Data

Definition at line 477 of file StackedDensityProfile.cpp.

◆ m_photzSelection()

bool cbl::measure::stackprofile::StackedDensityProfile::m_photzSelection ( const int  i_clu,
const int  i_gal,
const int  clu_zbin 
)
protected

redshift selection function

Parameters
i_clucluster index
i_galgalaxy index
clu_zbinindex of the redshift bin of the lensing cluster
Returns
true if the galaxy satisfies the conditions, otherwise it returns false

Definition at line 225 of file StackedDensityProfile.cpp.

◆ m_profile()

void cbl::measure::stackprofile::StackedDensityProfile::m_profile ( const int  clu_index)
protected

compute a single cluster profile

Parameters
clu_indexcluster index

Definition at line 346 of file StackedDensityProfile.cpp.

◆ m_resize()

void cbl::measure::stackprofile::StackedDensityProfile::m_resize ( const double  rad_min,
const double  rad_max,
const int  nRad,
const bool  log_rad 
)
protected

resize the private member arrays

Parameters
rad_minminimum distance from the cluster centre considered
rad_maxmaximum distance from the cluster centre considered
nRadnumber of cluster radial bins
log_radif true radial bins logarithmically spaced

Definition at line 57 of file StackedDensityProfile.cpp.

◆ m_write()

void cbl::measure::stackprofile::StackedDensityProfile::m_write ( const std::string  output_dir,
const std::string  output_file 
)
protected

write the results obtained from the stacking on file

Parameters
output_diroutput directory
output_fileoutput file

Definition at line 636 of file StackedDensityProfile.cpp.

◆ measure()

void cbl::measure::stackprofile::StackedDensityProfile::measure ( const std::vector< int >  z_proxy_bin,
const std::string  output_dir,
const std::string  output_file_root,
const ErrorType  errorType = ErrorType::_Bootstrap_,
const int  n_resampling = 10000,
const bool  write_background = false 
)

measure the stacked profiles in all the bins of redshift and mass proxy, providing in output the stacked profile in the redshift and proxy bins chosen through the parameter z_proxy_bin.

Note that with this function the stacking is performed in all the redshift and proxy bins, and the results are written on file. In the first line of the header of such file, all the parameters used for the stacking (colour and redshift selections, binnings, ...) are written, as well as the cosmological parameters. If such a file has already been written, the code reads it instead of performing again the stacking procedure.

In addition, this function creates the following folders:

  • covariance/: it contains \(N\) files, where \(N\) is the number of redshift-proxy bins. Each file name contains a string of two integers (e.g. "00"), where the first integer corresponds to the index of the redshift bin, while the second integer represents the index of the proxy bin.
  • background_galaxies/: created if write_background is set to true. This folder contains sub-folders, one for each redshift bin. In such folders, two files are stored: one containing the indices of the galaxies selected with the redshift selection, while the second file contains the indices of those galaxies selected through the colour selection. Such indices correspond to those of the input catalogue of galaxies, and start from 0.
Parameters
z_proxy_binvector containing the indices of the redshift and proxy bins to be stored, respectively
output_diroutput directory for the output_file
output_file_rootroot name of the output file, which contains the stacked profiles in all the redshift and mass proxy bins
errorTypethe type of error assigned to the density profile (only the diagonal of the covariance matrix is considered)
n_resamplingnumber of resampling regions for the bootstrap procedure used to evaluate the uncertainty on \(\Delta\Sigma(r)\)
write_backgroundif true, create the background_galaxies/ folder. WARNING: this folder may be very large

Definition at line 836 of file StackedDensityProfile.cpp.

◆ set_colour_selection() [1/2]

void cbl::measure::stackprofile::StackedDensityProfile::set_colour_selection ( const std::string  colour_space,
const double  C1,
const double  C2,
const double  C3,
const double  C4,
const double  z_min 
)

Set the colour selection in all cluster redshift bins.

Parameters
colour_spacethe colour space; possibilities are: "ri_gr" ( \(r-i\) vs \(g-r\))
C1for example, for the colour space \((r-i)\) vs \((g-r)\), it is \(C_1\) in \( (g-r)<C_1 \)
C2for example, for the colour space \((r-i)\) vs \((g-r)\), it is \(C_2\) in \( (r-i)>C_2 \)
C3for example, for the colour space \((r-i)\) vs \((g-r)\), it is \(C_3\) in \( (r-i)>C_3*(g-r)+C_4 \)
C4for example, for the colour space \((r-i)\) vs \((g-r)\), it is \(C_4\) in \( (r-i)>C_3*(g-r)+C_4 \)
z_minminimum redshift of the selected galaxies

Definition at line 767 of file StackedDensityProfile.cpp.

◆ set_colour_selection() [2/2]

void cbl::measure::stackprofile::StackedDensityProfile::set_colour_selection ( const std::string  colour_space,
const int  z_bin,
const double  C1,
const double  C2,
const double  C3,
const double  C4,
const double  z_min 
)

Set the colour selection in the i-th cluster redshift bin.

Parameters
colour_spacethe colour space; possibilities are: "ri_gr" ( \(r-i\) vs \(g-r\))
z_binindex of the cluster redshift bin
C1for example, for the colour space \((r-i)\) vs \((g-r)\), it is \(C_1\) in \( (g-r)<C_1 \)
C2for example, for the colour space \((r-i)\) vs \((g-r)\), it is \(C_2\) in \( (r-i)>C_2 \)
C3for example, for the colour space \((r-i)\) vs \((g-r)\), it is \(C_3\) in \( (r-i)>C_3*(g-r)+C_4 \)
C4for example, for the colour space \((r-i)\) vs \((g-r)\), it is \(C_4\) in \( (r-i)>C_3*(g-r)+C_4 \)
z_minminimum redshift of the selected galaxies

Definition at line 749 of file StackedDensityProfile.cpp.

◆ set_logic_selection() [1/2]

void cbl::measure::stackprofile::StackedDensityProfile::set_logic_selection ( const int  z_bin,
const std::string  sel 
)

Set the logic operator linking redshift and colour selections in the i-th cluster redshift bin.

Parameters
z_binindex of the cluster redshift bin
sel"and" or "or"

Definition at line 797 of file StackedDensityProfile.cpp.

◆ set_logic_selection() [2/2]

void cbl::measure::stackprofile::StackedDensityProfile::set_logic_selection ( const std::string  sel)

Set the logic operator linking redshift and colour selections in the all the cluster redshift bins.

Parameters
sel"and" or "or"

Definition at line 828 of file StackedDensityProfile.cpp.

◆ set_zphot_selection() [1/2]

void cbl::measure::stackprofile::StackedDensityProfile::set_zphot_selection ( const double  deltaz,
const double  zgal_min,
const double  zgal_max,
const double  ODDS_min 
)

Set the redshift selection in all cluster redshift bins.

Parameters
deltazadditive term, \(\Delta z\), to the cluster redshift, i.e. how much the minimum galaxy redshift, \(z_{\rm g,\,min}\), (in the tail of the relative posterior) must be higher than the cluster redshift, \(z_c\), that is \(z_{\rm g,\,min} > z_c+\Delta z\)
zgal_minminimum value for the galaxy mean redshift
zgal_maxmaximum value for the galaxy mean redshift
ODDS_minminimum value for the ODDS parameter

Definition at line 789 of file StackedDensityProfile.cpp.

◆ set_zphot_selection() [2/2]

void cbl::measure::stackprofile::StackedDensityProfile::set_zphot_selection ( const int  z_bin,
const double  deltaz,
const double  zgal_min,
const double  zgal_max,
const double  ODDS_min 
)

Set the redshift selection in the i-th cluster redshift bin.

Parameters
z_binindex of the cluster redshift bin
deltazadditive term, \(\Delta z\), to the cluster redshift, i.e. how much the minimum galaxy redshift, \(z_{\rm g,\,min}\), (in the tail of the relative posterior) must be higher than the cluster redshift, \(z_c\), that is \(z_{\rm g,\,min} > z_c+\Delta z\)
zgal_minminimum value for the galaxy mean redshift
zgal_maxmaximum value for the galaxy mean redshift
ODDS_minminimum value for the ODDS parameter

Definition at line 775 of file StackedDensityProfile.cpp.

◆ write()

void cbl::measure::stackprofile::StackedDensityProfile::write ( const std::string  dir,
const std::string  file 
)

write on file the measure in a given bin of redshift and mass proxy

Parameters
diroutput directory
filename of the output file

Definition at line 870 of file StackedDensityProfile.cpp.


The documentation for this class was generated from the following files: