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

This example shows how to measure the angular power spectrum

// =======================================================================
// Example code: how to measure the angular power spectrum
// =======================================================================
#include "GlobalFunc.h"
using namespace std;
int main () {
try {
// --------------------------------------------------------------------
// ---------------- set the cosmological model to Planck15 ------------
// --------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------------
// -------------------- read the input catalogue (in observed coordinates, RA, Dec, Redshift) ----------------------
// -----------------------------------------------------------------------------------------------------------------
std::string file_catalogue = "../input/catalogue.csv";
std::vector<int> column = {1,2,3};
cbl::catalogue::Catalogue catalogue {cbl::catalogue::ObjectType::_Galaxy_, cbl::CoordinateType::_observed_, attribute, column, {file_catalogue}, 0, 1, 1, cosmology, angularUnits};
// ----------------------------------------------------------------
// ---------------- construct the random catalogue ----------------
// ----------------------------------------------------------------
const double N_R = 2.; // random/data ratio
std::cout << "I'm constructing the sub-regions used for jackknife and bootstrap..." << std::endl;
const int nRa = 3, nDec = 3;
cbl::set_ObjectRegion_RaDec(catalogue, random_catalogue, nRa, nDec);
// --------------------------------------------------------------------------------------------------
// ------------------ angular power spectrum: binning parameters and output data ---------------------
// --------------------------------------------------------------------------------------------------
double ell_min=18.; //minimum multipole, starts from 1 in fast estimator
double ell_max=21.; //maximum multipole
const int Nell=3; //number of multipoles
const std::string dir_output = "../output/";
// --------------------------------------------------------------------------------------------------
// ------ METHOD 1: fast estimator, using angular two-point correlation function --------------------
// --------------------------------------------------------------------------------------------------
const std::string dir_correlation_output="../../clustering/output/"; //output directory
const std::string file_correlation_output="xi_angular.dat"; //output file
const cbl::CoordinateUnits correlation_angular_Units = cbl::CoordinateUnits::_arcminutes_; // angular units
cbl::BinType power_spectrum_bintype = cbl::BinType::_linear_;
const std::string dir_correlation_input=""; //input directory (leave empty if you want to measure w(theta))
const std::string file_correlation_input=""; //input file (leave empty if you want to measure w(theta))
const int n_lines_header=1;
const cbl::CoordinateUnits inputUnits = cbl::CoordinateUnits::_arcminutes_; // angular units of the input file
const double angMin = 1; // minimum angular separation
const double angMax = 1000; // maximum angular separation
const int nbins = 100; // number of bins
const double shift = 0.5; // shift used to set the bin centre
// measure the angular power spectrum and store the results
cbl::measure::angularpk::PowerSpectrum_angular Pow{catalogue, random_catalogue, ell_min, ell_max, Nell, power_spectrum_bintype, angMin, angMax, nbins, shift, correlation_angular_Units, cbl::BinType::_linear_};
Pow.measure(estimator, dir_correlation_input, file_correlation_input, n_lines_header, inputUnits, correlation_bintype, cbl::measure::ErrorType::_Jackknife_, dir_correlation_output, file_correlation_output);
Pow.write(dir_output, "Cl_fast.dat");
// --------------------------------------------------------------------------------------------------
// ------------------------- METHOD 2: spherical armonic estimator ----------------------------------
// --------------------------------------------------------------------------------------------------
cbl::measure::angularpk::PowerSpectrum_angular Pow2{catalogue, ell_min, ell_max};
Pow2.measure(estimator);
Pow2.write(dir_output, "Cl_spherical_harmonic.dat");
}
catch(cbl::glob::Exception &exc) { std::cerr << exc.what() << std::endl; exit(1); }
return 0;
}
Generic functions that use one or more classes of the CosmoBolognaLib.
int main()
main function to create the logo of the CosmoBolognaLib
Definition: Logo.cpp:41
The class PowerSpectrum_angular.
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
void measure(const AngularEstimator estimator=AngularEstimator::_Fast_, const std::string dir_correlation_input="", const std::string file_correlation_input="", const int n_lines_header=1, CoordinateUnits inputUnits=CoordinateUnits::_arcminutes_, BinType input_binType=BinType::_logarithmic_, cbl::measure::ErrorType errorType=ErrorType::_Poisson_, const std::string dir_correlation_output=par::defaultString, const std::string file_correlation_output="xi_angular.dat", const int nMocks=0)
measure the angular power spectrum
@ _RA_
Right Ascension.
@ _Dec_
Declination.
@ _createRandom_square_
random catalogue with square geometry in observed coordinates (R.A., Dec)
@ _Planck15_
Planck collaboration 2015, paper XIII: Table 4, TT,TE,EE+lowP+lensing.
AngularEstimator
the angular two-point correlation estimator type
@ _SphericalArmonic_
the spherical armonic estimator
@ _Jackknife_
Jackknife resampling.
void set_ObjectRegion_RaDec(catalogue::Catalogue &data, const int nCells_Ra, const int nCells_Dec, const bool use_colatitude=true)
set the object region in angular SubBoxes
Definition: SubSample.cpp:498
@ _observed_
observed coordinates (R.A., Dec, redshift)
CoordinateUnits
the coordinate units
Definition: Kernel.h:562
@ _radians_
angle in radians
@ _arcminutes_
angle in arcminutes
BinType
the binning type
Definition: Kernel.h:505
@ _logarithmic_
logarithmic binning
@ _linear_
linear binning