CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
2pt_multipoles.cpp

This example shows how to measure the multipoles of the two-point correlation function using the "direct" and "integrated" method.

// ========================================================================
// Example code: how to measure the multipoles of the two-point correlation
// function, using the "direct" method and the "integrated" method
// ========================================================================
int main () {
try {
// -----------------------------------------------------------------
// ---------------- use default cosmological parameters ------------
// -----------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------
// ---------------- read the input catalogue (with observed coordinates: R.A., Dec, redshift) ----------------
// -----------------------------------------------------------------------------------------------------------
const std::string file_catalogue = "../input/cat.dat";
// --------------------------------------------------------------------------------------
// ---------------- construct the random catalogue (with cubic geometry) ----------------
// --------------------------------------------------------------------------------------
const double N_R = 10.; // random/data ratio
// --------------------------------------------------------------------------------------------
// ---------------- measure the multipoles of the two-point correlation function ----------------
// --------------------------------------------------------------------------------------------
// output directory
const std::string dir = "../output/";
// binning parameters and output data
const double rMin = 10.; // minimum separation
const double rMax = 30.; // maximum separation
const int nbins = 3; // number of bins
const double shift = 0.5; // spatial shift used to set the bin centre
// measure the multipoles using direct estimator
cbl::measure::twopt::TwoPointCorrelation_multipoles_direct TwoP_direct {catalogue, random_catalogue, cbl::BinType::_logarithmic_, rMin, rMax, nbins, shift};
TwoP_direct.measure(cbl::measure::ErrorType::_Poisson_, dir);
// store the output data
std::string file = "xil_direct.dat";
TwoP_direct.write(dir, file);
// measure the multipoles with integrated estimator
const double muMin = 0.;
const double muMax = 1.;
const int nbinsMu = 20;
cbl::measure::twopt::TwoPointCorrelation_multipoles_integrated TwoP_integrated {catalogue, random_catalogue, cbl::BinType::_logarithmic_, rMin, rMax, nbins, shift, muMin, muMax, nbinsMu, shift};
TwoP_integrated.measure(cbl::measure::ErrorType::_Poisson_, dir);
// store the output data
file = "xil_integrated.dat";
TwoP_integrated.write(dir, file);
}
catch(cbl::glob::Exception &exc) { std::cerr << exc.what() << std::endl; exit(1); }
return 0;
}
int main()
main function to create the logo of the CosmoBolognaLib
Definition: Logo.cpp:41
The class TwoPointCorrelation_multipoles_direct.
The class TwoPointCorrelation_multipoles_integrated.
The class Catalogue.
Definition: Catalogue.h:654
The class Cosmology.
Definition: Cosmology.h:277
The class Exception.
Definition: Exception.h:111
const char * what() const noexcept override
the error description
Definition: Exception.h:203
@ _createRandom_box_
random catalogue with cubic geometry (or parallelepiped) in comoving coordinates
@ _Planck15_
Planck collaboration 2015, paper XIII: Table 4, TT,TE,EE+lowP+lensing.
@ _Poisson_
Poissonian error.
@ _observed_
observed coordinates (R.A., Dec, redshift)
@ _logarithmic_
logarithmic binning