From 6994a9715f05fd49f60a4346171a1d9226ec98d9 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Wed, 8 Jun 2016 10:26:30 +0800 Subject: mass_profile: fix many compilation warnings --- mass_profile/beta.hpp | 4 +- mass_profile/calc_lx.cpp | 16 +++--- mass_profile/calc_lx_beta.cpp | 79 ++++++++++++--------------- mass_profile/calc_lx_dbeta.cpp | 103 +++++++++++++++++------------------- mass_profile/chisq.hpp | 26 +++++---- mass_profile/dbeta.hpp | 10 ++-- mass_profile/dump_fit_qdp.cpp | 14 ++--- mass_profile/fit_beta_sbp.cpp | 40 +++++++------- mass_profile/fit_dbeta_sbp.cpp | 55 +++++++++---------- mass_profile/fit_direct_beta.cpp | 10 ++-- mass_profile/fit_lt_bpl.cpp | 42 +++++++-------- mass_profile/fit_lt_pl.cpp | 22 ++++---- mass_profile/fit_mt_bpl.cpp | 44 +++++++-------- mass_profile/fit_mt_pl.cpp | 18 +++---- mass_profile/fit_nfw_mass.cpp | 22 ++++---- mass_profile/fit_nfw_sbp.cpp | 34 ++++++------ mass_profile/fit_wang2012_model.cpp | 20 +++---- mass_profile/nfw_ne.hpp | 20 +++---- mass_profile/projector.hpp | 8 +-- mass_profile/vchisq.hpp | 32 +++++------ 20 files changed, 300 insertions(+), 319 deletions(-) (limited to 'mass_profile') diff --git a/mass_profile/beta.hpp b/mass_profile/beta.hpp index 4e6264c..6ae70ac 100644 --- a/mass_profile/beta.hpp +++ b/mass_profile/beta.hpp @@ -13,7 +13,7 @@ namespace opt_utilities { this->push_param_info(param_info,std::string>("n0",1,0,1E99)); this->push_param_info(param_info,std::string>("beta",.66,0,1E99)); - this->push_param_info(param_info,std::string>("rc",100,0,1E99)); + this->push_param_info(param_info,std::string>("rc",100,0,1E99)); } public: @@ -30,7 +30,7 @@ namespace opt_utilities T rc=p[2]; std::vector result(x.size()-1); - for(int i=1;i,double,string> f; - + f.set_statistic(chisq,double,string>()); f.set_opt_method(powell_method >()); f.set_model(beta1d()); @@ -74,7 +74,7 @@ int main(int argc,char* argv[]) double rmax=f.get_data_set().get_data(f.get_data_set().size()-1).get_x(); ofstream lx_fit_result("lx_fit_result.qdp"); lx_fit_result<<"read terr 1 2\nskip single\n"; - for(int i=0;i ds(dl.get_data_set()); opt_utilities::default_data_set ds1; - for(int i=0;i >::iterator i=cfg.param_map.begin(); i!=cfg.param_map.end();++i) @@ -280,12 +269,14 @@ int main(int argc,char* argv[]) f.fit(); f.fit(); std::vector p=f.get_all_params(); + /* n0=f.get_param_value("n0"); rc=f.get_param_value("rc"); beta=f.get_param_value("beta"); + */ //output the datasets and fitting results ofstream param_output("lx_beta_param.txt"); - for(int i=0;i& pj=dynamic_cast&>(f.get_model()); pj.attach_cfunc(cf_bolo_erg); - - - + + + mv=f.eval_model_raw(radii,p); double flux_erg=0; - for(int i=0;i,std::vector,std::vector,std::string>("rc2") ); } - + f.fit(); - + f.clear_param_modifier(); //then perform the fitting, freeze beta1 and beta2 @@ -341,9 +332,11 @@ int main(int argc,char* argv[]) //finally thaw all parameters f.fit(); + + /* double beta1=0; double beta2=0; - + n01=f.get_param_value("n01"); rc1=f.get_param_value("rc1"); n02=f.get_param_value("n02"); @@ -359,10 +352,12 @@ int main(int argc,char* argv[]) beta1=f.get_param_value("beta1"); beta2=f.get_param_value("beta2"); } + */ + //output the params ofstream param_output("lx_dbeta_param.txt"); //output the datasets and fitting results - for(int i=0;i& pj=dynamic_cast&>(f.get_model()); pj.attach_cfunc(cf_bolo_erg); - + mv=f.eval_model_raw(radii,p); double flux_erg=0; - for(int i=0;i* do_clone()const { // return const_cast*>(this); @@ -76,15 +76,15 @@ namespace opt_utilities chisq() :verb(true),limit_bound(false) {} - - + + Ty do_eval(const Tp& p) { if(limit_bound) { Tp p1=this->get_fitter().get_model().reform_param(p); - for(int i=0;ithis->get_fitter().get_param_info(i).get_upper_limit()|| p1[i]get_fitter().get_param_info(i).get_lower_limit()) @@ -111,7 +111,7 @@ namespace opt_utilities vye2.resize(this->get_data_set().size()); my.resize(this->get_data_set().size()); } - + } for(int i=(this->get_data_set()).size()-1;i>=0;--i) @@ -132,7 +132,7 @@ namespace opt_utilities Ty y_model=this->eval_model(this->get_data_set().get_data(i).get_x(),p); Ty y_obs=this->get_data_set().get_data(i).get_y(); Ty y_err; - + Ty errx=0; if(errx1get_data_set().get_data(i).get_x(); @@ -178,7 +178,7 @@ namespace opt_utilities vye1.at(i)=std::abs(this->get_data_set().get_data(i).get_y_lower_err()); vye2.at(i)=std::abs(this->get_data_set().get_data(i).get_y_upper_err()); my.at(i)=y_model; - + xmin=std::min(vx.at(i),xmin); ymin=std::min(vy.at(i),ymin-vye1[i]); xmax=std::max(vx.at(i),xmax); @@ -192,7 +192,7 @@ namespace opt_utilities if(n%display_interval==0) { cerr<push_param_info(param_info,std::string>("n02",1)); this->push_param_info(param_info,std::string>("beta2",.67)); this->push_param_info(param_info,std::string>("rc2",110)); - + } public: @@ -44,10 +44,10 @@ namespace opt_utilities T beta2=p[4]; T rc2=p[5]; - + std::vector result(x.size()-1); - for(int i=1;ipush_param_info(param_info,std::string>("n02",1)); this->push_param_info(param_info,std::string>("rc2",110)); this->push_param_info(param_info,std::string>("beta",.67)); - + } public: @@ -92,7 +92,7 @@ namespace opt_utilities T beta2=beta; std::vector result(x.size()-1); - for(int i=1;i p=f.get_all_params(); - for(int i=1;i p=f.get_all_params(); std::vector mv=f.eval_model_raw(r,p); - for(int i=1;i>x>>y; if(!ifs.good()) { @@ -251,7 +251,7 @@ int main(int argc,char* argv[]) //double beta=atof(arg_map["beta"].c_str()); double beta=0; double rc=0; - double bkg=0; + double bkg_level=0; for(std::map >::iterator i=cfg.param_map.begin(); i!=cfg.param_map.end();++i) @@ -285,7 +285,7 @@ int main(int argc,char* argv[]) beta=f.get_param_value("beta"); //output the datasets and fitting results ofstream param_output("beta_param.txt"); - for(int i=0;i>x>>y; if(!ifs.good()) { @@ -270,7 +270,7 @@ int main(int argc,char* argv[]) double n02=0; double rc2=0; double beta=0; - double bkg=0; + double bkg_level=0; if(tie_beta) { f.set_param_value("beta",.7); @@ -362,7 +362,7 @@ int main(int argc,char* argv[]) //output the params ofstream param_output("dbeta_param.txt"); //output the datasets and fitting results - for(int i=0;i,double,string> f; - + f.set_statistic(chisq,double,string>()); f.set_opt_method(powell_method >()); f.set_model(beta1d()); @@ -31,11 +31,11 @@ int main(int argc,char* argv[]) ifs>>dl; f.load_data(dl.get_data_set()); f.fit(); - + double rmin=f.get_data_set().get_data(0).get_x(); double rmax=f.get_data_set().get_data(f.get_data_set().size()-1).get_x(); cout<<"read terr 1 2\nskip single\n"; - for(int i=0;i,double,std::string> fit; fit.set_opt_method(powell_method >()); - + fit.set_statistic(logchisq,double,std::string>()); //fit.set_statistic(leastsq,double,std::string>()); fit.set_model(bpl1d()); @@ -208,7 +208,7 @@ int main(int argc,char* argv[]) cerr<<"k0l="< mean_p(p.size()); std::vector mean_p2(p.size()); int cnt=0; @@ -238,7 +238,7 @@ int main(int argc,char* argv[]) double sxl=0; double syl=0; double sxyl=0; - + double sxxu=0; double s1u=0; double sxu=0; @@ -246,7 +246,7 @@ int main(int argc,char* argv[]) double sxyu=0; opt_utilities::default_data_set ds1; - for(int i=0;i(new_x,new_y, yl/y*new_y, yu/y*new_y, @@ -292,40 +292,40 @@ int main(int argc,char* argv[]) double Mbl=sxxl*syl-sxl*sxyl; double k0l=Mal/Ml; double b0l=Mbl/Ml; - + double Mu=sxxu*s1u-sxu*sxu; double Mau=sxyu*s1u-syu*sxu; double Mbu=sxxu*syu-sxu*sxyu; double k0u=Mau/Mu; double b0u=Mbu/Mu; - + double gamma0l=k0l; double gamma0u=k0u; - + double ampl0l=exp(b0l)*pow(Tb,gamma0l); double ampl0u=exp(b0u)*pow(Tb,gamma0u);; - + fit.set_param_value("bpx",Tb); fit.set_param_value("bpy",(ampl0l+ampl0u)/2); fit.set_param_value("gamma1",gamma0l); fit.set_param_value("gamma2",gamma0u); - - + + fit.load_data(ds1); - + fit.fit(); vector p=fit.fit(); - for(int i=0;i std_p(p.size()); cerr< "< ds; ofstream ofs_result("l-t_result.qdp"); @@ -91,15 +91,15 @@ int main(int argc,char* argv[]) double L,Lerr; std::string line; getline(ifs_data,line); - - + + if(!ifs_data.good()) { break; } line+=" "; istringstream iss(line); - + if(line[0]=='#') { if(!is_first_nonono) @@ -163,7 +163,7 @@ int main(int argc,char* argv[]) double Mb=sxx*sy-sx*sxy; double k0=Ma/M; double b0=Mb/M; - + ofs_result<<"no no no"<,double,std::string> fit; fit.set_opt_method(powell_method >()); @@ -185,7 +185,7 @@ int main(int argc,char* argv[]) ofs_result< ds1; - for(int i=0;i0) { double result=std::exp(lxc-std::abs(std_norm_rand()*lxl)); @@ -107,7 +107,7 @@ int main(int argc,char* argv[]) } line+=" "; istringstream iss(line); - + if(line[0]=='#') { if(!is_first_nonono) @@ -145,7 +145,7 @@ int main(int argc,char* argv[]) cerr<,double,std::string> fit; fit.set_opt_method(powell_method >()); - + fit.set_statistic(logchisq,double,std::string>()); //fit.set_statistic(leastsq,double,std::string>()); fit.set_model(bpl1d()); @@ -222,7 +222,7 @@ int main(int argc,char* argv[]) cerr<<"k0l="< mean_p(p.size()); std::vector mean_p2(p.size()); int cnt=0; @@ -252,7 +252,7 @@ int main(int argc,char* argv[]) double sxl=0; double syl=0; double sxyl=0; - + double sxxu=0; double s1u=0; double sxu=0; @@ -260,7 +260,7 @@ int main(int argc,char* argv[]) double sxyu=0; opt_utilities::default_data_set ds1; - for(int i=0;i(new_x,new_y, yl/y*new_y, yu/y*new_y, @@ -306,40 +306,40 @@ int main(int argc,char* argv[]) double Mbl=sxxl*syl-sxl*sxyl; double k0l=Mal/Ml; double b0l=Mbl/Ml; - + double Mu=sxxu*s1u-sxu*sxu; double Mau=sxyu*s1u-syu*sxu; double Mbu=sxxu*syu-sxu*sxyu; double k0u=Mau/Mu; double b0u=Mbu/Mu; - + double gamma0l=k0l; double gamma0u=k0u; - + double ampl0l=exp(b0l)*pow(Tb,gamma0l); double ampl0u=exp(b0u)*pow(Tb,gamma0u);; - + fit.set_param_value("bpx",Tb); fit.set_param_value("bpy",(ampl0l+ampl0u)/2); fit.set_param_value("gamma1",gamma0l); fit.set_param_value("gamma2",gamma0u); - - + + fit.load_data(ds1); - + fit.fit(); vector p=fit.fit(); - for(int i=0;i std_p(p.size()); cerr<,double,std::string> fit; fit.set_opt_method(powell_method >()); @@ -203,12 +203,12 @@ int main(int argc,char* argv[]) ofs_resid<<"skip single"< ds1; - for(int i=0;i p=fit.fit(); //output parameters ofstream ofs_param("nfw_param.txt"); - for(int i=0;i d=ds.get_data(i); double x=d.get_x(); @@ -155,5 +155,5 @@ int main(int argc,char* argv[]) { ofs_fit_result< radii;//to store radius std::vector sbps;//to store the surface brightness value std::vector sbpe;//to store the sbp error @@ -148,8 +148,8 @@ int main(int argc,char* argv[]) About the format of the radius file: the radius file contains only radius, separated by space or line feed (i.e., the key). the unit should be pixel - - The number of radius can be larger than the number of annuli+1, the exceeded radius can be used + + The number of radius can be larger than the number of annuli+1, the exceeded radius can be used to calculate the influence of outer shells. */ int ncut=0; @@ -208,7 +208,7 @@ int main(int argc,char* argv[]) for(ifstream ifs(arg_map["cfunc_file"].c_str());;) { assert(ifs.is_open()); - double x,y,y1,y2; + double x,y; ifs>>x>>y; if(!ifs.good()) { @@ -250,7 +250,7 @@ int main(int argc,char* argv[]) nfw.set_cm_per_pixel(cm_per_pixel); //define the temperature profile model spline_func_obj tf; - + for(ifstream ifs_tfunc(arg_map["T_file"].c_str());;) { assert(ifs_tfunc.is_open()); @@ -286,8 +286,8 @@ int main(int argc,char* argv[]) f.set_param_value("n0",n0); f.set_param_value("rho0",rho0); f.set_param_value("rs",rs); - - + + f.set_param_value("bkg",bkg); cout< radius_list; std::vector delta_list; @@ -380,8 +380,8 @@ int main(int argc,char* argv[]) */ ofs_overdensity<=200&&delta_list[i+1]<200) diff --git a/mass_profile/fit_wang2012_model.cpp b/mass_profile/fit_wang2012_model.cpp index 3fe14b6..f15a2b1 100644 --- a/mass_profile/fit_wang2012_model.cpp +++ b/mass_profile/fit_wang2012_model.cpp @@ -2,7 +2,7 @@ Fitting Jy Wang's temperature profile model Author: Jingying Wang Last modification 20120819 - + */ #include "wang2012_model.hpp" @@ -34,7 +34,7 @@ int main(int argc,char* argv[]) { cm_per_pixel=atof(argv[3]); } - + //define the fitter fitter,double,std::string> fit; //define the data set @@ -88,7 +88,7 @@ int main(int argc,char* argv[]) fit.set_statistic(chisq_object); //fit.set_statistic(chisq,double,std::string>()); fit.set_model(wang2012_model()); - + if(argc>=3&&std::string(argv[2])!="NONE") { std::vector freeze_list; @@ -123,7 +123,7 @@ int main(int argc,char* argv[]) { freeze_param,std::string> fp(freeze_list[0]); fit.set_param_modifier(fp); - for(int i=1;i,std::string>&>(fit.get_param_modifier())+=freeze_param,std::string>(freeze_list[i]); } @@ -147,11 +147,11 @@ int main(int argc,char* argv[]) } #endif //output parameters - for(int i=0;i0) { diff --git a/mass_profile/nfw_ne.hpp b/mass_profile/nfw_ne.hpp index 5842bb8..8f23820 100644 --- a/mass_profile/nfw_ne.hpp +++ b/mass_profile/nfw_ne.hpp @@ -36,7 +36,7 @@ namespace opt_utilities { return rho0; } - + return nfw_mass_enclosed(r,rho0,rs)/(4.*pi/3*r*r*r); } @@ -46,7 +46,7 @@ namespace opt_utilities const double Omega_m=.27) { const double E=std::sqrt(Omega_m*(1+z)*(1+z)*(1+z)+1-Omega_m); - const double H=H0*E; + const double H=H0*E; return 3*H*H/8/pi/G; } @@ -66,7 +66,7 @@ namespace opt_utilities nfw_ne() :pTfunc(0),cm_per_pixel(1) { - + this->push_param_info(param_info,std::string>("rho0",1));//in mp this->push_param_info(param_info,std::string>("rs",100)); this->push_param_info(param_info,std::string>("n0",.01)); @@ -89,7 +89,7 @@ namespace opt_utilities this->push_param_info(param_info,std::string>("rs",rhs.get_param_info("rs").get_value())); this->push_param_info(param_info,std::string>("n0",rhs.get_param_info("n0").get_value())); } - + //assignment operator nfw_ne& operator=(const nfw_ne& rhs) { @@ -146,19 +146,19 @@ namespace opt_utilities */ std::vector do_eval(const std::vector & r, const std::vector& p) - { + { assert(pTfunc); //const T kT_erg=k*5; T rho0=std::abs(p[0])*mp; T rs=std::abs(p[1]); T n0=std::abs(p[2]); T rs_cm=rs*cm_per_pixel; - + std::vector yvec(r.size()); const T kT_erg0=pTfunc->eval((r.at(0)+r.at(1))/2)*k; //calculate the integration #pragma omp parallel for schedule(dynamic) - for(int i=0;ieval(r[i])*k; @@ -170,10 +170,10 @@ namespace opt_utilities //std::cout< ydxvec(r.size()-1); #pragma omp parallel for schedule(dynamic) - for(int i=1;i result(r.size()-1); #pragma omp parallel for schedule(dynamic) - for(int i=0;ieval(r[i])*k; diff --git a/mass_profile/projector.hpp b/mass_profile/projector.hpp index a9d5f2a..6f2f192 100644 --- a/mass_profile/projector.hpp +++ b/mass_profile/projector.hpp @@ -99,7 +99,7 @@ namespace opt_utilities void attach_model(const model,std::vector,std::vector >& m) { this->clear_param_info(); - for(int i=0;ipush_param_info(m.get_param_info(i)); } @@ -167,7 +167,7 @@ namespace opt_utilities } } std::vector p2(p1.size()-1); - for(int i=0;i unprojected(pmodel->eval(x,p)); std::vector projected(unprojected.size()); - for(int nrad=0;nrad Tp; - + vchisq* do_clone()const { return new vchisq(*this); @@ -38,7 +38,7 @@ namespace opt_utilities { return "chi^2 statistic"; } - + public: void verbose(bool v) { @@ -49,7 +49,7 @@ namespace opt_utilities { limit_bound=true; } - + void clear_limit() { limit_bound=false; @@ -58,8 +58,8 @@ namespace opt_utilities vchisq() :verb(false),limit_bound(false) {} - - + + T do_eval(const std::vector& p) { @@ -71,7 +71,7 @@ namespace opt_utilities } } T result(0); - + std::vector vx; std::vector vy; std::vector vye; @@ -80,7 +80,7 @@ namespace opt_utilities if(verb) { n++; - + if(n%100==0) { vx.resize(this->get_data_set().get_data(0).get_y().size()); @@ -88,24 +88,24 @@ namespace opt_utilities vye.resize(this->get_data_set().get_data(0).get_y().size()); my.resize(this->get_data_set().get_data(0).get_y().size()); } - + } for(int i=(this->get_data_set()).size()-1;i>=0;--i) { const std::vector y_model(this->eval_model(this->get_data_set().get_data(i).get_x(),p)); const std::vector& y=this->get_data_set().get_data(i).get_y(); const std::vector& ye=this->get_data_set().get_data(i).get_y_lower_err(); - for(int j=0;jget_data_set().get_data(i).get_x().at(j)+this->get_data_set().get_data(i).get_x().at(j+1))/2.); vy.at(j)=(y[j]); @@ -121,9 +121,9 @@ namespace opt_utilities my[j]=log10(my[j]); } - + } - + } if(verb) { @@ -148,7 +148,7 @@ namespace opt_utilities pr.plot_line(vx,my); } } - + return result; } }; -- cgit v1.2.2