Bayesian Analysis of Neutron Star Mass and Radius Observations
process.h
Go to the documentation of this file.
1 /*
2  -------------------------------------------------------------------
3 
4  Copyright (C) 2012-2015, Andrew W. Steiner
5 
6  This file is part of Bamr.
7 
8  Bamr is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version.
12 
13  Bamr is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with Bamr. If not, see <http://www.gnu.org/licenses/>.
20 
21  -------------------------------------------------------------------
22 */
23 /** \file process.h
24  \brief Definition of main process class
25 */
26 #ifndef PROCESS_H
27 #define PROCESS_H
28 
29 #include <iostream>
30 #include <string>
31 
32 // For gsl_sf_erf
33 #include <gsl/gsl_specfunc.h>
34 
35 #include <boost/numeric/ublas/vector.hpp>
36 #include <boost/numeric/ublas/matrix.hpp>
37 
38 #include <o2scl/table.h>
39 #include <o2scl/table3d.h>
40 #include <o2scl/format_float.h>
41 #include <o2scl/vec_stats.h>
42 #include <o2scl/contour.h>
43 #include <o2scl/hist.h>
44 #include <o2scl/hdf_io.h>
45 #include <o2scl/expval.h>
46 #include <o2scl/interp.h>
47 #include <o2scl/vector.h>
48 #include <o2scl/hist.h>
49 
50 #ifdef BAMR_READLINE
51 #include <o2scl/cli_readline.h>
52 #else
53 #include <o2scl/cli.h>
54 #endif
55 
58 
59 namespace bamr {
60 
61  /** \brief Processing MCMC data from bamr
62  */
63  class process {
64 
65  protected:
66 
73  o2scl::cli::parameter_int p_hist_size;
74  o2scl::cli::parameter_int p_n_blocks;
75  o2scl::cli::parameter_int p_line_start;
76  o2scl::cli::parameter_int p_verbose;
77  o2scl::cli::parameter_string p_constraint;
78 
79  /// \name Command-line parameters
80  //@{
81  /// Verbosity (default 1)
82  int verbose;
83  /// Ignore all lines before start
85  /// Scale for x-axis
86  double xscale;
87  /// Scale for y-axis
88  double yscale;
89  /// If true, use a logarithmic x scale
90  bool logx;
91  /// If true, use a logarithmic y scale
92  bool logy;
93  /// If true, use a logarithmic z scale
94  bool logz;
95  /// If true, plot errors in 1d
96  bool errors;
97  /// Histogram size
99  /// Number of blocks
100  int n_blocks;
101  //@}
102 
103 #ifdef BAMR_READLINE
105 #else
106  o2scl::cli cl;
107 #endif
108 
109  /// \name Axis limits from 'xlimits' and 'ylimits'
110  //@{
111  /// If true, x limits are set
112  bool xset;
113  /// Lower x value
114  double user_xlow;
115  /// Upper x value
116  double user_xhigh;
117  /// If true, y limits are set
118  bool yset;
119  /// Lower y value
120  double user_ylow;
121  /// Upper y value
122  double user_yhigh;
123  //@}
124 
125  /// \name Const confidence limits
126  //@{
127  /// The one-sigma limit of a normal distribution, 0.6827
128  const double one_sigma;
129  /// The two-sigma limit of a normal distribution, 0.9545
130  const double two_sigma;
131  /// The three-sigma limit of a normal distribution, 0.9973
132  const double three_sigma;
133  //@}
134 
135  /// \name Other class member data
136  //@{
137  /// Constraint to apply to the data
138  std::string constraint;
139  /// Contour levels set in 'contours'
140  std::vector<double> cont_levels;
141  /// Formatter for floating point numbers
143  //@}
144 
145  /// \name Commands
146  //@{
147  /** \brief Create a table of autocorrelation data from a specified
148  column
149  */
150  int auto_corr(std::vector<std::string> &sv, bool itive_com);
151 
152  /** \brief Set limits for the x-axis
153  */
154  int xlimits(std::vector<std::string> &sv, bool itive_com);
155 
156  /** \brief Set limits for the y-axis
157  */
158  int ylimits(std::vector<std::string> &sv, bool itive_com);
159 
160  /** \brief Create a histogram from a specified column
161 
162  \future This function isn't that efficient. It first reads all
163  of the data into one long vector and then reparses the long
164  vector into a set of \ref o2scl::expval_scalar objects. The
165  averages and errors for the \ref o2scl::expval_scalar objects
166  are stored into a table, and the table is written to the
167  output file. This could be improved.
168  */
169  int hist(std::vector<std::string> &sv, bool itive_com);
170 
171  /** \brief Create a two-dimensional histogram from two
172  user-specified columns
173  */
174  int hist2(std::vector<std::string> &sv, bool itive_com);
175 
176  /** \brief Create a set of histograms from a set of columns in
177  the bamr MCMC output
178  */
179  int hist_set(std::vector<std::string> &sv, bool itive_com);
180 
181  /** \brief Combine several <tt>bamr</tt> output files
182  */
183  int combine(std::vector<std::string> &sv, bool itive_com);
184 
185  /** \brief Specify which contour levels to use
186  */
187  int contours(std::vector<std::string> &sv, bool itive_com);
188  //@}
189 
190  /// Desc
191  virtual void setup_cli();
192 
193  public:
194 
195  /// Create the process object
196  process();
197 
198  /** \brief Main public interface
199  */
200  void run(int argc, char *argv[]);
201 
202  };
203 
204 }
205 
206 #endif
bool yset
If true, y limits are set.
Definition: process.h:118
bool logy
If true, use a logarithmic y scale.
Definition: process.h:92
int hist_size_int
Histogram size.
Definition: process.h:98
void run(int argc, char *argv[])
Main public interface.
std::vector< double > cont_levels
Contour levels set in 'contours'.
Definition: process.h:140
double user_ylow
Lower y value.
Definition: process.h:120
Main namespace.
Definition: bamr.h:54
int verbose
Verbosity (default 1)
Definition: process.h:82
const double one_sigma
The one-sigma limit of a normal distribution, 0.6827.
Definition: process.h:128
int n_blocks
Number of blocks.
Definition: process.h:100
double user_yhigh
Upper y value.
Definition: process.h:122
process()
Create the process object.
int hist_set(std::vector< std::string > &sv, bool itive_com)
Create a set of histograms from a set of columns in the bamr MCMC output.
int ylimits(std::vector< std::string > &sv, bool itive_com)
Set limits for the y-axis.
double user_xhigh
Upper x value.
Definition: process.h:116
virtual void setup_cli()
Desc.
int contours(std::vector< std::string > &sv, bool itive_com)
Specify which contour levels to use.
const double two_sigma
The two-sigma limit of a normal distribution, 0.9545.
Definition: process.h:130
std::string constraint
Constraint to apply to the data.
Definition: process.h:138
Processing MCMC data from bamr.
Definition: process.h:63
o2scl::format_float ff
Formatter for floating point numbers.
Definition: process.h:142
bool errors
If true, plot errors in 1d.
Definition: process.h:96
int hist2(std::vector< std::string > &sv, bool itive_com)
Create a two-dimensional histogram from two user-specified columns.
bool xset
If true, x limits are set.
Definition: process.h:112
bool logx
If true, use a logarithmic x scale.
Definition: process.h:90
double xscale
Scale for x-axis.
Definition: process.h:86
int hist(std::vector< std::string > &sv, bool itive_com)
Create a histogram from a specified column.
int auto_corr(std::vector< std::string > &sv, bool itive_com)
Create a table of autocorrelation data from a specified column.
int combine(std::vector< std::string > &sv, bool itive_com)
Combine several bamr output files.
double user_xlow
Lower x value.
Definition: process.h:114
bool logz
If true, use a logarithmic z scale.
Definition: process.h:94
int line_start
Ignore all lines before start.
Definition: process.h:84
const double three_sigma
The three-sigma limit of a normal distribution, 0.9973.
Definition: process.h:132
int xlimits(std::vector< std::string > &sv, bool itive_com)
Set limits for the x-axis.
double yscale
Scale for y-axis.
Definition: process.h:88

Documentation generated with Doxygen. Bamr documentation is under the GNU Free Documentation License.