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

This example shows how to measure the projected two-point correlation function

// =========================================================================
// Example code: how to measure the projected two-point correlation function
// =========================================================================
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 = 3.; // random/data ratio
// --------------------------------------------------------------------------------------
// ---------------- measure the projected two-point correlation function ----------------
// --------------------------------------------------------------------------------------
// binning parameters and output data
const double rpMin = 10.; // minimum separation in the first dimension
const double rpMax = 30.; // maximum separation in the first dimension
const int nbins_D1 = 3; // number of bins in the first dimension
const double shift_D1 = 0.5; // spatial shift used to set the bin centre in the first dimension
const double piMin = 0.; // minimum separation in the second dimension
const double piMax = 50.; // maximum separation in the second dimension
const int nbins_D2 = 10; // number of bins in the second dimension
const double shift_D2 = 0.5; // spatial shift used to set the bin centre in the second dimension
const double piMax_integral = 50.; // upper limit of the integral
const std::string dir = "../output/";
const std::string file = "xi_projected.dat";
// measure the projected two-point correlation function
const auto TwoP = cbl::measure::twopt::TwoPointCorrelation::Create(cbl::measure::twopt::TwoPType::_projected_, catalogue, random_catalogue, cbl::BinType::_logarithmic_, rpMin, rpMax, nbins_D1, shift_D1, piMin, piMax, nbins_D2, shift_D2, piMax_integral);
TwoP->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 TwoPointCorrelation1D.
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
static std::shared_ptr< TwoPointCorrelation > Create(const TwoPType type, const catalogue::Catalogue data, const catalogue::Catalogue random, const BinType binType, const double Min, const double Max, const int nbins, const double shift, const CoordinateUnits angularUnits=CoordinateUnits::_radians_, std::function< double(double)> angularWeight=nullptr, const bool compute_extra_info=false, const double random_dilution_fraction=1.)
static factory used to construct two-point correlation functions of any type
@ _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.
@ _projected_
the projected two-point correlation function, w(rp)
@ _Poisson_
Poissonian error.
@ _observed_
observed coordinates (R.A., Dec, redshift)
@ _logarithmic_
logarithmic binning