CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
Modelling_NumberCounts1D_Mass.cpp
Go to the documentation of this file.
1 /********************************************************************
2  * Copyright (C) 2016 by Federico Marulli and Alfonso Veropalumbo *
3  * federico.marulli3@unibo.it *
4  * *
5  * This program is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU General Public License as *
7  * published by the Free Software Foundation; either version 2 of *
8  * the License, or (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public *
16  * License along with this program; if not, write to the Free *
17  * Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ********************************************************************/
20 
39 
40 using namespace std;
41 
42 using namespace cbl;
43 
44 using namespace modelling::numbercounts;
45 
46 
47 // ===========================================================================================
48 
49 
50 void cbl::modelling::numbercounts::Modelling_NumberCounts1D_Mass::set_data_model_snapshot (const cosmology::Cosmology cosmology, const double redshift, const std::string method_Pk, const double k_min, const double k_max, const int step, const int norm, const double Delta, const bool isDelta_critical, const std::string model_MF, const double Volume, const double Mass_min, const double Mass_max, const int Mass_step, const double prec)
51 {
52  m_data_model.isSnapshot = true;
53 
54  m_data_model.cosmology = make_shared<cosmology::Cosmology>(cosmology);
55  m_data_model.redshift = redshift;
56  m_data_model.method_Pk = method_Pk;
57  m_data_model.k_min = k_min;
58  m_data_model.k_max = k_max;
59  m_data_model.step = step;
60  m_data_model.kk = logarithmic_bin_vector(step, k_min, k_max);
61  m_data_model.norm = norm;
62 
63  m_data_model.output_root = "test";
64  m_data_model.file_par = par::defaultString;
65 
66  m_data_model.isDelta_critical = isDelta_critical;
67  m_data_model.Delta = Delta;
68  m_data_model.model_MF = model_MF;
69 
70  m_data_model.Volume = Volume;
71 
72  m_data_model.Mass_min = Mass_min;
73  m_data_model.Mass_max = Mass_max;
74  m_data_model.Mass_step = Mass_step;
75  m_data_model.Mass_vector = logarithmic_bin_vector(200, 1.e10, 1.e16);
76 
77  m_data_model.prec = prec;
78 }
79 
80 
81 // ===========================================================================================
82 
83 
84 void cbl::modelling::numbercounts::Modelling_NumberCounts1D_Mass::set_model_NumberCounts_cosmology (const std::vector<cbl::cosmology::CosmologicalParameter> cosmo_param, const std::vector<statistics::PriorDistribution> cosmo_param_prior)
85 {
86  m_data_model.Cpar = cosmo_param;
87 
88  const size_t nParams = cosmo_param.size();
89 
90  vector<statistics::ParameterType> cosmoPar_type(nParams, statistics::ParameterType::_Base_);
91  vector<string> cosmoPar_string(nParams);
92 
93  for (size_t i=0; i<nParams; i++)
94  cosmoPar_string[i] = CosmologicalParameter_name(cosmo_param[i]);
95 
96  // input data used to construct the model
97  auto inputs = make_shared<STR_NC_data_model>(m_data_model);
98 
99  // set prior
100  m_set_prior(cosmo_param_prior);
101 
102  // construct the model
103  switch (m_HistogramType) {
104 
105  case (glob::HistogramType::_N_V_):
106  if (m_data_model.isSnapshot == true)
107  m_model = make_shared<statistics::Model1D>(statistics::Model1D(&number_counts_mass_snapshot, nParams, cosmoPar_type, cosmoPar_string, inputs));
108  else
109  m_model = make_shared<statistics::Model1D>(statistics::Model1D(&number_counts_mass, nParams, cosmoPar_type, cosmoPar_string, inputs));
110  break;
111  case (glob::HistogramType::_n_V_):
112  m_model = make_shared<statistics::Model1D>(statistics::Model1D(&number_density_mass, nParams, cosmoPar_type, cosmoPar_string, inputs));
113  break;
114  case (glob::HistogramType::_dn_dV_):
115  m_model = make_shared<statistics::Model1D>(statistics::Model1D(&mass_function_mass, nParams, cosmoPar_type, cosmoPar_string, inputs));
116  break;
117  default:
118  ErrorCBL("no such a variable in the list!", "set_model_NumberCounts_cosmology", "Modelling_NumberCounts1D_Mass.cpp");
119  }
120 }
Global functions to model number counts.
The class Modelling_NumberCounts1D_Mass.
The class Cosmology.
Definition: Cosmology.h:277
void set_data_model_snapshot(const cbl::cosmology::Cosmology cosmology={}, const double redshift=0., const std::string method_Pk="CAMB", const double k_min=1.e-4, const double k_max=100., const int step=500, const int norm=-1, const double Delta=200., const bool isDelta_critical=true, const std::string model_MF="Tinker", const double Volume=par::defaultDouble, const double Mass_min=par::defaultDouble, const double Mass_max=par::defaultDouble, const int Mass_step=100, const double prec=1.e-4)
set the data used to construct mass number counts of simulation snapshots
void set_model_NumberCounts_cosmology(const std::vector< cbl::cosmology::CosmologicalParameter > cosmo_param={}, const std::vector< statistics::PriorDistribution > cosmo_param_prior={})
set the cosmological parameters used to model the mass function
The class Model1D.
Definition: Model1D.h:60
static const std::string defaultString
default std::string value
Definition: Constants.h:336
std::string CosmologicalParameter_name(const CosmologicalParameter parameter)
name of the cosmological parameter
Definition: Cosmology.cpp:45
std::vector< double > mass_function_mass(const std::vector< double > mass, const std::shared_ptr< void > inputs, std::vector< double > &parameter)
compute the mass function as a function of the mass
std::vector< double > number_density_mass(const std::vector< double > mass, const std::shared_ptr< void > inputs, std::vector< double > &parameter)
compute the number density as a function of the mass
std::vector< double > number_counts_mass_snapshot(const std::vector< double > mass, const std::shared_ptr< void > inputs, std::vector< double > &parameter)
compute the number counts as a function of the mass for a simulation snapshot
std::vector< double > number_counts_mass(const std::vector< double > mass, const std::shared_ptr< void > inputs, std::vector< double > &parameter)
compute the number counts as a function of the mass
The global namespace of the CosmoBolognaLib
Definition: CAMB.h:38
std::vector< T > logarithmic_bin_vector(const size_t nn, const T min, const T max)
fill a std::vector with logarithmically spaced values
Definition: Kernel.h:1621
int ErrorCBL(const std::string msg, const std::string functionCBL, const std::string fileCBL, const cbl::glob::ExitCode exitCode=cbl::glob::ExitCode::_error_)
throw an exception: it is used for handling exceptions inside the CosmoBolognaLib
Definition: Kernel.h:780