5 #include <gsl/gsl_specfunc.h>
7 #include <boost/numeric/ublas/vector.hpp>
8 #include <boost/numeric/ublas/matrix.hpp>
10 #include <o2scl/table.h>
11 #include <o2scl/table3d.h>
12 #include <o2scl/format_float.h>
13 #include <o2scl/vec_stats.h>
14 #include <o2scl/contour.h>
15 #include <o2scl/hist.h>
16 #include <o2scl/hdf_io.h>
17 #include <o2scl/expval.h>
18 #include <o2scl/interp.h>
19 #include <o2scl/vector.h>
20 #include <o2scl/hist.h>
21 #include <o2scl/mcarlo_miser.h>
22 #include <o2scl/fit_linear.h>
25 #include <o2scl/cli_readline.h>
27 #include <o2scl/cli.h>
31 using namespace o2scl;
111 int auto_corr(std::vector<std::string> &sv,
bool itive_com) {
114 size_t hist_size=(size_t)hist_size_int;
115 if (hist_size_int<=0) {
116 cout <<
"Histogram size <=0, using 100." << endl;
126 vector<string> files;
127 for(
size_t i=3;i<sv.size();i++) files.push_back(sv[i]);
128 size_t nf=files.size();
134 for(
size_t i=0;i<nf;i++) {
138 cout <<
"Opening file: " << files[i] << endl;
143 hf.
get_szt(
"n_chains",n_chains);
144 cout << n_chains <<
" separate chains." << endl;
146 size_t line_counter=0;
149 for(
size_t j=0;j<n_chains;j++) {
152 std::string tab_name=
"markov_chain"+
szttos(j);
155 cout <<
"Read table " << tab_name << endl;
159 if (((
int)line_counter)>=line_start) {
160 values.push_back(tab.
get(name,k));
170 size_t kmax=values.size()/3;
171 vector<double> kvec(kmax-1), acvec(kmax-1), acerr(kmax-1), acfit(kmax-1);
172 for(
size_t k=1;k<kmax;k++) {
173 kvec[k-1]=((double)k);
175 acerr[k-1]=fabs(acvec[k-1])/10.0;
200 int xlimits(std::vector<std::string> &sv,
bool itive_com) {
204 cout <<
"Setting 'xset' to false." << endl;
215 cout <<
"X limits are " << user_xlow <<
" and "
216 << user_xhigh <<
" ." << endl;
222 string low_name=sv[2];
223 string high_name=sv[3];
227 cout <<
"Reading file named '" << file <<
"'." << endl;
231 hf.
getd(low_name,user_xlow);
232 hf.
getd(high_name,user_xhigh);
236 cout <<
"X limits are " << user_xlow <<
" and "
237 << user_xhigh <<
" ." << endl;
245 int ylimits(std::vector<std::string> &sv,
bool itive_com) {
249 cout <<
"Setting 'yset' to false." << endl;
260 cout <<
"Y limits are " << user_ylow <<
" and "
261 << user_yhigh <<
" ." << endl;
267 string low_name=sv[2];
268 string high_name=sv[3];
272 cout <<
"Reading file named '" << file <<
"'." << endl;
276 hf.
getd(low_name,user_ylow);
277 hf.
getd(high_name,user_yhigh);
281 cout <<
"Y limits are " << user_ylow <<
" and "
282 << user_yhigh <<
" ." << endl;
297 int hist(std::vector<std::string> &sv,
bool itive_com) {
300 size_t hist_size=(size_t)hist_size_int;
301 if (hist_size_int<=0) {
302 cout <<
"Histogram size <=0, using 100." << endl;
312 vector<string> files;
313 for(
size_t i=3;i<sv.size();i++) files.push_back(sv[i]);
314 size_t nf=files.size();
322 for(
size_t i=0;i<nf;i++) {
326 if (verbose>0) cout <<
"Opening file: " << files[i] << endl;
334 cout << n_chains <<
" separate chains." << endl;
336 cout <<
"1 chain." << endl;
340 size_t line_counter=0;
343 for(
size_t j=0;j<n_chains;j++) {
346 std::string tab_name=
"markov_chain"+
szttos(j);
350 if (constraint.size()>0) {
355 cout <<
"Applied constraint \"" << constraint
356 <<
"\" and went from " << nlines_old <<
" to "
357 << nlines_new <<
" lines." << endl;
363 if (((
int)line_counter)>=line_start) {
364 values.push_back(tab.
get(name,k));
365 weights.push_back(tab.
get(
"mult",k));
371 cout <<
"Table " << tab_name <<
" lines: "
374 cout <<
" skipping: " << line_start;
384 cout <<
"Done with reading files.\n" << endl;
392 min=*min_element(values.begin(),values.end());
393 max=*max_element(values.begin(),values.end());
401 cout <<
"xsize, min, max: " << values.size() <<
" "
402 << min <<
" " << max << endl;
410 O2SCL_ERR2(
"Both min and max negative with logarithmic ",
411 "grid in hist().",exc_efailed);
416 for(
size_t i=0;i<values.size();i++) {
417 if (values[i]>0.0 && values[i]<min_new) min_new=values[i];
419 cout <<
"Resetting 'min' from " << min <<
" to "
420 << min_new <<
"." << endl;
429 cout <<
"Variable 'n_blocks' <= 0. Setting to 20." << endl;
432 vector<expval_scalar> sev(hist_size);
433 for(
size_t i=0;i<hist_size;i++) {
434 sev[i].set_blocks(n_blocks,1);
446 max*(1.0+1.0e-6),hist_size);
450 max+fabs(max)*1.0e-6,hist_size);
457 size_t block_size=values.size()/((size_t)n_blocks);
458 for(
int i=0;i<n_blocks;i++) {
460 cout <<
"Block " << i << endl;
462 for(
size_t j=0;j<block_size;j++) {
463 double val=values[i*block_size+j]*xscale;
464 if (val>min && val<max) {
465 h.
update(val,weights[i*block_size+j]);
469 for(
size_t j=0;j<hist_size;j++) {
489 double avg, std_dev, avg_err;
490 for(
size_t i=0;i<hist_size;i++) {
492 sev[i].current_avg(avg,std_dev,avg_err);
494 t.
set(
"errs",i,avg_err);
499 t.
set(
"avgs",hist_size-1,0.0);
501 cout <<
"Here." << endl;
505 if (verbose>0) cout <<
"Total integral: " << total << endl;
507 cout <<
"Here " << total << endl;
508 std::vector<double> locs;
513 t[
"reps"],t[
"avgs"],lev);
515 cout <<
"here: " << locs.size() << endl;
518 double xlo1=locs[0], xhi1=locs[0];
519 for(
size_t i=0;i<locs.size();i++) {
520 if (locs[i]<xlo1) xlo1=locs[i];
521 if (locs[i]>xhi1) xhi1=locs[i];
526 t[
"reps"],t[
"avgs"],lev);
528 double xlo2=locs[0], xhi2=locs[0];
529 for(
size_t i=0;i<locs.size();i++) {
530 if (locs[i]<xlo2) xlo2=locs[i];
531 if (locs[i]>xhi2) xhi2=locs[i];
535 double xpeak=vector_max_quad_loc<std::vector<double>,
double>
536 (hist_size,t[
"reps"],t[
"avgs"]);
539 cout << name <<
" -2,-1,0,+1,+2 sigma: " << endl;
541 cout.unsetf(ios::scientific);
543 cout << xlo2 <<
" & " << xlo1 <<
" & "
544 << xpeak <<
" & " << xhi1 <<
" & " << xhi2 <<
" \\\\" << endl;
546 cout.setf(ios::scientific);
550 << ff.
convert(xhi2) <<
" \\\\" << endl;
555 double xmin=t.min(
"reps");
556 double xmax=t.max(
"reps");
557 double ymin=t.min(
"avgs");
558 double ymax=t.max(
"avgs");
562 for(
size_t i=0;i<hist_size;i++) {
563 if (t.get(
"avgs",i)>=0.0) {
564 if (t.get(
"avgs",i)-t.get(
"errs",i)>=0.0) {
565 t.set(
"minus",i,t.get(
"avgs",i)-t.get(
"errs",i));
567 t.set(
"minus",i,0.0);
569 t.set(
"plus",i,t.get(
"avgs",i)+t.get(
"errs",i));
571 t.set(
"minus",i,t.get(
"avgs",i)-t.get(
"errs",i));
572 if (t.get(
"avgs",i)+t.get(
"errs",i)>0.0) {
575 t.set(
"plus",i,t.get(
"avgs",i)+t.get(
"errs",i));
579 double plus_max=t.max(
"plus");
580 double minus_min=t.min(
"minus");
581 if (plus_max>ymax) ymax=plus_max;
582 if (minus_min<ymin) ymin=minus_min;
586 cout <<
"Writing to file " << sv[2] << endl;
592 hf.
setd(
"xmin",xmin);
593 hf.
setd(
"xmax",xmax);
599 hf.
setd(
"ymin",ymin);
600 hf.
setd(
"ymax",ymax);
601 hf.
setd(
"xlo2",xlo2);
602 hf.
setd(
"xhi2",xhi2);
603 hf.
setd(
"xlo1",xlo1);
604 hf.
setd(
"xhi1",xhi1);
605 hf.
setd(
"xpeak",xpeak);
614 int hist2(std::vector<std::string> &sv,
bool itive_com) {
617 size_t hist_size=(size_t)hist_size_int;
618 if (hist_size_int<=0) {
619 cout <<
"Histogram size <=0, using 100." << endl;
630 vector<string> files;
631 for(
size_t i=4;i<sv.size();i++) files.push_back(sv[i]);
632 size_t nf=files.size();
641 for(
size_t i=0;i<nf;i++) {
643 cout <<
"Opening file: " << files[i] << endl;
647 cout << n_chains <<
" chains." << endl;
649 size_t line_counter=0;
651 for(
size_t j=0;j<n_chains;j++) {
653 std::string tab_name=
"markov_chain"+
szttos(j);
655 cout <<
"Read table " << tab_name << endl;
657 if (constraint.size()>0) {
662 cout <<
"Applied constraint \"" << constraint
663 <<
"\" and went from " << nlines_old <<
" to "
664 << nlines_new <<
" lines." << endl;
669 if (((
int)line_counter)>=line_start) {
670 valuesx.push_back(tab.
get(xname,k));
671 valuesy.push_back(tab.
get(yname,k));
672 weights.push_back(tab.
get(
"mult",k));
682 xmin=*min_element(valuesx.begin(),valuesx.end());
683 xmax=*max_element(valuesx.begin(),valuesx.end());
686 cout << xname <<
" xsize, xmin, xmax: " << valuesx.size() <<
" "
687 << xmin <<
" " << xmax << endl;
695 ymin=*min_element(valuesy.begin(),valuesy.end());
696 ymax=*max_element(valuesy.begin(),valuesy.end());
699 cout << yname <<
" ysize, ymin, ymax: " << valuesy.size() <<
" "
700 << ymin <<
" " << ymax << endl;
707 if (n_blocks<=0) n_blocks=20;
708 vector<expval_scalar> sev(hist_size*hist_size);
709 for(
size_t i=0;i<hist_size*hist_size;i++) {
710 sev[i].set_blocks(n_blocks,1);
715 xmax*(1.0+1.0e-6),hist_size);
717 ymax*(1.0+1.0e-6),hist_size);
722 size_t block_size=valuesx.size()/20;
723 for(
size_t i=0;((int)i)<n_blocks;i++) {
724 cout <<
"Block " << i << endl;
725 for(
size_t j=0;j<block_size;j++) {
726 double vx=valuesx[i*block_size+j]*xscale;
727 double vy=valuesy[i*block_size+j]*yscale;
728 if (vx<xmax && vx>xmin && vy<ymax && vy>ymin) {
729 h.
update(vx,vy,weights[i*block_size+j]);
732 for(
size_t j=0;j<hist_size;j++) {
733 for(
size_t k=0;k<hist_size;k++) {
734 sev[j*hist_size+k].add(h.
get_wgt_i(j,k));
741 ubvector xreps(hist_size), yreps(hist_size);
742 for(
size_t i=0;i<hist_size;i++) {
749 t3d.
set_xy(xname,xreps.size(),xreps,yname,yreps.size(),yreps);
753 double std_dev, avg_err, avg, smax=0.0;
754 for(
size_t i=0;i<hist_size;i++) {
755 for(
size_t j=0;j<hist_size;j++) {
756 sev[i*hist_size+j].current_avg(avg,std_dev,avg_err);
757 if (avg>smax) smax=avg;
758 t3d.
set(i,j,
"avgs",avg);
764 for(
size_t i=0;i<hist_size;i++) {
765 for(
size_t j=0;j<hist_size;j++) {
766 t3d.
set(i,j,
"avgs",t3d.
get(i,j,
"avgs")/smax);
773 vector<contour_line> conts;
778 for(
size_t i=0;i<101;i++) {
779 integx[i]=((double)i)/100.0;
781 for(
size_t k=0;k<101;k++) {
783 for(
size_t i=0;i<hist_size;i++) {
784 for(
size_t j=0;j<hist_size;j++) {
785 if (t3d.
get(i,j,
"avgs")>integx[k]) integy[k]+=t3d.
get(i,j,
"avgs");
791 double total=integy[0];
792 ubvector levels(cont_levels.size());
795 for(
size_t k=0;k<cont_levels.size();k++) {
797 for(
size_t i=0;i<100;i++) {
798 if (integy[i]>cont_levels[k]*total &&
799 integy[i+1]<cont_levels[k]*total) {
800 levels[k]=(integx[i]+integx[i+1])/2.0;
804 if (levels[k]==0.0) {
805 cout <<
"Failed to find contour level for level "
806 << levels[k] << endl;
814 ubvector xg(hist_size), yg(hist_size);
815 for(
size_t i=0;i<hist_size;i++) {
827 cout <<
"Number of contours: " << nc << endl;
829 cout <<
"Writing to file " << sv[3] << endl;
846 int hist_set(std::vector<std::string> &sv,
bool itive_com) {
849 size_t hist_size=(size_t)hist_size_int;
850 if (hist_size_int<=0) {
851 cout <<
"Histogram size <=0, using 100." << endl;
856 string low_name=sv[2];
857 string high_name=sv[3];
858 string set_prefix=sv[4];
863 vector<string> files;
866 for(
size_t i=6;i<sv.size();i++) files.push_back(sv[i]);
867 size_t nf=files.size();
874 vector<vector<double> > values_ser;
878 double index_low, index_high;
886 double ser_min=0.0, ser_max=0.0;
891 for(
size_t i=0;i<nf;i++) {
894 cout <<
"Opening file: " << files[i] << endl;
900 hf.
get_szt(
"grid_size",grid_size);
901 hf.
getd(low_name,index_low);
902 hf.
getd(high_name,index_high);
904 cout <<
"grid_size, index_low, index_high: "
905 << grid_size <<
" " << index_low <<
" " << index_high << endl;
907 if ((logx && type==((
string)
"x")) ||
908 (logy && type==((
string)
"y"))) {
910 (index_low,index_high,grid_size-1);
913 (index_low,index_high,grid_size-1);
915 values_ser.resize(grid_size);
921 hf.
get_szt(
"n_chains",n_chains);
924 cout << n_chains <<
" separate chain." << endl;
926 cout << n_chains <<
" separate chains." << endl;
932 size_t line_counter=0;
935 for(
size_t j=0;j<n_chains;j++) {
939 std::string tab_name=
"markov_chain"+
szttos(j);
942 cout <<
"Read table " << tab_name <<
" lines: "
947 if (constraint.size()>0) {
952 cout <<
"Applied constraint \"" << constraint
953 <<
"\" and went from " << nlines_old <<
" to "
954 << nlines_new <<
" lines." << endl;
961 if (((
int)line_counter)>=line_start) {
964 for(
size_t ell=0;ell<grid_size;ell++) {
967 string col=set_prefix+
"_"+
szttos(ell);
968 double val=tab.
get(col,k);
971 values_ser[ell].push_back(val);
984 if (val<ser_min) ser_min=val;
985 if (val>ser_max) ser_max=val;
989 weights.push_back(tab.
get(
"mult",k));
1002 cout <<
"Done reading files." << endl;
1007 if (type==((
string)
"x")) {
1014 if (type==((
string)
"x")) {
1027 cout <<
"Total lines: " << weights.size() <<
" "
1028 << values_ser[0].size() <<
" ser_min: " << ser_min <<
" ser_max: "
1033 if (n_blocks<=0) n_blocks=20;
1034 vector<expval_scalar> sev(hist_size*grid_size);
1035 for(
size_t i=0;i<hist_size*grid_size;i++) {
1036 sev[i].set_blocks(n_blocks,1);
1040 if ((logy && type==((
string)
"x")) ||
1041 (logx && type==((
string)
"y"))) {
1057 ubmatrix cont_res(cont_levels.size()*2,grid_size);
1060 size_t block_size=weights.size()/20;
1061 for(
size_t k=0;k<grid_size;k++) {
1063 string col=set_prefix+
"_"+
szttos(k);
1064 cout <<
"Column " << col <<
" index: ";
1065 if (type==((
string)
"x")) {
1066 cout << index_grid[k]*xscale <<
" count: ";
1068 cout << index_grid[k]*yscale <<
" count: ";
1070 cout << count[k] <<
" ";
1073 for(
size_t i=0;((int)i)<n_blocks;i++) {
1074 for(
size_t j=0;j<block_size;j++) {
1075 double val=values_ser[k][i*block_size+j];
1076 if (type==((
string)
"x")) val*=yscale;
1078 if (val>ser_min && val<ser_max) {
1079 h.
update(val,weights[i*block_size+j]);
1080 hsum.
update(val,weights[i*block_size+j]);
1083 for(
size_t j=0;j<hist_size;j++) {
1091 for(
size_t i=0;i<hsum.
size();i++) {
1097 for(
size_t j=0;j<cont_levels.size();j++) {
1099 std::vector<double> locs;
1101 cont_wgt[cont_wgt.size()-1]=0.0;
1104 cont_levels[j],locs);
1105 double lmin=vector_min_value<vector<double>,
double>(locs);
1106 double lmax=vector_max_value<vector<double>,
double>(locs);
1107 cout << lmin <<
" " << lmax <<
" ";
1108 cont_res(2*j,k)=lmin;
1109 cont_res(2*j+1,k)=lmax;
1112 cont_res(2*j,k)=0.0;
1113 cont_res(2*j+1,k)=0.0;
1117 cont_res(2*j,k)=0.0;
1118 cont_res(2*j+1,k)=0.0;
1129 for(
size_t i=0;i<hist_size;i++) {
1135 if (type==((
string)
"x")) {
1136 for(
size_t i=0;i<index_grid_vec.size();i++) {
1137 index_grid_vec[i]*=xscale;
1140 for(
size_t i=0;i<index_grid_vec.size();i++) {
1141 index_grid_vec[i]*=yscale;
1147 if (type==((
string)
"x")) {
1148 t3d.
set_xy(
"x",index_grid_vec.size(),index_grid_vec,
1149 "y",reps.size(),reps);
1151 t3d.
set_xy(
"x",reps.size(),reps,
1152 "y",index_grid_vec.size(),index_grid_vec);
1157 double std_dev, avg_err, avg, smax=0.0;
1158 for(
size_t j=0;j<hist_size;j++) {
1159 for(
size_t k=0;k<grid_size;k++) {
1160 sev[j*grid_size+k].current_avg(avg,std_dev,avg_err);
1161 if (avg>smax) smax=avg;
1162 if (type==((
string)
"x")) {
1163 t3d.
set(k,j,
"avgs",avg);
1165 t3d.
set(j,k,
"avgs",avg);
1171 for(
size_t j=0;j<t3d.
get_nx();j++) {
1172 for(
size_t k=0;k<t3d.
get_ny();k++) {
1173 t3d.
set(j,k,
"avgs",t3d.
get(j,k,
"avgs")/smax);
1178 cout <<
"Writing table to file " << sv[5] << endl;
1192 int contours(std::vector<std::string> &sv,
bool itive_com) {
1193 cont_levels.clear();
1194 for(
size_t i=1;i<sv.size();i++) {
1195 if (sv[i]==((
string)
"1s")) {
1196 cont_levels.push_back(one_sigma);
1197 }
else if (sv[i]==((
string)
"2s")) {
1198 cont_levels.push_back(two_sigma);
1199 }
else if (sv[i]==((
string)
"3s")) {
1200 cont_levels.push_back(three_sigma);
1210 int combine(std::vector<std::string> &sv,
bool itive_com) {
1213 size_t thin_factor=
stoszt(sv[1]);
1214 if (thin_factor==0) thin_factor=1;
1217 string out_file=sv[2];
1220 vector<string> files;
1223 for(
size_t i=3;i<sv.size();i++) files.push_back(sv[i]);
1224 size_t nf=files.size();
1228 double e_low, e_high, m_low, m_high, nb_low, nb_high;
1230 size_t nparams, nsources, lgrid_size, file_row_start;
1231 vector<string> param_names, source_names;
1234 for(
size_t i=0;i<nf;i++) {
1238 cout <<
"Opening file: " << files[i] << endl;
1243 hf.
get_szt(
"n_chains",n_chains);
1245 cout << n_chains <<
" separate chains." << endl;
1247 cout <<
"1 chain." << endl;
1250 size_t line_counter=0;
1255 for(
size_t j=0;j<n_chains;j++) {
1258 std::string tab_name=
"markov_chain"+
szttos(j);
1271 hf.
getd(
"e_low",e_low);
1272 hf.
getd(
"e_high",e_high);
1273 hf.
getd(
"nb_low",nb_low);
1274 hf.
getd(
"nb_high",nb_high);
1275 hf.
getd(
"m_low",m_low);
1276 hf.
getd(
"m_high",m_high);
1279 hf.
get_szt(
"grid_size",lgrid_size);
1280 hf.
get_szt(
"nparams",nparams);
1281 hf.
get_szt(
"nsources",nsources);
1282 hf.
gets_vec(
"param_names",param_names);
1283 hf.
gets_vec(
"source_names",source_names);
1287 for(
size_t k=((
size_t)line_start);k<tab.
get_nlines();k+=thin_factor) {
1295 cout <<
"Added table " << tab_name <<
" lines: "
1298 cout <<
" skipped: " << line_start;
1308 for(
size_t k=file_row_start;k<full.
get_nlines();k++) {
1309 subweights.push_back(full.
get(
"weight",k));
1313 size_t kmax=subweights.size()/3;
1314 ubvector kvec(kmax-1), acvec(kmax-1), acerr(kmax-1);
1315 for(
size_t k=1;k<kmax;k++) {
1316 kvec[k-1]=((double)k);
1318 acerr[k-1]=fabs(acvec[k-1])/10.0;
1321 cout <<
"full.nlines=" << full.
get_nlines() << endl;
1326 cout <<
"Writing table to file " << out_file << endl;
1329 hf.
setd(
"e_low",e_low);
1330 hf.
setd(
"e_high",e_high);
1331 hf.
setd(
"nb_low",nb_low);
1332 hf.
setd(
"nb_high",nb_high);
1333 hf.
setd(
"m_low",m_low);
1334 hf.
setd(
"m_high",m_high);
1335 hf.
set_szt(
"grid_size",lgrid_size);
1339 hf.
set_szt(
"nparams",nparams);
1340 hf.
set_szt(
"nsources",nsources);
1341 hf.
sets_vec(
"param_names",param_names);
1342 hf.
sets_vec(
"source_names",source_names);
1354 two_sigma(gsl_sf_erf(2.0/sqrt(2.0))),
1355 three_sigma(gsl_sf_erf(3.0/sqrt(2.0))) {
1380 void run(
int argc,
char *argv[]) {
1385 #ifdef BAMR_READLINE
1398 static const int nopt=8;
1400 {
'x',
"xlimits",
"Set histogram limits for first variable",0,3,
1401 "<low-value high-value> or <file> <low-name> <high-name> or <>",
1402 ((string)
"In the case of no arguments, set the limits ")+
1403 "to the default. In the case of two arguments, take the two "+
1404 "specified numbers as the limits, in the case of three "+
1405 "arguments, assume that the first argument is the bamr output "+
1406 "file, and the second and third are the names of values "+
1407 "in the output file which should be set as limits.",
1409 cli::comm_option_both},
1410 {
'y',
"ylimits",
"Set histogram limits for the second variable",0,3,
1411 "<low-value high-value> or <file> <low-name> <high-name> or <>",
1412 ((std::string)
"In the case of no arguments, set the limits ")+
1413 "to the default. In the case of two arguments, take the two "+
1414 "specified numbers as the limits, in the case of three "+
1415 "arguments, assume that the first argument is the bamr output "+
1416 "file, and the second and third are the names of values "+
1417 "in the output file which should be set as limits.",
1419 cli::comm_option_both},
1420 {
'C',
"combine",
"Combine two bamr output files.",2,-1,
1421 "<name> <file1> <file2> [file 3...]",
1422 ((string)
"Long ")+
"desc.",
1424 cli::comm_option_both},
1425 {0,
"contours",
"Specify contour levels",-1,-1,
1426 "[level 1] [level 2] ...",
1427 ((string)
"Specify a list of contour levels for the 'hist2' and ")+
1428 "'hist-set' commands. The levels can either be numerical values "+
1429 "or they can be 1s, 2s, or 3s, corresponding to 1-, 2-, and 3-"+
1430 "sigma confidence limits, respectively.",
1432 cli::comm_option_both},
1433 {0,
"hist2",
"Create a histogram from two columns of MCMC data.",4,-1,
1434 "<x> <y> <out_file> <file1> [file2 file 3...]",
1435 ((string)
"Using the 'markov_chain' objects in a bamr output ")+
1436 "file, construct a two-dimensional histogram from the "+
1437 "specified columns and store the histogram in 'out_file'.",
1439 cli::comm_option_both},
1440 {0,
"hist",
"Create a histogram from one column of MCMC data.",3,-1,
1441 "<column> <out_file> <file1> [file2 file 3...]",
1442 ((string)
"Using the 'markov_chain' objects in a bamr output ")+
1443 "file, construct a histogram from the specified column, and "+
1444 "store the histogram in 'out_file'.",
1446 cli::comm_option_both},
1447 {0,
"auto-corr",
"Create a table of autocorrelation data",3,-1,
1448 "<column> <out_file> <file1> [file2 file 3...]",
1449 ((string)
"Using the 'markov_chain' objects in a bamr output ")+
1450 "file, create a table containing autocorrelation "+
1451 "information about the specified column, and "+
1452 "store the table in 'out_file'.",
1454 cli::comm_option_both},
1455 {0,
"hist-set",
"Create an ensemble of of 1-d histograms.",3,-1,
1456 "<direction> <low> <high> <set> <out_file> <file1> [file2...]",
1457 ((string)
"Using the 'markov_chain' objects in a bamr output ")+
1458 "file, create an ensemble of 1-d histograms from a set "+
1459 "of columns in each chain. Typical uses are: "+
1460 "\'process -hist-set y m_low m_high R out.o2 x_0_out\', "+
1461 "\'process -hist-set x e_low e_high P out.o2 x_0_out\', and "+
1462 "\'process -hist-set x nb_low nb_high P out.o2 x_0_out\'. ",
1464 cli::comm_option_both}
1473 p_xscale.
help=
"Scale parameter for first variable";
1474 cl.
par_list.insert(make_pair(
"xscale",&p_xscale));
1478 p_yscale.
help=
"Scale parameter for second variable";
1479 cl.
par_list.insert(make_pair(
"yscale",&p_yscale));
1483 p_errors.
help=
"If true, output more error information";
1484 cl.
par_list.insert(make_pair(
"errors",&p_errors));
1488 p_logx.
help=
"If true, use a logarithmic x-axis (default false).";
1489 cl.
par_list.insert(make_pair(
"logx",&p_logx));
1493 p_logy.
help=
"If true, use a logarithmic y-axis (default false).";
1494 cl.
par_list.insert(make_pair(
"logy",&p_logy));
1498 p_logz.
help=
"If true, use a logarithmic z-axis (default false).";
1499 cl.
par_list.insert(make_pair(
"logz",&p_logz));
1502 p_hist_size.
i=&hist_size_int;
1503 p_hist_size.
help=
"Histogram size (default 100).";
1504 cl.
par_list.insert(make_pair(
"hist_size",&p_hist_size));
1507 p_n_blocks.
i=&n_blocks;
1508 p_n_blocks.
help=
"Number of blocks (default 20).";
1509 cl.
par_list.insert(make_pair(
"n_blocks",&p_n_blocks));
1512 p_line_start.
i=&line_start;
1513 p_line_start.
help=((string)
"Number of initial rows to skip over ")+
1514 "when reading MCMC tables.";
1515 cl.
par_list.insert(make_pair(
"line_start",&p_line_start));
1518 p_verbose.
i=&verbose;
1519 p_verbose.
help=
"Verbosity (default 1).";
1520 cl.
par_list.insert(make_pair(
"verbose",&p_verbose));
1523 p_constraint.
str=&constraint;
1524 p_constraint.
help=
"Constraint (default is an empty string).";
1525 cl.
par_list.insert(make_pair(
"constraint",&p_constraint));
1539 int main(
int argc,
char *argv[]) {
1540 cout.setf(ios::scientific);
bool yset
If true, y limits are set.
void vector_region_parint(size_t n, vec_t &x, vec2_t &y, double frac, std::vector< double > &locs, int verbose=0)
double vector_lagk_autocorr(size_t n, const vec_t &data, size_t k, double mean)
bool logy
If true, use a logarithmic y scale.
int hist_size_int
Histogram size.
void run(int argc, char *argv[])
Main public interface.
int open(std::string fname, bool err_on_fail=true)
int setd_mat_copy(std::string name, const ubmatrix &m)
int setd_vec_copy(std::string name, const vec_t &v)
const double & get_wgt_i(size_t i) const
double user_ylow
Lower y value.
int get_szt_def(std::string name, size_t def, size_t &i)
int verbose
Verbosity (default 1)
const double one_sigma
The one-sigma limit of a normal distribution, 0.6827.
void set_szt(std::string name, size_t u)
int getd(std::string name, double &d)
void setd(std::string name, double d)
double get_grid_x(size_t ix)
void set_nlines(size_t il)
size_t get_nlines() const
int n_blocks
Number of blocks.
void set_bin_edges(uniform_grid< double > gx, uniform_grid< double > gy)
double & get(size_t ix, size_t iy, std::string name)
double user_yhigh
Upper y value.
void hdf_output(hdf_file &hf, o2scl::table3d &h, std::string name)
void set_data(size_t sizex, size_t sizey, const vec_t &x_fun, const vec_t &y_fun, const mat_t &udata)
void seti(std::string name, int i)
double get_y_rep_i(size_t j)
process()
Create the process object.
int run_auto(int argc, char *argv[], int debug=0)
int get_szt(std::string name, size_t &u)
const ubmatrix & get_slice(std::string scol) const
format_float ff
Formatter for floating point numbers.
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.
double get_rep_i(size_t i)
std::string get_column_name(size_t icol) const
void open_or_create(std::string fname)
int ylimits(std::vector< std::string > &sv, bool itive_com)
Set limits for the y-axis.
double user_xhigh
Upper x value.
void update(double x, double y, double val=1.0)
void line_of_names(std::string newheads)
int contours(std::vector< std::string > &sv, bool itive_com)
Specify which contour levels to use.
#define O2SCL_ERR2(d, d2, n)
const double two_sigma
The two-sigma limit of a normal distribution, 0.9545.
std::string constraint
Constraint to apply to the data.
Processing MCMC data from bamr.
bool errors
If true, plot errors in 1d.
int hist2(std::vector< std::string > &sv, bool itive_com)
Create a two-dimensional histogram from two user-specified columns.
void line_of_data(size_t nv, const vec2_t &v)
bool xset
If true, x limits are set.
int set_comm_option_vec(size_t list_size, vec_t &option_list)
double get_x_rep_i(size_t i)
bool logx
If true, use a logarithmic x scale.
double vector_integ_linear(size_t n, vec_t &x, vec2_t &y)
void vector_invert_enclosed_sum(double sum, size_t n, vec_t &x, vec2_t &y, double &lev, int verbose=0)
double xscale
Scale for x-axis.
void delete_rows(std::string func)
size_t get_ncolumns() const
const double & get_wgt_i(size_t i, size_t j) const
void vector_grid(uniform_grid< data_t > g, vec_t &v)
int hist(std::vector< std::string > &sv, bool itive_com)
Create a histogram from a specified column.
void new_column(std::string head)
int auto_corr(std::vector< std::string > &sv, bool itive_com)
Create a table of autocorrelation data from a specified column.
double get_grid_y(size_t iy)
void update(double x, double val=1.0)
void set(size_t ix, size_t iy, std::string name, double val)
double vector_sum_double(size_t n, vec_t &data)
int combine(std::vector< std::string > &sv, bool itive_com)
Combine several bamr output files.
void new_slice(std::string name)
int sets_vec(std::string name, std::vector< std::string > &s)
void set(std::string scol, size_t row, double val)
size_t stoszt(std::string s, bool err_on_fail=true)
double user_xlow
Lower x value.
int gets_vec(std::string name, std::vector< std::string > &s)
bool logz
If true, use a logarithmic z scale.
int line_start
Ignore all lines before start.
void set_levels(size_t nlevels, vec_t &ulevels)
void calc_contours(std::vector< contour_line > &clines)
int getd_vec_copy(std::string name, vec_t &v)
const double three_sigma
The three-sigma limit of a normal distribution, 0.9973.
int xlimits(std::vector< std::string > &sv, bool itive_com)
Set limits for the x-axis.
void set_bin_edges(uniform_grid< double > g)
std::map< std::string, parameter *, std::greater< std::string > > par_list
double function_to_double(std::string s, bool err_on_fail=true)
void set_xy(std::string x_name, size_t nx, const vec_t &x, std::string y_name, size_t ny, const vec2_t &y)
vector< double > cont_levels
Contour levels set in 'contours'.
std::string szttos(size_t x)
void hdf_input(hdf_file &hf, o2scl::table< vec_t > &t, std::string name)
void vector_find_level(double level, size_t n, vec_t &x, vec2_t &y, std::vector< double > &locs)
double get(std::string scol, size_t row) const
void inc_maxlines(size_t llines)
virtual void swap_column_data(std::string scol, vec_t &v)
double yscale
Scale for y-axis.