diff --git a/include/GFits.hpp b/include/GFits.hpp index 64a80c7..3bcb874 100644 --- a/include/GFits.hpp +++ b/include/GFits.hpp @@ -41,9 +41,9 @@ public: void save(void); void saveto(const std::string filename, int clobber); void close(void); - GFitsHDU* hdu(std::string extname); + GFitsHDU* hdu(const std::string extname); GFitsHDU* hdu(int extno); - + private: // Private methods void init_members(void); diff --git a/include/GFitsHDU.hpp b/include/GFitsHDU.hpp index 0d40ffb..536b800 100644 --- a/include/GFitsHDU.hpp +++ b/include/GFitsHDU.hpp @@ -48,7 +48,7 @@ public: GFitsHeader* header(void) const; GFitsData* data(void) const; GFitsTableCol* column(const std::string colname) const; - + private: // Private methods void init_members(void); diff --git a/src/fits/GFits.cpp b/src/fits/GFits.cpp index 9d6575f..7ffa18a 100644 --- a/src/fits/GFits.cpp +++ b/src/fits/GFits.cpp @@ -15,6 +15,7 @@ /* __ Includes ___________________________________________________________ */ #include "GException.hpp" #include "GFits.hpp" +#include "GTools.hpp" #include // cout, cerr /* __ Namespaces _________________________________________________________ */ @@ -233,7 +234,7 @@ void GFits::close(void) * Get pointer to HDU * * ----------------------------------------------------------------------- * ***************************************************************************/ -GFitsHDU* GFits::hdu(std::string extname) +GFitsHDU* GFits::hdu(const std::string extname) { // Initialise result to NULL pointer GFitsHDU* ptr = NULL; diff --git a/src/fits/GFitsHDU.cpp b/src/fits/GFitsHDU.cpp index 3ea7afb..e9ed99d 100644 --- a/src/fits/GFitsHDU.cpp +++ b/src/fits/GFitsHDU.cpp @@ -14,6 +14,7 @@ /* __ Includes ___________________________________________________________ */ #include "GException.hpp" +#include "GTools.hpp" #include "GFitsHDU.hpp" #include // cout, cerr @@ -162,7 +163,7 @@ void GFitsHDU::open(__fitsfile* fptr, int hdunum) m_data->open(m_fitsfile); // Get HDU name from header - m_name = m_header->string("EXTNAME"); + m_name = strip_whitespace(m_header->string("EXTNAME")); if (m_name.length() == 0) { if (hdunum == 1) m_name = "Primary"; diff --git a/test/Makefile.am b/test/Makefile.am index c08ec3c..253976b 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -12,13 +12,15 @@ check_PROGRAMS = test_GVector \ test_GMatrix \ test_GSymMatrix \ test_GSparseMatrix \ - test_GFits + test_GFits \ + test_GResponse TESTS = test_GVector \ test_GMatrix \ test_GSymMatrix \ test_GSparseMatrix \ - test_GFits + test_GFits \ + test_GResponse test_GVector_SOURCES = test_GVector.cpp test_GVector_LDADD = ../src/libgamma.la @@ -30,3 +32,5 @@ test_GSparseMatrix_SOURCES = test_GSparseMatrix.cpp test_GSparseMatrix_LDADD = ../src/libgamma.la test_GFits_SOURCES = test_GFits.cpp test_GFits_LDADD = ../src/libgamma.la +test_GResponse_SOURCES = test_GResponse.cpp +test_GResponse_LDADD = ../src/libgamma.la diff --git a/test/Makefile.in b/test/Makefile.in index a3d300c..52dd1b4 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -41,7 +41,7 @@ build_triplet = @build@ host_triplet = @host@ check_PROGRAMS = test_GVector$(EXEEXT) test_GMatrix$(EXEEXT) \ test_GSymMatrix$(EXEEXT) test_GSparseMatrix$(EXEEXT) \ - test_GFits$(EXEEXT) + test_GFits$(EXEEXT) test_GResponse$(EXEEXT) subdir = test DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -57,6 +57,9 @@ test_GFits_DEPENDENCIES = ../src/libgamma.la am_test_GMatrix_OBJECTS = test_GMatrix.$(OBJEXT) test_GMatrix_OBJECTS = $(am_test_GMatrix_OBJECTS) test_GMatrix_DEPENDENCIES = ../src/libgamma.la +am_test_GResponse_OBJECTS = test_GResponse.$(OBJEXT) +test_GResponse_OBJECTS = $(am_test_GResponse_OBJECTS) +test_GResponse_DEPENDENCIES = ../src/libgamma.la am_test_GSparseMatrix_OBJECTS = test_GSparseMatrix.$(OBJEXT) test_GSparseMatrix_OBJECTS = $(am_test_GSparseMatrix_OBJECTS) test_GSparseMatrix_DEPENDENCIES = ../src/libgamma.la @@ -78,11 +81,11 @@ CXXLD = $(CXX) CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(test_GFits_SOURCES) $(test_GMatrix_SOURCES) \ - $(test_GSparseMatrix_SOURCES) $(test_GSymMatrix_SOURCES) \ - $(test_GVector_SOURCES) + $(test_GResponse_SOURCES) $(test_GSparseMatrix_SOURCES) \ + $(test_GSymMatrix_SOURCES) $(test_GVector_SOURCES) DIST_SOURCES = $(test_GFits_SOURCES) $(test_GMatrix_SOURCES) \ - $(test_GSparseMatrix_SOURCES) $(test_GSymMatrix_SOURCES) \ - $(test_GVector_SOURCES) + $(test_GResponse_SOURCES) $(test_GSparseMatrix_SOURCES) \ + $(test_GSymMatrix_SOURCES) $(test_GVector_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -207,7 +210,8 @@ TESTS = test_GVector \ test_GMatrix \ test_GSymMatrix \ test_GSparseMatrix \ - test_GFits + test_GFits \ + test_GResponse test_GVector_SOURCES = test_GVector.cpp test_GVector_LDADD = ../src/libgamma.la @@ -219,6 +223,8 @@ test_GSparseMatrix_SOURCES = test_GSparseMatrix.cpp test_GSparseMatrix_LDADD = ../src/libgamma.la test_GFits_SOURCES = test_GFits.cpp test_GFits_LDADD = ../src/libgamma.la +test_GResponse_SOURCES = test_GResponse.cpp +test_GResponse_LDADD = ../src/libgamma.la all: all-am .SUFFIXES: @@ -265,6 +271,9 @@ test_GFits$(EXEEXT): $(test_GFits_OBJECTS) $(test_GFits_DEPENDENCIES) test_GMatrix$(EXEEXT): $(test_GMatrix_OBJECTS) $(test_GMatrix_DEPENDENCIES) @rm -f test_GMatrix$(EXEEXT) $(CXXLINK) $(test_GMatrix_LDFLAGS) $(test_GMatrix_OBJECTS) $(test_GMatrix_LDADD) $(LIBS) +test_GResponse$(EXEEXT): $(test_GResponse_OBJECTS) $(test_GResponse_DEPENDENCIES) + @rm -f test_GResponse$(EXEEXT) + $(CXXLINK) $(test_GResponse_LDFLAGS) $(test_GResponse_OBJECTS) $(test_GResponse_LDADD) $(LIBS) test_GSparseMatrix$(EXEEXT): $(test_GSparseMatrix_OBJECTS) $(test_GSparseMatrix_DEPENDENCIES) @rm -f test_GSparseMatrix$(EXEEXT) $(CXXLINK) $(test_GSparseMatrix_LDFLAGS) $(test_GSparseMatrix_OBJECTS) $(test_GSparseMatrix_LDADD) $(LIBS) diff --git a/test/test_GFits.cpp b/test/test_GFits.cpp index 2c5121f..1a0935e 100644 --- a/test/test_GFits.cpp +++ b/test/test_GFits.cpp @@ -283,7 +283,7 @@ int main(void) // Dump header std::cout << std::endl; std::cout << "***********************" << std::endl; - std::cout << "* GFIts class testing *" << std::endl; + std::cout << "* GFits class testing *" << std::endl; std::cout << "***********************" << std::endl; // Execute the tests diff --git a/test/test_GResponse.cpp b/test/test_GResponse.cpp new file mode 100644 index 0000000..e23d19b --- /dev/null +++ b/test/test_GResponse.cpp @@ -0,0 +1,73 @@ +/*************************************************************************** + * test_GResponse.cpp - test Response classes * + * ----------------------------------------------------------------------- * + * copyright : (C) 2008 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +/* __ Includes ___________________________________________________________ */ +#include "test_GResponse.hpp" + +/* __ Namespaces _________________________________________________________ */ + +/* __ Globals ____________________________________________________________ */ + + +/*************************************************************************** + * Test: Open * + ***************************************************************************/ +void test_open(void) +{ + std::cout << "Test GResponse: Open PSF FITS file: "; + try { + // Open FITS file + GFits fits; + fits.open("irf/lat/aeff_Pass5_v0_front.fits"); + + // Get pointer towards effective area HDU + GFitsHDU* aeff = fits.hdu("EFFECTIVE AREA"); + if (aeff == NULL) { + std::cout << std::endl << "TEST ERROR: Unable to find HDU ." << std::endl; + throw; + } + + // Get columns + GFitsTableFltCol energ_lo = *((GFitsTableFltCol*)aeff->column("ENERG_LO")); + GFitsTableFltCol energ_hi = *((GFitsTableFltCol*)aeff->column("ENERG_HI")); + GFitsTableFltCol ctheta_lo = *((GFitsTableFltCol*)aeff->column("CTHETA_LO")); + GFitsTableFltCol ctheta_hi = *((GFitsTableFltCol*)aeff->column("CTHETA_HI")); + GFitsTableFltCol effarea = *((GFitsTableFltCol*)aeff->column("EFFAREA")); + + } + catch (exception &e) { + std::cout << std::endl << "TEST ERROR: Unable to open FITS file." << std::endl; + std::cout << e.what() << std::endl; + throw; + } + std::cout << ". ok." << std::endl; +} + + +/*************************************************************************** + * Main test function * + ***************************************************************************/ +int main(void) +{ + // Dump header + std::cout << std::endl; + std::cout << "***************************" << std::endl; + std::cout << "* GResponse class testing *" << std::endl; + std::cout << "**************************" << std::endl; + + // Execute the tests + test_open(); + + // Return + return 0; +} diff --git a/test/test_GResponse.hpp b/test/test_GResponse.hpp new file mode 100644 index 0000000..4a0b5ba --- /dev/null +++ b/test/test_GResponse.hpp @@ -0,0 +1,23 @@ +/*************************************************************************** + * test_GResponse.hpp - test Response classes * + * ----------------------------------------------------------------------- * + * copyright : (C) 2008 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef TEST_GRESPONSE_HPP +#define TEST_GRESPONSE_HPP + +/* __ Includes ___________________________________________________________ */ +#include "GammaLib.hpp" +#include // cout, cerr +#include // std::exception +//#include + +#endif /* TEST_GRESPONSE_HPP */