CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
Modelling_NumberCounts1D_Size.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_Size::set_model_NumberCounts_cosmology (const std::vector<cbl::cosmology::CosmologicalParameter> cosmo_params, const std::vector<statistics::PriorDistribution> cosmo_param_priors)
51 {
52  m_data_model_SF.Cpar = cosmo_params;
53 
54  const size_t nParams = cosmo_params.size();
55  checkDim(cosmo_params, nParams, "cosmoPar_prior");
56 
57  vector<statistics::ParameterType> cosmoPar_type(nParams, statistics::ParameterType::_Base_);
58  vector<string> cosmoPar_string(nParams);
59 
60  for (size_t i=0; i<nParams; i++)
61  cosmoPar_string[i] = CosmologicalParameter_name(cosmo_params[i]);
62 
63  // input data used to construct the model
64  auto inputs = make_shared<STR_NCSF_data_model>(m_data_model_SF);
65 
66  // set prior
67  m_set_prior(cosmo_param_priors);
68 
69  // construct the model
70  if (m_HistogramType==glob::HistogramType::_dn_dlnV_)
71  m_model = make_shared<statistics::Model1D>(statistics::Model1D(&size_function_model, nParams, cosmoPar_type, cosmoPar_string, inputs));
72  else ErrorCBL("no such a variable in the list!", "set_model_NumberCounts_cosmology", "Modelling_NumberCounts1D_Size.cpp");
73 
74 }
75 
76 // ===========================================================================================
77 
78 
79 void cbl::modelling::numbercounts::Modelling_NumberCounts1D_Size::set_model_NumberCounts_cosmology_and_bias (const std::vector<cbl::cosmology::CosmologicalParameter> cosmo_params, const std::vector<statistics::PriorDistribution> cosmo_param_priors, const std::vector<statistics::PriorDistribution> bias_priors)
80 {
81  // set the model parameters
82  const size_t nParams = cosmo_params.size()+3;
83  checkDim(cosmo_params, cosmo_params.size(), "cosmoPar&bias_prior");
84 
85  vector<statistics::ParameterType> Par_type(nParams, statistics::ParameterType::_Base_);
86 
87  vector<string> Par_name(nParams);
88  vector<statistics::PriorDistribution> priors(nParams);
89 
90  for (size_t i=0; i<cosmo_params.size(); i++){
91  Par_name[i] = CosmologicalParameter_name(cosmo_params[i]);
92  priors[i] = cosmo_param_priors[i];}
93 
94  Par_name[nParams-3] = "b_eff";
95  priors[nParams-3] = bias_priors[0];
96  Par_name[nParams-2] = "b_slope";
97  priors[nParams-2] = bias_priors[1];
98  Par_name[nParams-1] = "b_offset";
99  priors[nParams-1] = bias_priors[2];
100 
101  // add the cosmological parameters
102  m_data_model_SF.Cpar = cosmo_params;
103 
104  // input data used to construct the model
105  auto inputs = make_shared<STR_NCSF_data_model>(m_data_model_SF);
106 
107  // set prior
108  m_set_prior(priors);
109 
110  // construct the model
111  if (m_HistogramType==glob::HistogramType::_dn_dlnV_)
112  m_model = make_shared<statistics::Model1D>(statistics::Model1D(&size_function_model, nParams, Par_type, Par_name, inputs));
113  else ErrorCBL("no such a variable in the list!", "set_model_NumberCounts_cosmology_and_bias", "Modelling_NumberCounts1D_Size.cpp");
114 
115 }
Global functions to model number counts.
The class Modelling_NumberCounts1D_Size.
void set_model_NumberCounts_cosmology_and_bias(const std::vector< cbl::cosmology::CosmologicalParameter > cosmo_params={}, const std::vector< statistics::PriorDistribution > cosmo_param_priors={}, const std::vector< statistics::PriorDistribution > bias_priors={})
set the cosmological parameters and parameters necessary to re-parametrise the void size function
void set_model_NumberCounts_cosmology(const std::vector< cbl::cosmology::CosmologicalParameter > cosmo_params={}, const std::vector< statistics::PriorDistribution > cosmo_param_priors={})
set the cosmological parameters used to model the size function
The class Model1D.
Definition: Model1D.h:60
std::string CosmologicalParameter_name(const CosmologicalParameter parameter)
name of the cosmological parameter
Definition: Cosmology.cpp:45
std::vector< double > size_function_model(const std::vector< double > radii, const std::shared_ptr< void > inputs, std::vector< double > &parameter)
compute the size function as a function of the void effective radii
The global namespace of the CosmoBolognaLib
Definition: CAMB.h:38
void checkDim(const std::vector< T > vect, const int val, const std::string vector, bool equal=true)
check if the dimension of a std::vector is equal/lower than an input value
Definition: Kernel.h:1532
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