From e6cb89d7e126e0cba4ea29ad91b3b96f7014f451 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Tue, 7 Feb 2017 14:33:22 +0800 Subject: Remove graphical plot report (depends on PGPLOT) Therefore remove the depends on PGPLOT (from HEASoft) and X11 libraries. --- mass_profile/Makefile | 76 +++++++++++++++--------------------------- mass_profile/chisq.hpp | 23 ++++--------- mass_profile/fit_nfw_sbp.cpp | 3 +- mass_profile/plot_reporter.cpp | 70 -------------------------------------- mass_profile/plot_reporter.hpp | 23 ------------- mass_profile/vchisq.hpp | 30 +++-------------- 6 files changed, 39 insertions(+), 186 deletions(-) delete mode 100644 mass_profile/plot_reporter.cpp delete mode 100644 mass_profile/plot_reporter.hpp (limited to 'mass_profile') diff --git a/mass_profile/Makefile b/mass_profile/Makefile index b6418ab..3bf9aa0 100644 --- a/mass_profile/Makefile +++ b/mass_profile/Makefile @@ -22,8 +22,6 @@ else endif OPT_UTIL_INC ?= -I../opt_utilities -PGPLOT_INC= -I$(HEADAS)/include -PGPLOT_LIB= -L. -lcpgplot -lpgplot -lX11 -lgfortran TARGETS= fit_nfw_sbp fit_dbeta_sbp fit_beta_sbp \ fit_direct_beta calc_distance fit_wang2012_model \ @@ -31,52 +29,36 @@ TARGETS= fit_nfw_sbp fit_dbeta_sbp fit_beta_sbp \ fit_lt_bpl cooling_time calc_lx_dbeta calc_lx_beta HEADERS= projector.hpp spline.hpp vchisq.hpp -all: pgplot $(TARGETS) - -pgplot: libcpgplot.a libpgplot.a - -libcpgplot.a: -ifdef HEADAS - ln -s $(HEADAS)/lib/libcpgplot*.a ./$@ -else - $(error HEASoft not initialized) -endif - -libpgplot.a: -ifdef HEADAS - ln -s $(HEADAS)/lib/libpgplot*.a ./$@ -else - $(error HEASoft not initialized) -endif +all: $(TARGETS) # NOTE: # Object/source files should placed *before* libraries (order matters) -fit_nfw_sbp: fit_nfw_sbp.o plot_reporter.o - $(CXX) $(CXXFLAGS) $^ -o $@ $(OPT_UTIL_INC) $(PGPLOT_INC) $(PGPLOT_LIB) +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 plot_reporter.o - $(CXX) $(CXXFLAGS) $^ -o $@ $(OPT_UTIL_INC) $(PGPLOT_INC) $(PGPLOT_LIB) +fit_dbeta_sbp: fit_dbeta_sbp.o beta_cfg.o report_error.o + $(CXX) $(CXXFLAGS) $^ -o $@ $(OPT_UTIL_INC) -fit_beta_sbp: fit_beta_sbp.o beta_cfg.o dump_fit_qdp.o plot_reporter.o - $(CXX) $(CXXFLAGS) $^ -o $@ $(OPT_UTIL_INC) $(PGPLOT_INC) $(PGPLOT_LIB) +fit_beta_sbp: fit_beta_sbp.o beta_cfg.o dump_fit_qdp.o + $(CXX) $(CXXFLAGS) $^ -o $@ $(OPT_UTIL_INC) -fit_wang2012_model: fit_wang2012_model.o plot_reporter.o - $(CXX) $(CXXFLAGS) $^ -o $@ $(OPT_UTIL_INC) $(PGPLOT_INC) $(PGPLOT_LIB) +fit_wang2012_model: fit_wang2012_model.o + $(CXX) $(CXXFLAGS) $^ -o $@ $(OPT_UTIL_INC) -fit_nfw_mass: fit_nfw_mass.o plot_reporter.o - $(CXX) $(CXXFLAGS) $^ -o $@ $(OPT_UTIL_INC) $(PGPLOT_INC) $(PGPLOT_LIB) +fit_nfw_mass: fit_nfw_mass.o + $(CXX) $(CXXFLAGS) $^ -o $@ $(OPT_UTIL_INC) -fit_direct_beta: fit_direct_beta.o plot_reporter.o - $(CXX) $(CXXFLAGS) $^ -o $@ $(OPT_UTIL_INC) $(PGPLOT_INC) $(PGPLOT_LIB) +fit_direct_beta: fit_direct_beta.o + $(CXX) $(CXXFLAGS) $^ -o $@ $(OPT_UTIL_INC) -calc_lx: calc_lx.o calc_distance.o plot_reporter.o - $(CXX) $(CXXFLAGS) $^ -o $@ $(OPT_UTIL_INC) $(PGPLOT_INC) $(PGPLOT_LIB) +calc_lx: calc_lx.o calc_distance.o + $(CXX) $(CXXFLAGS) $^ -o $@ $(OPT_UTIL_INC) -calc_lx_dbeta: calc_lx_dbeta.o beta_cfg.o report_error.o plot_reporter.o - $(CXX) $(CXXFLAGS) $^ -o $@ $(OPT_UTIL_INC) $(PGPLOT_INC) $(PGPLOT_LIB) +calc_lx_dbeta: calc_lx_dbeta.o beta_cfg.o report_error.o + $(CXX) $(CXXFLAGS) $^ -o $@ $(OPT_UTIL_INC) -calc_lx_beta: calc_lx_beta.o beta_cfg.o dump_fit_qdp.o plot_reporter.o - $(CXX) $(CXXFLAGS) $^ -o $@ $(OPT_UTIL_INC) $(PGPLOT_INC) $(PGPLOT_LIB) +calc_lx_beta: calc_lx_beta.o beta_cfg.o dump_fit_qdp.o + $(CXX) $(CXXFLAGS) $^ -o $@ $(OPT_UTIL_INC) calc_distance: calc_distance_main.o calc_distance.o $(CXX) $(CXXFLAGS) -o $@ $^ @@ -98,28 +80,25 @@ cooling_time: cooling_time.cpp fit_nfw_sbp.o: fit_nfw_sbp.cpp nfw_ne.hpp $(HEADERS) - $(CXX) $(CXXFLAGS) -c $< $(OPT_UTIL_INC) $(PGPLOT_INC) + $(CXX) $(CXXFLAGS) -c $< $(OPT_UTIL_INC) fit_dbeta_sbp.o: fit_dbeta_sbp.cpp constrained_dbeta.hpp $(HEADERS) - $(CXX) $(CXXFLAGS) -c $< $(OPT_UTIL_INC) $(PGPLOT_INC) + $(CXX) $(CXXFLAGS) -c $< $(OPT_UTIL_INC) fit_beta_sbp.o: fit_beta_sbp.cpp beta.hpp $(HEADERS) - $(CXX) $(CXXFLAGS) -c $< $(OPT_UTIL_INC) $(PGPLOT_INC) + $(CXX) $(CXXFLAGS) -c $< $(OPT_UTIL_INC) fit_wang2012_model.o: fit_wang2012_model.cpp wang2012_model.hpp chisq.hpp - $(CXX) $(CXXFLAGS) -c $< $(OPT_UTIL_INC) $(PGPLOT_INC) + $(CXX) $(CXXFLAGS) -c $< $(OPT_UTIL_INC) fit_nfw_mass.o: fit_nfw_mass.cpp nfw.hpp chisq.hpp - $(CXX) $(CXXFLAGS) -c $< $(OPT_UTIL_INC) $(PGPLOT_INC) + $(CXX) $(CXXFLAGS) -c $< $(OPT_UTIL_INC) calc_lx_dbeta.o: calc_lx_dbeta.cpp constrained_dbeta.hpp $(HEADERS) - $(CXX) $(CXXFLAGS) -c $< $(OPT_UTIL_INC) $(PGPLOT_INC) + $(CXX) $(CXXFLAGS) -c $< $(OPT_UTIL_INC) calc_lx_beta.o: calc_lx_beta.cpp beta.hpp $(HEADERS) - $(CXX) $(CXXFLAGS) -c $< $(OPT_UTIL_INC) $(PGPLOT_INC) - -plot_reporter.o: plot_reporter.cpp plot_reporter.hpp - $(CXX) $(CXXFLAGS) -c $< $(PGPLOT_INC) + $(CXX) $(CXXFLAGS) -c $< $(OPT_UTIL_INC) beta_cfg.o: beta_cfg.cpp beta_cfg.hpp $(CXX) $(CXXFLAGS) -c $< @@ -142,6 +121,3 @@ calc_distance.o: calc_distance.cc calc_distance.h adapt_trapezoid.h clean: rm -f *.o $(TARGETS) - -cleanall: clean - rm -f libpgplot.a libcpgplot.a diff --git a/mass_profile/chisq.hpp b/mass_profile/chisq.hpp index bdfadcb..0e58200 100644 --- a/mass_profile/chisq.hpp +++ b/mass_profile/chisq.hpp @@ -6,15 +6,17 @@ #ifndef CHI_SQ_HPP #define CHI_SQ_HPP + #define OPT_HEADER + #include #include #include #include #include -#include "plot_reporter.hpp" -#include -using std::cerr;using std::endl; + +using std::cerr; +using std::endl; namespace opt_utilities { @@ -77,8 +79,6 @@ namespace opt_utilities :verb(true),limit_bound(false) {} - - Ty do_eval(const Tp& p) { if(limit_bound) @@ -111,7 +111,6 @@ 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) @@ -157,7 +156,6 @@ namespace opt_utilities } } - if(y_model>y_obs) { y_err=this->get_data_set().get_data(i).get_y_upper_err(); @@ -185,7 +183,6 @@ namespace opt_utilities ymax=std::max(vy.at(i),ymax+vye2[i]); } - } if(verb) { @@ -198,20 +195,12 @@ namespace opt_utilities } cerr< #include #include "spline.hpp" -#include + 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 diff --git a/mass_profile/plot_reporter.cpp b/mass_profile/plot_reporter.cpp deleted file mode 100644 index b5fc9ff..0000000 --- a/mass_profile/plot_reporter.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include "plot_reporter.hpp" -#include -#include -#include - -plot_reporter::plot_reporter() -{ - const char* pgplot_device=getenv("PGPLOT_DEVICE"); - if(pgplot_device==NULL) - { - if (cpgopen("/null") < 1) - { - assert(0); - } - } - else - { - if (cpgopen(pgplot_device) < 1) - { - assert(0); - } - } - cpgask(0); -} - - -plot_reporter::~plot_reporter() -{ - cpgclos(); -} - - -void plot_reporter::init_xyrange(float x1, - float x2, - float y1, - float y2, - int axis_flag) -{ - cpgenv(x1, x2, y1, y2, 0, axis_flag); -} - - -void plot_reporter::plot_line(std::vector& x,std::vector& y) -{ - cpgbbuf(); - cpgline(x.size(),x.data(),y.data()); - cpgebuf(); -} - -void plot_reporter::plot_err1_dot(std::vector& x,std::vector& y, - std::vector& e) -{ - cpgbbuf(); - cpgpt(x.size(),x.data(),y.data(),1); - cpgerrb(6,x.size(),x.data(),y.data(),e.data(),0); - cpgebuf(); -} - - -void plot_reporter::plot_err2_dot(std::vector& x,std::vector& y, - std::vector& e1,std::vector& e2) -{ - cpgbbuf(); - cpgpt(x.size(),x.data(),y.data(),1); - cpgerrb(2,x.size(),x.data(),y.data(),e1.data(),0); - cpgerrb(4,x.size(),x.data(),y.data(),e2.data(),0); - cpgebuf(); -} - -plot_reporter pr; diff --git a/mass_profile/plot_reporter.hpp b/mass_profile/plot_reporter.hpp deleted file mode 100644 index 5625f47..0000000 --- a/mass_profile/plot_reporter.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef PLOT_REPORTER_HPP -#define PLOT_REPORTER_HPP -#include -class plot_reporter -{ -private: - plot_reporter(const plot_reporter&); - plot_reporter& operator=(const plot_reporter&); -public: - plot_reporter(); - ~plot_reporter(); - void init_xyrange(float x1,float x2,float y1,float y2,int axis_flag); - void plot_line(std::vector& x,std::vector& y); - void plot_err1_dot(std::vector& x,std::vector& y, - std::vector& e); - void plot_err2_dot(std::vector& x,std::vector& y, - std::vector& e1,std::vector& e2); - -}; - -extern plot_reporter pr; - -#endif diff --git a/mass_profile/vchisq.hpp b/mass_profile/vchisq.hpp index c3d38b8..8cd8481 100644 --- a/mass_profile/vchisq.hpp +++ b/mass_profile/vchisq.hpp @@ -6,19 +6,20 @@ #ifndef VCHI_SQ_HPP #define VCHI_SQ_HPP + #define OPT_HEADER + #include #include #include #include #include -#include "plot_reporter.hpp" -#include -using std::cerr;using std::endl; + +using std::cerr; +using std::endl; namespace opt_utilities { - template class vchisq :public statistic,std::vector,std::vector,T,std::string> @@ -59,8 +60,6 @@ namespace opt_utilities :verb(false),limit_bound(false) {} - - T do_eval(const std::vector& p) { if(limit_bound) @@ -71,7 +70,6 @@ namespace opt_utilities } } T result(0); - std::vector vx; std::vector vy; std::vector vye; @@ -80,7 +78,6 @@ namespace opt_utilities if(verb) { n++; - if(n%100==0) { vx.resize(this->get_data_set().get_data(0).get_y().size()); @@ -88,7 +85,6 @@ 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) { @@ -101,10 +97,8 @@ namespace opt_utilities result+=chi*chi; } - if(verb&&n%100==0) { - for(size_t 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.); @@ -119,18 +113,13 @@ namespace opt_utilities vx[j]=log10(vx[j]); vy[j]=log10(vy[j]); my[j]=log10(my[j]); - } - } - } if(verb) { - if(n%100==0) { - cerr<