CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
Modelling2D.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 
35 #include "Modelling.h"
36 
37 using namespace std;
38 
39 using namespace cbl;
40 
41 
42 // ============================================================================================
43 
44 
45 void cbl::modelling::Modelling::set_fit_range (const double xmin, const double xmax, const double ymin, const double ymax)
46 {
47  m_data_fit = m_data->cut(xmin, xmax, ymin, ymax);
48  m_fit_range = true;
49 }
50 
51 // ============================================================================================
52 
53 
54 void cbl::modelling::Modelling::write_model (const std::string output_dir, const std::string output_file, const std::vector<double> xx, const std::vector<double> yy, const std::vector<double> parameters)
55 {
56  if (m_model==NULL)
57  ErrorCBL("no model found!", "write_model", "Modelling2D.cpp");
58 
59  m_model->write(output_dir, output_file, xx, yy, parameters);
60 }
61 
62 
63 // ============================================================================================
64 
65 
66 void cbl::modelling::Modelling::write_model_at_bestfit (const std::string output_dir, const std::string output_file, const std::vector<double> xx, const std::vector<double> yy)
67 {
68  if (m_posterior==NULL)
69  ErrorCBL("no posterior found: run maximize_posterior() first!", "write_model_at_bestfit", "Modelling2D.cpp");
70 
71  m_posterior->write_model_at_bestfit(output_dir, output_file, xx, yy);
72 }
73 
74 
75 // ============================================================================================
76 
77 
78 void cbl::modelling::Modelling::write_model_from_chains (const std::string output_dir, const std::string output_file, const std::vector<double> xx, const std::vector<double> yy, const int start, const int thin)
79 {
80  if (m_posterior==NULL)
81  ErrorCBL("no posterior found: run sample_posterior() first!", "write_model_from_chains", "Modelling2D.cpp");
82 
83  m_posterior->write_model_from_chain(output_dir, output_file, xx, yy, start, thin);
84 }
The class Modelling.
virtual void write_model_from_chains(const std::string output_dir, const std::string output_file, const std::vector< double > xx, const int start=0, const int thin=1)
write the model at xx computing 16th, 50th and 84th percentiles from the chains
Definition: Modelling1D.cpp:80
virtual void write_model(const std::string output_dir, const std::string output_file, const std::vector< double > xx, const std::vector< double > parameters)
write the model at xx for given parameters
Definition: Modelling1D.cpp:56
void set_fit_range(const double xmin, const double xmax)
set the fit range
Definition: Modelling1D.cpp:46
virtual void write_model_at_bestfit(const std::string output_dir, const std::string output_file, const std::vector< double > xx)
write the model at xx with best-fit parameters obtained from posterior maximization
Definition: Modelling1D.cpp:68
The global namespace of the CosmoBolognaLib
Definition: CAMB.h:38
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