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

This example shows how to model baryon acoustic oscillations in the monopole of the two-point correlation function

// ========================================================================================================================
// Example code: how to how to model the baryon acoustic oscillations in the monopole of the two-point correlation function
// ========================================================================================================================
#include "Data1D.h"
int main () {
try {
// ------------------------------------------------------------------------------------------
// ---------------- set the cosmological parameters (as in Anderson et al. 2013) ------------
// ------------------------------------------------------------------------------------------
const double hh = 0.7;
const double Omega_b = 0.0224/(hh*hh);
const double Omega_M = 0.274;
const double n_s = 0.96;
const double sigma8 = 0.8;
// ----------------------------------------------
// ------------- reading the dataset ------------
// ----------------------------------------------
const std::string dir_input = "../input/";
const std::string dir_output = "../output/";
const std::string dir_chains = dir_output+"chains/";
const std::string MK = "mkdir -p "+dir_output+" "+dir_chains; if (system(MK.c_str())) {}
const std::string file_xi = dir_input+"Anderson_2013_CMASSDR11_monopole_prerecon.dat";
const std::string file_cov = dir_input+"Anderson_2013_CMASSDR11_monopole_prerecon_cov.dat";
const int skipped_lines = 1;
const auto twop_dataset = std::make_shared<cbl::data::Data1D>(cbl::data::Data1D(file_xi, skipped_lines));
twop_dataset->set_covariance(file_cov);
// ------------------------------------------------------
// ------------- set the modelling structure ------------
// ------------------------------------------------------
// --------------------------------------------------------------------------
// ------------- set the underlying dark matter clustering model ------------
// --------------------------------------------------------------------------
const double redshift = 0.57;
const double sigmaNL = 8.;
model_twop.set_data_model(cosmology, redshift, "CAMB", sigmaNL, sigmaNL, false, 2.);
// -------------------------------------------------------
// ------------- set the priors and the model ------------
// -------------------------------------------------------
model_twop.set_model_BAO(alpha_prior, BB_prior, A0_prior, A1_prior, A2_prior);
// ----------------------------------------------------------------------
// ------------- run chains and write output chain and model ------------
// ----------------------------------------------------------------------
const int chain_size = 1000;
const int nwalkers = 100;
const std::string chain_file = "Anderson_2013_CMASSDR11_monopole_prerecon_chains.dat";
const double xmin = 40., xmax = 160.;
model_twop.set_fit_range(xmin, xmax);
model_twop.sample_posterior(chain_size, nwalkers);
const int burn_in = 100; // discard the first 100 chain steps
const int thin = 10; // take 1 step every 10
model_twop.show_results(burn_in, thin);
}
catch(cbl::glob::Exception &exc) { std::cerr << exc.what() << std::endl; exit(1); }
return 0;
}
The class Data1D.
int main()
main function to create the logo of the CosmoBolognaLib
Definition: Logo.cpp:41
The class Modelling_TwoPointCorrelation1D_monopole.
The class Cosmology.
Definition: Cosmology.h:277
void set_parameters(const std::vector< CosmologicalParameter > parameter, const std::vector< double > value)
set the value of some cosmological paramters
Definition: Cosmology.cpp:525
The class Data1D.
Definition: Data1D.h:51
The class Exception.
Definition: Exception.h:111
const char * what() const noexcept override
the error description
Definition: Exception.h:203
void show_results(const int start=0, const int thin=1, const int nbins=50, const bool show_mode=false, const int ns=-1)
show the results of the MCMC sampling on screen
Definition: Modelling.cpp:269
void set_likelihood(const statistics::LikelihoodType likelihood_type, const std::vector< size_t > x_index={0, 2}, const int w_index=-1, const double prec=1.e-10, const int Nres=-1)
set the likelihood function
Definition: Modelling.cpp:124
void sample_posterior(const int chain_size, const int nwalkers, const int seed=666, const double aa=2, const bool parallel=true)
sample the posterior, initializing the chains by drawing from the prior distributions
Definition: Modelling.cpp:187
void set_fit_range(const double xmin, const double xmax)
set the fit range
Definition: Modelling1D.cpp:46
void set_model_BAO(const statistics::PriorDistribution alpha_prior={}, const statistics::PriorDistribution bs8_prior={}, const statistics::PriorDistribution A0_prior={}, const statistics::PriorDistribution A1_prior={}, const statistics::PriorDistribution A2_prior={})
set the function to model the monopole of the two-point correlation function, taking into accout geom...
void set_data_model(const cbl::cosmology::Cosmology cosmology, const double redshift, const std::string method_Pk="CAMB", const double sigmaNL_perp=0., const double sigmaNL_par=0., const bool NL=true, const double bias=1., const double pimax=40., const double r_min=1., const double r_max=350., const double k_min=1.e-4, const double k_max=100., const int step=500, const std::string output_dir=par::defaultString, const std::string output_root="test", const int norm=-1, const double aa=0., const bool GSL=true, const double prec=1.e-3, const std::string file_par=par::defaultString, const double Delta=200., const bool isDelta_critical=true, const std::vector< double > cluster_redshift={}, const std::vector< double > cluster_mass_proxy={}, const std::vector< double > cluster_mass_proxy_error={}, const std::string model_bias="Tinker", const std::string meanType="mean_bias", const int seed=666, const cbl::cosmology::Cosmology cosmology_mass={}, const std::vector< double > redshift_source={})
set the data used to construct generic models of the two-point correlation function
The class PriorDistribution.
@ _sigma8_
: the power spectrum normalisation
@ _hh_
: the Hubble constant at z=0 divided by 100
@ _Omega_matter_LCDM_
: the density of baryons, cold dark matter and massive neutrinos (in units of the critical density) a...
@ _Omega_baryon_
: the baryon density at z=0
@ _n_spec_
: the primordial spectral index
@ _Uniform_
Identity function.
@ _Gaussian_Covariance_
Gaussian likelihood covariance.