From 61c7e9781c1bb3447fc5ae2362ebbac12158e4d3 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Fri, 17 Feb 2017 23:26:07 +0800 Subject: Remove the unused 'fit_nfw_sbp.cpp' with 'nfw_ne.hpp' --- mass_profile/Makefile | 7 +- mass_profile/fit_nfw_sbp.cpp | 416 ------------------------------------------- mass_profile/nfw_ne.hpp | 204 --------------------- 3 files changed, 1 insertion(+), 626 deletions(-) delete mode 100644 mass_profile/fit_nfw_sbp.cpp delete mode 100644 mass_profile/nfw_ne.hpp (limited to 'mass_profile') diff --git a/mass_profile/Makefile b/mass_profile/Makefile index c13b312..67e9aae 100644 --- a/mass_profile/Makefile +++ b/mass_profile/Makefile @@ -23,7 +23,7 @@ endif OPT_UTIL_INC ?= -I../opt_utilities -TARGETS= fit_nfw_sbp fit_dbeta_sbp fit_beta_sbp \ +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 @@ -33,8 +33,6 @@ all: $(TARGETS) # NOTE: # Object/source files should placed *before* libraries (order matters) -fit_nfw_sbp: fit_nfw_sbp.o - $(CXX) $(CXXFLAGS) $^ -o $@ $(OPT_UTIL_INC) fit_dbeta_sbp: fit_dbeta_sbp.o beta_cfg.o report_error.o $(CXX) $(CXXFLAGS) $^ -o $@ $(OPT_UTIL_INC) @@ -67,9 +65,6 @@ fit_lt_bpl: fit_lt_bpl.cpp $(CXX) $(CXXFLAGS) $< -o $@ $(OPT_UTIL_INC) -fit_nfw_sbp.o: fit_nfw_sbp.cpp nfw_ne.hpp $(HEADERS) - $(CXX) $(CXXFLAGS) -c $< $(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_nfw_sbp.cpp b/mass_profile/fit_nfw_sbp.cpp deleted file mode 100644 index 9ac8401..0000000 --- a/mass_profile/fit_nfw_sbp.cpp +++ /dev/null @@ -1,416 +0,0 @@ -/* - Fitting the surface brightness profile with an NFW-based surface brightness model - Author: Junhua Gu - Last modification 20120721 - The temperature is assumed to be an allen model with a minimum temperature assumed -*/ - - -#include -#include -#include "vchisq.hpp" -#include "nfw_ne.hpp" -#include -#include -#include -#include -#include "spline.hpp" - -using namespace std; -using namespace opt_utilities; - -//double s=5.63136645E20; -const double M_sun=1.988E33;//solar mass in g -const double kpc=3.086E21;//kpc in cm - -//A class enclosing the spline interpolation method -class spline_func_obj - :public func_obj -{ - //has an spline object - spline spl; -public: - //This function is used to calculate the intepolated value - double do_eval(const double& x) - { - /* - if(x<=spl.x_list[0]) - { - return spl.y_list[0]; - } - if(x>=spl.x_list.back()) - { - return spl.y_list.back(); - } - */ - return spl.get_value(x); - } - - //we need this function, when this object is performing a clone of itself - spline_func_obj* do_clone()const - { - return new spline_func_obj(*this); - } - -public: - //add points to the spline object, after which the spline will be initialized - void add_point(double x,double y) - { - spl.push_point(x,y); - } - - //before getting the intepolated value, the spline should be initialzied by calling this function - void gen_spline() - { - spl.gen_spline(0,0); - } -}; - -//Allen temperature model - -int main(int argc,char* argv[]) -{ - if(argc!=2) - { - cerr<"< arg_map; - //open the configuration file - ifstream cfg_file(argv[1]); - assert(cfg_file.is_open()); - for(;;) - { - std::string key; - std::string value; - cfg_file>>key>>value; - if(!cfg_file.good()) - { - cfg_file.close(); - break; - } - arg_map[key]=value; - } - //check whether following parameters are defined in the configuration file - assert(arg_map.find("radius_file")!=arg_map.end()); - assert(arg_map.find("sbp_file")!=arg_map.end()); - assert(arg_map.find("cfunc_file")!=arg_map.end()); - assert(arg_map.find("T_file")!=arg_map.end()); - assert(arg_map.find("z")!=arg_map.end()); - const double z=atof(arg_map["z"].c_str()); - double r_min=0; - if(arg_map.find("r_min")!=arg_map.end()) - { - r_min=atof(arg_map["r_min"].c_str()); - cerr<<"r_min presents and its value is "< radii;//to store radius - std::vector sbps;//to store the surface brightness value - std::vector sbpe;//to store the sbp error - //read in radius file - /* - 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 - to calculate the influence of outer shells. - */ - int ncut=0; - for(ifstream ifs(arg_map["radius_file"].c_str());;) - { - assert(ifs.is_open()); - double x; - ifs>>x; - if(!ifs.good()) - { - break; - } - if(x>x>>xe; - if(!ifs.good()) - { - break; - } - if(ncut) - { - --ncut; - continue; - } - cerr<>x>>y; - if(!ifs.good()) - { - break; - } - cerr<,std::vector > ds; - ds.add_data(data,std::vector >(radii,sbps,sbpe,sbpe,radii,radii)); - - //initial a fitter object - fitter,vector,vector,double> f; - //load the data set into the fitter object - f.load_data(ds); - //define a projector object - //see projector for more detailed information - projector a; - //define the nfw surface brightness profofile model - nfw_ne nfw; - //attach the cooling function into the projector - a.attach_cfunc(cf); - assert(arg_map.find("cm_per_pixel")!=arg_map.end()); - //set the cm to pixel ratio - double cm_per_pixel=atof(arg_map["cm_per_pixel"].c_str()); - a.set_cm_per_pixel(cm_per_pixel); - 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()); - double x,y; - ifs_tfunc>>x>>y; - if(!ifs_tfunc.good()) - { - break; - } - if(x c; - c.verbose(true); - f.set_statistic(c); - //set the optimization method, here we use powell method - f.set_opt_method(powell_method >()); - //set the initial values - double n0=atof(arg_map["n0"].c_str()); - double rho0=atof(arg_map["rho0"].c_str()); - double rs=atof(arg_map["rs"].c_str()); - double bkg=atof(arg_map["bkg"].c_str()); - 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< p=f.get_all_params(); - f.clear_param_modifier(); - std::vector mv=f.eval_model(radii,p); - cerr< radius_list; - std::vector delta_list; - - cerr<<"delta\tr_delta (kpc)\tr_delta (pixel)\tmass_delta (solar mass)\n"; - for(double r=kpc;r<6000*kpc;r+=kpc) - { - double delta=nfw_average_density(r,abs(rho0),abs(rs))/calc_critical_density(z); - radius_list.push_back(r); - delta_list.push_back(delta); - - /* - if(delta<=200&&!hit_200) - { - hit_200=true; - cerr<<200<<"\t"<=200&&delta_list[i+1]<200) - { - cerr<<200<<"\t"<=500&&delta_list[i+1]<500) - { - cerr<<500<<"\t"<=1500&&delta_list[i+1]<1500) - { - cerr<<1500<<"\t"<=2500&&delta_list[i+1]<2500) - { - cerr<<2500<<"\t"< -#include -#include - -//a series of physical constants -static const double G=6.673E-8;//cm^3 g^-1 s^2 -static const double mu=1.4074; -static const double mp=1.67262158E-24;//g -static const double k=1.60217646E-9;//erg/keV -static const double c=2.99792458E10;//cm/s - - -namespace opt_utilities -{ - //the nfw mass enclosed within a radius r, with parameter rho0 and rs - template - T nfw_mass_enclosed(T r,T rho0,T rs) - { - return 4*pi*rho0*rs*rs*rs*(std::log((r+rs)/rs)-r/(r+rs)); - } - - //average mass density - template - T nfw_average_density(T r,T rho0,T rs) - { - if(r==0) - { - return rho0; - } - - return nfw_mass_enclosed(r,rho0,rs)/(4.*pi/3*r*r*r); - } - - //calculate critical density from z, under following cosmological constants - static double calc_critical_density(double z, - const double H0=2.3E-18, - 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; - return 3*H*H/8/pi/G; - } - - - //a class wraps method of calculating gas density from mass profile and temperature profile - template - class nfw_ne - :public model,std::vector,std::vector > - { - private: - //pointer to temperature profile function - func_obj* pTfunc; - //cm per pixel - T cm_per_pixel; - public: - //default constructor - 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)); - } - - //copy constructor - nfw_ne(const nfw_ne& rhs) - :cm_per_pixel(rhs.cm_per_pixel) - { - if(rhs.pTfunc) - { - pTfunc=rhs.pTfunc->clone(); - } - else - { - pTfunc=0; - } - //initial parameter list - this->push_param_info(param_info,std::string>("rho0",rhs.get_param_info("rho0").get_value())); - 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) - { - cm_per_pixel=rhs.cm_per_pixel; - if(pTfunc) - { - pTfunc->destroy(); - } - if(rhs.pTfunc) - { - pTfunc=rhs.pTfunc->clone(); - } - } - - //destructor - ~nfw_ne() - { - if(pTfunc) - { - pTfunc->destroy(); - } - } - - public: - //attach the temperature profile function - void attach_Tfunc(const func_obj& Tf) - { - if(pTfunc) - { - pTfunc->destroy(); - } - pTfunc=Tf.clone(); - } - - //set the cm per pixel value - void set_cm_per_pixel(const T& x) - { - cm_per_pixel=x; - } - - //clone self - nfw_ne* do_clone()const - { - return new nfw_ne(*this); - } - - - //calculate density under parameters p, at radius r - /* - r is a vector, which stores a series of radius values - the annuli or pie regions are enclosed between any two - adjacent radii. - so the returned value has length smaller than r by 1. - */ - 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 -#ifdef _OPENMP -#pragma omp parallel for schedule(dynamic) -#endif - for(size_t i=0;ieval(r[i])*k; - if(abs(r_cm)==0) - { - continue; - } - yvec.at(i)=G*nfw_mass_enclosed(r_cm,rho0,rs_cm)*mu*mp/kT_erg/r_cm/r_cm; - //std::cout< ydxvec(r.size()-1); -#ifdef _OPENMP -#pragma omp parallel for schedule(dynamic) -#endif - for(size_t i=1;i result(r.size()-1); -#ifdef _OPENMP -#pragma omp parallel for schedule(dynamic) -#endif - for(size_t i=0;ieval(r[i])*k; - //std::cout<