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

This example shows how to how to measure the number counts of a catalogue, computing Poissonian errors

// =========================================================================================================================
// Example code: how to measure the number counts of a catalogue, i.e. the redshift distribution, computing Possonian errors
// =========================================================================================================================
#include "GlobalFunc.h"
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 sub-regions used for jackknife and bootstrap
std::cout << "I'm constructing the sub-regions used for jackknife and bootstrap..." << std::endl;
const int nCells_Ra = 3;
const int nCells_Dec = 3;
cbl::set_ObjectRegion_RaDec(catalogue, nCells_Ra, nCells_Dec);
// -------------------------------------------------------------------
// ---------------- measure the redshift distribution ----------------
// -------------------------------------------------------------------
// binning parameters and output data
const int nbin = 10;
const std::string dir = "../output/";
// measure the redshift distribution anc compute Poisson errors
// measure the number counts and compute Poissonian errors
NC.write(dir, "redshift_distribution_Poisson.dat");
// measure the number counts and compute Jackknife errors
NC.write(dir, "redshift_distribution_Jackknife.dat");
NC.write_covariance(dir, "redshift_distribution_Jackknife_covariance.dat");
// measure the number counts and compute Jackknife errors
NC.measure(cbl::measure::ErrorType::_Bootstrap_, dir+"Bootstrap/", 1000);
NC.write(dir, "redshift_distribution_Bootstrap.dat");
NC.write_covariance(dir, "redshift_distribution_Bootstrap_covariance.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 NumberCounts1D_Redshift.
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 ErrorType errorType=ErrorType::_Poisson_, const std::string dir_output_resample=par::defaultString, const int nResamplings=0, const int seed=3213, const bool conv=false, const double sigma=0.) override
measure the number counts
@ _Planck15_
Planck collaboration 2015, paper XIII: Table 4, TT,TE,EE+lowP+lensing.
@ _Bootstrap_
Bootstrap resampling.
@ _Poisson_
Poissonian error.
@ _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)