From f77885e968e30b28669b4d24af75ec4e7bb0a41e Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Fri, 17 Feb 2017 23:33:55 +0800 Subject: Remove unused 'fit_{lt,mt}_{bpl,pl}.cpp' tools --- mass_profile/Makefile | 18 +-- mass_profile/fit_lt_bpl.cpp | 336 ------------------------------------------ mass_profile/fit_lt_pl.cpp | 239 ------------------------------ mass_profile/fit_mt_bpl.cpp | 350 -------------------------------------------- mass_profile/fit_mt_pl.cpp | 265 --------------------------------- 5 files changed, 2 insertions(+), 1206 deletions(-) delete mode 100644 mass_profile/fit_lt_bpl.cpp delete mode 100644 mass_profile/fit_lt_pl.cpp delete mode 100644 mass_profile/fit_mt_bpl.cpp delete mode 100644 mass_profile/fit_mt_pl.cpp (limited to 'mass_profile') diff --git a/mass_profile/Makefile b/mass_profile/Makefile index 67e9aae..a2067ad 100644 --- a/mass_profile/Makefile +++ b/mass_profile/Makefile @@ -23,10 +23,8 @@ endif OPT_UTIL_INC ?= -I../opt_utilities -TARGETS= fit_dbeta_sbp fit_beta_sbp \ - fit_wang2012_model \ - fit_nfw_mass fit_mt_pl fit_lt_pl fit_mt_bpl \ - fit_lt_bpl calc_lx_dbeta calc_lx_beta +TARGETS= fit_dbeta_sbp fit_beta_sbp fit_wang2012_model \ + fit_nfw_mass calc_lx_dbeta calc_lx_beta HEADERS= projector.hpp spline.hpp vchisq.hpp all: $(TARGETS) @@ -52,18 +50,6 @@ calc_lx_dbeta: calc_lx_dbeta.o beta_cfg.o report_error.o calc_lx_beta: calc_lx_beta.o beta_cfg.o dump_fit_qdp.o $(CXX) $(CXXFLAGS) $^ -o $@ $(OPT_UTIL_INC) -fit_mt_pl: fit_mt_pl.cpp - $(CXX) $(CXXFLAGS) $< -o $@ $(OPT_UTIL_INC) - -fit_lt_pl: fit_lt_pl.cpp - $(CXX) $(CXXFLAGS) $< -o $@ $(OPT_UTIL_INC) - -fit_mt_bpl: fit_mt_bpl.cpp - $(CXX) $(CXXFLAGS) $< -o $@ $(OPT_UTIL_INC) - -fit_lt_bpl: fit_lt_bpl.cpp - $(CXX) $(CXXFLAGS) $< -o $@ $(OPT_UTIL_INC) - fit_dbeta_sbp.o: fit_dbeta_sbp.cpp constrained_dbeta.hpp $(HEADERS) $(CXX) $(CXXFLAGS) -c $< $(OPT_UTIL_INC) diff --git a/mass_profile/fit_lt_bpl.cpp b/mass_profile/fit_lt_bpl.cpp deleted file mode 100644 index 0c06b22..0000000 --- a/mass_profile/fit_lt_bpl.cpp +++ /dev/null @@ -1,336 +0,0 @@ -/* - Perform a double-beta density model fitting to the surface brightness data - Author: Junhua Gu - Last modified: 2011.01.01 - This code is distributed with no warrant -*/ - -//#define HAVE_X_ERROR -#include -#include -#include -#include -#include -#include -#include "statistics/chisq.hpp" -#include "statistics/logchisq.hpp" -#include "statistics/leastsq.hpp" -#include -#include -#include -#include - -using namespace std; -using namespace opt_utilities; -//double s=5.63136645E20; -const double kpc=3.086E21;//kpc in cm -const double Mpc=kpc*1000; -const double pi=4*atan(1); -double std_norm_rand() -{ - double u=0; - double v=0; - while(u<=0||v<=0) - { - u=rand()/(double)RAND_MAX; - rand(); - v=rand()/(double)RAND_MAX; - } - double x=std::sqrt(-log(u))*cos(2*pi*v); - return x; -} - -double shuffle_data(double xc,double xl,double xu) -{ - double lxc=log(xc); - double lxl=log(xc-xl)-log(xc); - double lxu=log(xc+xu)-log(xc); - - if(std_norm_rand()>0) - { - double result=std::exp(lxc-std::abs(std_norm_rand()*lxl)); - return result; - } - else - { - double result=std::exp(lxc+std::abs(std_norm_rand()*lxu)); - return result; - } -} - -int main(int argc,char* argv[]) -{ - srand(time(0)); - if(argc!=4) - { - cerr<<"Usage:"< "<0); - ifstream ifs_data(argv[1]); - default_data_set ds; - ofstream ofs_result("l-t_bpl_result.qdp"); - ofs_result<<"read terr 1 2"<>T>>Tl>>Tu>>M>>Ml>>Mu; - if(!ifs_data.good()) - { - break; - } - line+=" "; - istringstream iss(line); - - if(line[0]=='#') - { - if(!is_first_nonono) - { - ofs_result<<"no no no"<>T>>Tl>>Tu>>L>>Ll; - Lu=Ll; - //std::cerr<std::abs(L)) - { - continue; - } - Tl=std::abs(Tl); - Tu=std::abs(Tu); - Ll=std::abs(Ll); - Lu=std::abs(Lu); - ofs_result<Tb) - { - sxxl+=log(x)*log(x); - sxl+=log(x); - syl+=log(y); - sxyl+=log(y)*log(x); - s1l+=1; - } - else - { - sxxu+=log(x)*log(x); - sxu+=log(x); - syu+=log(y); - sxyu+=log(y)*log(x); - s1u+=1; - } - data d(x,y,std::abs(yl),std::abs(yu), - std::abs(xl),std::abs(xu)); - ds.add_data(d); - } - - double Ml=sxxl*s1l-sxl*sxl; - double Mal=sxyl*s1l-syl*sxl; - 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);; - - - - ofs_result<<"no no no"<,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()); - fit.load_data(ds); - - cerr<<"k0l="< >()); - fit.fit(); - std::vector p=fit.fit(); - Tb=fit.get_param_value("bpx"); - ///std::cout<<"chi="< mean_p(p.size()); - std::vector mean_p2(p.size()); - int cnt=0; - for(int n=0;n<100;++n) - { - ++cnt; - cerr<<"."; - double sxxl=0; - double s1l=0; - double sxl=0; - double syl=0; - double sxyl=0; - - double sxxu=0; - double s1u=0; - double sxu=0; - double syu=0; - double sxyu=0; - - opt_utilities::default_data_set ds1; - for(size_t i=0;i(new_x,new_y, - yl/y*new_y, - yu/y*new_y, - xl/x*new_x, - xu/x*new_x)); - - x=new_x; - y=new_y; - if(x>Tb) - { - sxxl+=log(x)*log(x); - sxl+=log(x); - syl+=log(y); - sxyl+=log(y)*log(x); - s1l+=1; - } - else - { - sxxu+=log(x)*log(x); - sxu+=log(x); - syu+=log(y); - sxyu+=log(y)*log(x); - s1u+=1; - } - } - double Ml=sxxl*s1l-sxl*sxl; - double Mal=sxyl*s1l-syl*sxl; - 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(size_t i=0;i std_p(p.size()); - cerr< -#include -#include -#include -#include -#include "statistics/chisq.hpp" -#include "statistics/leastsq.hpp" -#include -#include -#include - -using namespace std; -using namespace opt_utilities; -//double s=5.63136645E20; -const double kpc=3.086E21;//kpc in cm -const double Mpc=kpc*1000; -const double pi=4*atan(1); -double std_norm_rand() -{ - double x=0; - double u=0; - double v=0; - - do - { - u=rand()/(double)RAND_MAX; - rand(); - v=rand()/(double)RAND_MAX; - - x=std::sqrt(-log(u))*cos(2*pi*v); - }while(isnan(x)); - return x; -} - -double shuffle_data(double xc,double xl,double xu) -{ - double result=0; - assert(!isnan(xc)); - assert(!isnan(xl)); - assert(!isnan(xu)); - if(std_norm_rand()>0) - { - result=xc-std::abs(std_norm_rand()*xl); - } - else - { - result=xc+std::abs(std_norm_rand()*xu); - } - assert(!isnan(result)); - return result; -} - -int main(int argc,char* argv[]) -{ - if(argc!=3) - { - cerr<<"Usage:"< "< ds; - ofstream ofs_result("l-t_result.qdp"); - ofs_result<<"read terr 1"<>T>>Tl>>Tu>>L>>Lerr; - //std::cerr< data, skipped"< d(x,y,std::abs(yl),std::abs(yu), - std::abs(xl),std::abs(xu)); - ds.add_data(d); - } - - double M=sxx*s1-sx*sx; - double Ma=sxy*s1-sy*sx; - 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 >()); - fit.set_statistic(chisq,double,std::string>()); - //fit.set_statistic(leastsq,double,std::string>()); - fit.set_model(lin1d()); - fit.load_data(ds); - - cerr<<"k0="< p=fit.fit(); - for(double i=.5;i<12;i*=1.01) - { - ofs_result< ds1; - for(size_t i=0;i(new_x,new_y, - ds.get_data(i).get_y_lower_err(), - ds.get_data(i).get_y_upper_err(), - ds.get_data(i).get_y_lower_err(), - ds.get_data(i).get_y_upper_err())); - //cerr< -#include -#include -#include -#include -#include -#include "statistics/chisq.hpp" -#include "statistics/logchisq.hpp" -#include "statistics/leastsq.hpp" -#include -#include -#include -#include - -using namespace std; -using namespace opt_utilities; -//double s=5.63136645E20; -const double kpc=3.086E21;//kpc in cm -const double Mpc=kpc*1000; -const double pi=4*atan(1); -double std_norm_rand() -{ - double u=0; - double v=0; - while(u<=0||v<=0) - { - u=rand()/(double)RAND_MAX; - rand(); - v=rand()/(double)RAND_MAX; - } - double x=std::sqrt(-log(u))*cos(2*pi*v); - return x; -} - -double shuffle_data(double xc,double xl,double xu) -{ - double lxc=log(xc); - double lxl=log(xc-xl)-log(xc); - double lxu=log(xc+xu)-log(xc); - - if(std_norm_rand()>0) - { - double result=std::exp(lxc-std::abs(std_norm_rand()*lxl)); - return result; - } - else - { - double result=std::exp(lxc+std::abs(std_norm_rand()*lxu)); - return result; - } -} - -int main(int argc,char* argv[]) -{ - srand(time(0)); - if(argc!=4) - { - cerr<<"Usage:"< "<0); - ifstream ifs_data(argv[1]); - default_data_set ds; - ofstream ofs_result("m-t_bpl_result.qdp"); - ofs_result<<"read terr 1 2"<>T>>Tl>>Tu>>M>>Ml>>Mu; - if(!ifs_data.good()) - { - break; - } - line+=" "; - istringstream iss(line); - - if(line[0]=='#') - { - if(!is_first_nonono) - { - ofs_result<<"no no no"<>T>>Tl>>Tu>>M>>Ml>>Mu; - //std::cerr<std::abs(M)) - { - continue; - } - Tl=std::abs(Tl); - Tu=std::abs(Tu); - Ml=std::abs(Ml); - Mu=std::abs(Mu); - ofs_result<Tb) - { - sxxl+=log(x)*log(x); - sxl+=log(x); - syl+=log(y); - sxyl+=log(y)*log(x); - s1l+=1; - } - else - { - sxxu+=log(x)*log(x); - sxu+=log(x); - syu+=log(y); - sxyu+=log(y)*log(x); - s1u+=1; - } - data d(x,y,std::abs(yl),std::abs(yu), - std::abs(xl),std::abs(xu)); - ds.add_data(d); - } - - double Ml=sxxl*s1l-sxl*sxl; - double Mal=sxyl*s1l-syl*sxl; - 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);; - - - - ofs_result<<"no no no"<,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()); - fit.load_data(ds); - - cerr<<"k0l="< >()); - fit.fit(); - std::vector p=fit.fit(); - Tb=fit.get_param_value("bpx"); - //std::cout<<"chi="< mean_p(p.size()); - std::vector mean_p2(p.size()); - int cnt=0; - for(int n=0;n<100;++n) - { - ++cnt; - cerr<<"."; - double sxxl=0; - double s1l=0; - double sxl=0; - double syl=0; - double sxyl=0; - - double sxxu=0; - double s1u=0; - double sxu=0; - double syu=0; - double sxyu=0; - - opt_utilities::default_data_set ds1; - for(size_t i=0;i(new_x,new_y, - yl/y*new_y, - yu/y*new_y, - xl/x*new_x, - xu/x*new_x)); - - x=new_x; - y=new_y; - if(x>Tb) - { - sxxl+=log(x)*log(x); - sxl+=log(x); - syl+=log(y); - sxyl+=log(y)*log(x); - s1l+=1; - } - else - { - sxxu+=log(x)*log(x); - sxu+=log(x); - syu+=log(y); - sxyu+=log(y)*log(x); - s1u+=1; - } - } - double Ml=sxxl*s1l-sxl*sxl; - double Mal=sxyl*s1l-syl*sxl; - 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(size_t i=0;i std_p(p.size()); - cerr< -#include -#include -#include -#include -#include -#include "statistics/chisq.hpp" -#include "statistics/leastsq.hpp" -#include "statistics/robust_chisq.hpp" -#include -#include -#include - -using namespace std; -using namespace opt_utilities; -//double s=5.63136645E20; -const double kpc=3.086E21;//kpc in cm -const double Mpc=kpc*1000; -const double pi=4*atan(1); -double std_norm_rand() -{ - double u=0; - double v=0; - while(u<=0||v<=0) - { - u=rand()/(double)RAND_MAX; - rand(); - v=rand()/(double)RAND_MAX; - } - double x=std::sqrt(-log(u))*cos(2*pi*v); - return x; -} - -double shuffle_data(double xc,double xl,double xu) -{ - if(std_norm_rand()>0) - { - double result=xc-std::abs(std_norm_rand()*xl); - return result; - } - else - { - double result= xc+std::abs(std_norm_rand()*xu); - return result; - } -} - -int main(int argc,char* argv[]) -{ - if(argc!=3) - { - cerr<<"Usage:"< "< ds; - ofstream ofs_result("m-t_result.qdp"); - ofs_result<<"read terr 1 2"<>T>>Tl>>Tu>>M>>Ml>>Mu; - if(!ifs_data.good()) - { - break; - } - line+=" "; - istringstream iss(line); - - if(line[0]=='#') - { - if(!is_first_nonono) - { - ofs_result<<"no no no"<>T>>Tl>>Tu>>M>>Ml>>Mu; - //std::cerr< data, skipped"< d(x,y,std::abs(yl),std::abs(yu), - std::abs(xl),std::abs(xu)); - ds.add_data(d); - } - - double M=sxx*s1-sx*sx; - double Ma=sxy*s1-sy*sx; - 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 >()); - fit.set_statistic(chisq,double,std::string>()); - //fit.set_statistic(robust_chisq,double,std::string>()); - //fit.set_statistic(leastsq,double,std::string>()); - fit.set_model(lin1d()); - fit.load_data(ds); - - cerr<<"k0="< p=fit.get_all_params(); - std::cout<<"chi="< ds1; - for(size_t i=0;i(new_x,new_y, - ds.get_data(i).get_y_lower_err(), - ds.get_data(i).get_y_upper_err(), - ds.get_data(i).get_y_lower_err(), - ds.get_data(i).get_y_upper_err())); - } - fit.load_data(ds1); - - fit.fit(); - double k=fit.get_param_value("k"); - double b=fit.get_param_value("b"); - double A=exp(b); - double g=k; - mean_A+=A; - mean_A2+=A*A; - mean_g+=g; - mean_g2+=g*g; - } - std::cerr<