From 8ebdfced8b8eed3d3eaf6ce2be4d7328d19e39df Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Fri, 24 Mar 2017 10:18:36 +0100 Subject: [PATCH] Define extension names as constant strings --- include/GArf.hpp | 5 +++++ include/GEbounds.hpp | 7 ++++++- include/GEnergies.hpp | 7 ++++++- include/GGti.hpp | 9 +++++++-- include/GPha.hpp | 7 ++++++- include/GRmf.hpp | 7 ++++++- inst/cta/include/GCTAAeff2D.hpp | 5 +++++ inst/cta/include/GCTABackground3D.hpp | 7 ++++++- inst/cta/include/GCTACubeEdisp.hpp | 7 ++++++- inst/cta/include/GCTACubePsf.hpp | 7 ++++++- inst/cta/include/GCTAEdisp2D.hpp | 5 +++++ inst/cta/include/GCTAEventCube.hpp | 8 +++++++- inst/cta/include/GCTAEventList.hpp | 10 ++++++++-- inst/cta/include/GCTAObservation.hpp | 7 ++++--- inst/cta/include/GCTAPsf2D.hpp | 8 ++++++-- inst/cta/include/GCTAPsfKing.hpp | 7 ++++++- inst/cta/include/GCTAPsfTable.hpp | 7 ++++++- inst/cta/src/GCTAAeff2D.cpp | 9 +++++---- inst/cta/src/GCTAAeffArf.cpp | 7 ++++--- inst/cta/src/GCTABackground3D.cpp | 9 +++++---- inst/cta/src/GCTACubeBackground.cpp | 2 +- inst/cta/src/GCTACubeEdisp.cpp | 24 ++++++++++++------------ inst/cta/src/GCTACubeExposure.cpp | 6 +++--- inst/cta/src/GCTACubePsf.cpp | 8 ++++---- inst/cta/src/GCTAEdisp2D.cpp | 9 +++++---- inst/cta/src/GCTAEventCube.cpp | 32 ++++++++++++++++---------------- inst/cta/src/GCTAEventList.cpp | 27 ++++++++++++++------------- inst/cta/src/GCTAObservation.cpp | 16 ++++++++-------- inst/cta/src/GCTAOnOffObservation.cpp | 4 ++-- inst/cta/src/GCTAPsf2D.cpp | 11 ++++++----- inst/cta/src/GCTAPsfKing.cpp | 13 +++++++------ inst/cta/src/GCTAPsfTable.cpp | 13 +++++++------ inst/cta/src/GCTAResponseIrf.cpp | 41 +++++++++++++++++++++-------------------- inst/lat/include/GLATAeff.hpp | 8 +++++++- inst/lat/include/GLATEdisp.hpp | 8 +++++++- inst/lat/include/GLATEventList.hpp | 7 ++++++- inst/lat/include/GLATLtCube.hpp | 9 ++++++++- inst/lat/src/GLATAeff.cpp | 16 ++++++++-------- inst/lat/src/GLATEdisp.cpp | 8 ++++---- inst/lat/src/GLATEventCube.cpp | 10 +++++----- inst/lat/src/GLATEventList.cpp | 8 ++++---- inst/lat/src/GLATLtCube.cpp | 10 +++++----- pyext/GEbounds.i | 2 +- pyext/GEnergies.i | 2 +- pyext/GGti.i | 4 ++-- src/obs/GEbounds.cpp | 16 ++++++++-------- src/obs/GEnergies.cpp | 10 +++++----- src/obs/GGti.cpp | 12 ++++++------ src/xspec/GArf.cpp | 8 ++++---- src/xspec/GPha.cpp | 26 +++++++++++++------------- src/xspec/GRmf.cpp | 14 +++++++------- 51 files changed, 322 insertions(+), 207 deletions(-) diff --git a/include/GArf.hpp b/include/GArf.hpp index d8c5c08..686b2ee 100644 --- a/include/GArf.hpp +++ b/include/GArf.hpp @@ -38,6 +38,11 @@ class GFits; class GFitsTable; +/* __ Constants __________________________________________________________ */ +namespace gammalib { + const std::string extname_arf = "SPECRESP"; +} + /***********************************************************************//** * @class GArf diff --git a/include/GEbounds.hpp b/include/GEbounds.hpp index 8918a1a..99883c3 100644 --- a/include/GEbounds.hpp +++ b/include/GEbounds.hpp @@ -39,6 +39,11 @@ class GFitsTable; class GFilename; class GEnergies; +/* __ Constants __________________________________________________________ */ +namespace gammalib { + const std::string extname_ebounds = "EBOUNDS"; +} + /***********************************************************************//** * @class GEbounds @@ -91,7 +96,7 @@ public: const std::string& unit = "keV") const; void read(const GFitsTable& table); void write(GFits& file, - const std::string& extname = "EBOUNDS", + const std::string& extname = gammalib::extname_ebounds, const std::string& unit = "keV") const; void read(const GXmlElement& xml); void write(GXmlElement& xml) const; diff --git a/include/GEnergies.hpp b/include/GEnergies.hpp index bec6f05..e37ed58 100644 --- a/include/GEnergies.hpp +++ b/include/GEnergies.hpp @@ -39,6 +39,11 @@ class GFilename; class GEbounds; +/* __ Constants __________________________________________________________ */ +namespace gammalib { + const std::string extname_energies = "ENERGIES"; +} + /***********************************************************************//** * @class GEnergies @@ -92,7 +97,7 @@ public: const bool& clobber = false) const; void read(const GFitsTable& table); void write(GFits& file, - const std::string& extname = "ENERGIES") const; + const std::string& extname = gammalib::extname_energies) const; std::string print(const GChatter& chatter = NORMAL) const; protected: diff --git a/include/GGti.hpp b/include/GGti.hpp index 68b03ae..52ddd63 100644 --- a/include/GGti.hpp +++ b/include/GGti.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * GGti.hpp - Good time interval class * * ----------------------------------------------------------------------- * - * copyright (C) 2008-2016 by Juergen Knoedlseder * + * copyright (C) 2008-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -39,6 +39,11 @@ class GXmlElement; class GFits; class GFitsTable; +/* __ Constants __________________________________________________________ */ +namespace gammalib { + const std::string extname_gti = "GTI"; +} + /***********************************************************************//** * @class GGti @@ -88,7 +93,7 @@ public: const bool& clobber = false) const; void read(const GFitsTable& table); void write(GFits& fits, - const std::string& extname = "GTI") const; + const std::string& extname = gammalib::extname_gti) const; void read(const GXmlElement& xml); void write(GXmlElement& xml) const; const GTime& tstart(void) const; diff --git a/include/GPha.hpp b/include/GPha.hpp index c8f07a5..cff2f5e 100644 --- a/include/GPha.hpp +++ b/include/GPha.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * GPha.hpp - XSPEC Pulse Height Analyzer class * * ----------------------------------------------------------------------- * - * copyright (C) 2013-2016 by Juergen Knoedlseder * + * copyright (C) 2013-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -38,6 +38,11 @@ class GEnergy; class GFits; class GFitsTable; +/* __ Constants __________________________________________________________ */ +namespace gammalib { + const std::string extname_pha = "SPECTRUM"; +} + /***********************************************************************//** * @class GPha diff --git a/include/GRmf.hpp b/include/GRmf.hpp index 7ff173f..db91458 100644 --- a/include/GRmf.hpp +++ b/include/GRmf.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * GRmf.hpp - XSPEC Redistribution Matrix File class * * ----------------------------------------------------------------------- * - * copyright (C) 2013-2016 by Juergen Knoedlseder * + * copyright (C) 2013-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -38,6 +38,11 @@ class GFits; class GFitsTable; +/* __ Constants __________________________________________________________ */ +namespace gammalib { + const std::string extname_rmf = "MATRIX"; +} + /***********************************************************************//** * @class GRmf diff --git a/inst/cta/include/GCTAAeff2D.hpp b/inst/cta/include/GCTAAeff2D.hpp index 5127074..de218e7 100644 --- a/inst/cta/include/GCTAAeff2D.hpp +++ b/inst/cta/include/GCTAAeff2D.hpp @@ -37,6 +37,11 @@ class GFitsTable; class GFitsBinTable; +/* __ Constants __________________________________________________________ */ +namespace gammalib { + const std::string extname_cta_aeff2d = "EFFECTIVE AREA"; +} + /***********************************************************************//** * @class GCTAAeff2D diff --git a/inst/cta/include/GCTABackground3D.hpp b/inst/cta/include/GCTABackground3D.hpp index ca434ba..0feb04a 100644 --- a/inst/cta/include/GCTABackground3D.hpp +++ b/inst/cta/include/GCTABackground3D.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * GCTABackground3D.hpp - CTA 3D background class * * ----------------------------------------------------------------------- * - * copyright (C) 2014-2016 by Juergen Knoedlseder * + * copyright (C) 2014-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -37,6 +37,11 @@ class GFits; class GFitsBinTable; +/* __ Constants __________________________________________________________ */ +namespace gammalib { + const std::string extname_cta_background3d = "BACKGROUND"; +} + /***********************************************************************//** * @class GCTABackground3D diff --git a/inst/cta/include/GCTACubeEdisp.hpp b/inst/cta/include/GCTACubeEdisp.hpp index a84fcaf..f41fa43 100644 --- a/inst/cta/include/GCTACubeEdisp.hpp +++ b/inst/cta/include/GCTACubeEdisp.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * GCTACubeEdisp.hpp - CTA cube analysis energy dispersion class * * ----------------------------------------------------------------------- * - * copyright (C) 2016 by Michael Mayer * + * copyright (C) 2016-2017 by Michael Mayer * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -43,6 +43,11 @@ class GObservations; class GCTAEventCube; class GCTAObservation; +/* __ Constants __________________________________________________________ */ +namespace gammalib { + const std::string extname_cta_migras = "MIGRAS"; +} + /***********************************************************************//** * @class GCTACubeEdisp diff --git a/inst/cta/include/GCTACubePsf.hpp b/inst/cta/include/GCTACubePsf.hpp index eeab877..107c63f 100644 --- a/inst/cta/include/GCTACubePsf.hpp +++ b/inst/cta/include/GCTACubePsf.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * GCTACubePsf.hpp - CTA cube analysis point spread function class * * ----------------------------------------------------------------------- * - * copyright (C) 2014-2016 by Chia-Chun Lu * + * copyright (C) 2014-2017 by Chia-Chun Lu * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -42,6 +42,11 @@ class GObservations; class GCTAEventCube; class GCTAObservation; +/* __ Constants __________________________________________________________ */ +namespace gammalib { + const std::string extname_deltas = "DELTAS"; +} + /***********************************************************************//** diff --git a/inst/cta/include/GCTAEdisp2D.hpp b/inst/cta/include/GCTAEdisp2D.hpp index 353e2a5..05cf35c 100644 --- a/inst/cta/include/GCTAEdisp2D.hpp +++ b/inst/cta/include/GCTAEdisp2D.hpp @@ -39,6 +39,11 @@ class GRan; class GFits; class GFitsBinTable; +/* __ Constants __________________________________________________________ */ +namespace gammalib { + const std::string extname_cta_edisp2d = "ENERGY DISPERSION"; +} + /***********************************************************************//** * @class GCTAEdisp2D diff --git a/inst/cta/include/GCTAEventCube.hpp b/inst/cta/include/GCTAEventCube.hpp index 3ce6d74..f71185c 100644 --- a/inst/cta/include/GCTAEventCube.hpp +++ b/inst/cta/include/GCTAEventCube.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * GCTAEventCube.hpp - CTA event bin container class * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2016 by Juergen Knoedlseder * + * copyright (C) 2010-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -44,6 +44,12 @@ /* __ Forward declarations _______________________________________________ */ class GFilename; +/* __ Constants __________________________________________________________ */ +namespace gammalib { + const std::string extname_cta_counts = "COUNTS"; + const std::string extname_cta_weights = "WEIGHTS"; +} + /***********************************************************************//** * @class GCTAEventCube diff --git a/inst/cta/include/GCTAEventList.hpp b/inst/cta/include/GCTAEventList.hpp index 4e28911..a1447e9 100644 --- a/inst/cta/include/GCTAEventList.hpp +++ b/inst/cta/include/GCTAEventList.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * GCTAEventList.hpp - CTA event list class * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2016 by Juergen Knoedlseder * + * copyright (C) 2010-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -41,6 +41,11 @@ class GFitsHDU; class GFitsTable; class GFitsBinTable; +/* __ Constants __________________________________________________________ */ +namespace gammalib { + const std::string extname_cta_events = "EVENTS"; +} + /***********************************************************************//** * @class GCTAEventList @@ -100,7 +105,8 @@ protected: virtual void set_times(void) { return; } void read_events(const GFitsTable& table) const; void write_events(GFitsBinTable& table) const; - void write_ds_keys(GFitsHDU& hdu, const std::string& gtiname = "GTI") const; + void write_ds_keys(GFitsHDU& hdu, + const std::string& gtiname = gammalib::extname_gti) const; int irf_cache_init(const std::string& name) const; int irf_cache_index(const std::string& name) const; diff --git a/inst/cta/include/GCTAObservation.hpp b/inst/cta/include/GCTAObservation.hpp index b1fd06a..da9e04b 100644 --- a/inst/cta/include/GCTAObservation.hpp +++ b/inst/cta/include/GCTAObservation.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * GCTAObservation.hpp - CTA Observation class * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2016 by Juergen Knoedlseder * + * copyright (C) 2010-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -33,6 +33,7 @@ #include "GObservation.hpp" #include "GCTAResponse.hpp" #include "GCTAPointing.hpp" +#include "GCTAEventList.hpp" /* __ Forward declarations _______________________________________________ */ class GTime; @@ -100,8 +101,8 @@ public: bool has_events(void) const; void read(const GFits& fits); void write(GFits& fits, - const std::string& evtname = "EVENTS", - const std::string& gtiname = "GTI") const; + const std::string& evtname = gammalib::extname_cta_events, + const std::string& gtiname = gammalib::extname_gti) const; void load(const GFilename& filename); void load(const GFilename& cntcube, const GFilename& expcube, diff --git a/inst/cta/include/GCTAPsf2D.hpp b/inst/cta/include/GCTAPsf2D.hpp index d9b9c68..504e0eb 100644 --- a/inst/cta/include/GCTAPsf2D.hpp +++ b/inst/cta/include/GCTAPsf2D.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * GCTAPsf2D.hpp - CTA 2D point spread function class * * ----------------------------------------------------------------------- * - * copyright (C) 2012-2016 by Juergen Knoedlseder * + * copyright (C) 2012-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -29,7 +29,6 @@ /* __ Includes ___________________________________________________________ */ #include -//#include "GRan.hpp" #include "GFilename.hpp" #include "GCTAPsf.hpp" #include "GCTAResponseTable.hpp" @@ -38,6 +37,11 @@ class GRan; class GFitsBinTable; +/* __ Constants __________________________________________________________ */ +namespace gammalib { + const std::string extname_cta_psf2d = "POINT SPREAD FUNCTION"; +} + /***********************************************************************//** * @class GCTAPsf2D diff --git a/inst/cta/include/GCTAPsfKing.hpp b/inst/cta/include/GCTAPsfKing.hpp index cfc603d..09343d2 100644 --- a/inst/cta/include/GCTAPsfKing.hpp +++ b/inst/cta/include/GCTAPsfKing.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * GCTAPsfKing.hpp - King profile CTA point spread function class * * ----------------------------------------------------------------------- * - * copyright (C) 2013-2016 by Michael Mayer * + * copyright (C) 2013-2017 by Michael Mayer * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -37,6 +37,11 @@ class GRan; class GFitsTable; +/* __ Constants __________________________________________________________ */ +namespace gammalib { + const std::string extname_cta_psfking = "POINT SPREAD FUNCTION"; +} + /***********************************************************************//** * @class GCTAPsfKing diff --git a/inst/cta/include/GCTAPsfTable.hpp b/inst/cta/include/GCTAPsfTable.hpp index 793826f..d93aedd 100644 --- a/inst/cta/include/GCTAPsfTable.hpp +++ b/inst/cta/include/GCTAPsfTable.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * GCTAPsfTable.hpp - CTA point spread function table class * * ----------------------------------------------------------------------- * - * copyright (C) 2016 by Juergen Knoedlseder * + * copyright (C) 2016-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -37,6 +37,11 @@ class GRan; class GFitsTable; +/* __ Constants __________________________________________________________ */ +namespace gammalib { + const std::string extname_cta_psftable = "POINT SPREAD FUNCTION"; +} + /***********************************************************************//** * @class GCTAPsfTable diff --git a/inst/cta/src/GCTAAeff2D.cpp b/inst/cta/src/GCTAAeff2D.cpp index 1eee94a..8dbe137 100644 --- a/inst/cta/src/GCTAAeff2D.cpp +++ b/inst/cta/src/GCTAAeff2D.cpp @@ -356,7 +356,7 @@ void GCTAAeff2D::write(GFitsBinTable& table) const * @param[in] filename FITS file name. * * Loads the effective area from a FITS file. If no extension name is given - * the effective area will be loaded from the "EFFECTIVE AREA" extension. + * the effective area will be loaded from the `EFFECTIVE AREA` extension. ***************************************************************************/ void GCTAAeff2D::load(const GFilename& filename) { @@ -364,7 +364,8 @@ void GCTAAeff2D::load(const GFilename& filename) GFits fits(filename); // Get effective area table - const GFitsTable& table = *fits.table(filename.extname("EFFECTIVE AREA")); + const GFitsTable& table = + *fits.table(filename.extname(gammalib::extname_cta_aeff2d)); // Read effective area from table read(table); @@ -391,7 +392,7 @@ void GCTAAeff2D::load(const GFilename& filename) * opens the existing file. The method will create a (or replace an existing) * effective area extension. The extension name can be specified as part * of the @p filename, or if no extension name is given, is assumed to be - * "EFFECTIVE AREA". + * `EFFECTIVE AREA`. * * An existing file will only be modified if the @p clobber flag is set to * true. @@ -399,7 +400,7 @@ void GCTAAeff2D::load(const GFilename& filename) void GCTAAeff2D::save(const GFilename& filename, const bool& clobber) const { // Get extension name - std::string extname = filename.extname("EFFECTIVE AREA"); + std::string extname = filename.extname(gammalib::extname_cta_aeff2d); // Open or create FITS file (without extension name since the requested // extension may not yet exist in the file) diff --git a/inst/cta/src/GCTAAeffArf.cpp b/inst/cta/src/GCTAAeffArf.cpp index 92a0cc7..6922e28 100644 --- a/inst/cta/src/GCTAAeffArf.cpp +++ b/inst/cta/src/GCTAAeffArf.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GCTAAeffArf.cpp - CTA ARF effective area class * * ----------------------------------------------------------------------- * - * copyright (C) 2012-2016 by Juergen Knoedlseder * + * copyright (C) 2012-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -34,6 +34,7 @@ #include "GFilename.hpp" #include "GFitsTable.hpp" #include "GFitsTableCol.hpp" +#include "GArf.hpp" #include "GCTAAeffArf.hpp" #include "GCTAResponseIrf.hpp" #include "GCTAResponse_helpers.hpp" @@ -245,7 +246,7 @@ GCTAAeffArf* GCTAAeffArf::clone(void) const * Loads the effective area from an ARF FITS file. * * If no extension name is provided, the effective area will be loaded from - * the "SPECRESP" extension. + * the `SPECRESP` extension. ***************************************************************************/ void GCTAAeffArf::load(const GFilename& filename) { @@ -253,7 +254,7 @@ void GCTAAeffArf::load(const GFilename& filename) GFits fits(filename); // Get ARF table - const GFitsTable& table = *fits.table(filename.extname("SPECRESP")); + const GFitsTable& table = *fits.table(filename.extname(gammalib::extname_arf)); // Read ARF from table read(table); diff --git a/inst/cta/src/GCTABackground3D.cpp b/inst/cta/src/GCTABackground3D.cpp index 1af50b3..d38887f 100644 --- a/inst/cta/src/GCTABackground3D.cpp +++ b/inst/cta/src/GCTABackground3D.cpp @@ -401,7 +401,7 @@ void GCTABackground3D::write(GFitsBinTable& table) const * Loads the background from a FITS file. * * If no extension name is provided, the background will be loaded from the - * "BACKGROUND" extension. + * `BACKGROUND` extension. ***************************************************************************/ void GCTABackground3D::load(const GFilename& filename) { @@ -409,7 +409,8 @@ void GCTABackground3D::load(const GFilename& filename) GFits fits(filename); // Get background table - const GFitsTable& table = *fits.table(filename.extname("BACKGROUND")); + const GFitsTable& table = + *fits.table(filename.extname(gammalib::extname_cta_background3d)); // Read effective area from table read(table); @@ -436,7 +437,7 @@ void GCTABackground3D::load(const GFilename& filename) * existing file. The method will create a (or replace an existing) * background extension. The extension name can be specified as part * of the @p filename, or if no extension name is given, is assumed to be - * "BACKGROUND". + * `BACKGROUND`. * * An existing file will only be modified if the @p clobber flag is set to * true. @@ -444,7 +445,7 @@ void GCTABackground3D::load(const GFilename& filename) void GCTABackground3D::save(const GFilename& filename, const bool& clobber) const { // Get extension name - std::string extname = filename.extname("BACKGROUND"); + std::string extname = filename.extname(gammalib::extname_cta_background3d); // Open or create FITS file (without extension name since the requested // extension may not yet exist in the file) diff --git a/inst/cta/src/GCTACubeBackground.cpp b/inst/cta/src/GCTACubeBackground.cpp index 10da03c..4d8d40c 100644 --- a/inst/cta/src/GCTACubeBackground.cpp +++ b/inst/cta/src/GCTACubeBackground.cpp @@ -520,7 +520,7 @@ void GCTACubeBackground::read(const GFits& fits) // Get HDUs const GFitsImage& hdu_bgdcube = *fits.image("Primary"); - const GFitsTable& hdu_energies = *fits.table("ENERGIES"); + const GFitsTable& hdu_energies = *fits.table(gammalib::extname_energies); // Read cube m_cube.read(hdu_bgdcube); diff --git a/inst/cta/src/GCTACubeEdisp.cpp b/inst/cta/src/GCTACubeEdisp.cpp index f81a388..dda0c3a 100644 --- a/inst/cta/src/GCTACubeEdisp.cpp +++ b/inst/cta/src/GCTACubeEdisp.cpp @@ -496,8 +496,8 @@ void GCTACubeEdisp::fill(const GObservations& obs, GLog* log) * * Reads the energy dispersion cube from a FITS file. The energy dispersion * cube values are expected in the primary extension of the FITS file, the - * true energy boundaries are expected in the "ENERGIES" extension, and the - * migration values are expected in the "MIGRAS" extension. + * true energy boundaries are expected in the `ENERGIES` extension, and the + * migration values are expected in the `MIGRAS` extension. ***************************************************************************/ void GCTACubeEdisp::read(const GFits& fits) { @@ -506,8 +506,8 @@ void GCTACubeEdisp::read(const GFits& fits) // Get HDUs const GFitsImage& hdu_edispcube = *fits.image("Primary"); - const GFitsTable& hdu_energies = *fits.table("ENERGIES"); - const GFitsTable& hdu_migras = *fits.table("MIGRAS"); + const GFitsTable& hdu_energies = *fits.table(gammalib::extname_energies); + const GFitsTable& hdu_migras = *fits.table(gammalib::extname_cta_migras); // Read energy dispersion cube m_cube.read(hdu_edispcube); @@ -536,17 +536,17 @@ void GCTACubeEdisp::read(const GFits& fits) * * Write the energy dispersion cube into a FITS file. The energy dispersion * cube values are written into the primary extension of the FITS file, the - * true energy boundaries are written into the "EBOUNDS" extension, and the - * migration values are written into the "MIGRAS" extension. + * true energy boundaries are written into the `ENERGIES` extension, and the + * migration values are written into the `MIGRAS` extension. ***************************************************************************/ void GCTACubeEdisp::write(GFits& fits) const { // Remove extensions from FITS file - if (fits.contains("MIGRAS")) { - fits.remove("MIGRAS"); + if (fits.contains(gammalib::extname_cta_migras)) { + fits.remove(gammalib::extname_cta_migras); } - if (fits.contains("ENERGIES")) { - fits.remove("ENERGIES"); + if (fits.contains(gammalib::extname_energies)) { + fits.remove(gammalib::extname_energies); } if (fits.contains("Primary")) { fits.remove("Primary"); @@ -556,10 +556,10 @@ void GCTACubeEdisp::write(GFits& fits) const m_cube.write(fits); // Write energy boundaries - m_energies.write(fits, "ENERGIES"); + m_energies.write(fits, gammalib::extname_energies); // Write migration nodes - m_migras.write(fits, "MIGRAS"); + m_migras.write(fits, gammalib::extname_cta_migras); // Return return; diff --git a/inst/cta/src/GCTACubeExposure.cpp b/inst/cta/src/GCTACubeExposure.cpp index adf200c..543f42f 100644 --- a/inst/cta/src/GCTACubeExposure.cpp +++ b/inst/cta/src/GCTACubeExposure.cpp @@ -39,7 +39,7 @@ #include "GCTAEventList.hpp" /* __ Method name definitions ____________________________________________ */ -#define G_FILL_CUBE "GCTACubeExposure::fill_cube(GCTAObservation&, GLog*)" +#define G_FILL_CUBE "GCTACubeExposure::fill_cube(GCTAObservation&, GLog*)" /* __ Macros _____________________________________________________________ */ @@ -386,8 +386,8 @@ void GCTACubeExposure::read(const GFits& fits) // Get HDUs const GFitsImage& hdu_expcube = *fits.image("Primary"); - const GFitsTable& hdu_energies = *fits.table("ENERGIES"); - const GFitsTable& hdu_gti = *fits.table("GTI"); + const GFitsTable& hdu_energies = *fits.table(gammalib::extname_energies); + const GFitsTable& hdu_gti = *fits.table(gammalib::extname_gti); // Read cube m_cube.read(hdu_expcube); diff --git a/inst/cta/src/GCTACubePsf.cpp b/inst/cta/src/GCTACubePsf.cpp index 512c16e..223f659 100644 --- a/inst/cta/src/GCTACubePsf.cpp +++ b/inst/cta/src/GCTACubePsf.cpp @@ -478,8 +478,8 @@ void GCTACubePsf::read(const GFits& fits) // Get HDUs const GFitsImage& hdu_psfcube = *fits.image("Primary"); - const GFitsTable& hdu_energies = *fits.table("ENERGIES"); - const GFitsTable& hdu_deltas = *fits.table("DELTAS"); + const GFitsTable& hdu_energies = *fits.table(gammalib::extname_energies); + const GFitsTable& hdu_deltas = *fits.table(gammalib::extname_deltas); // Read cube m_cube.read(hdu_psfcube); @@ -522,10 +522,10 @@ void GCTACubePsf::write(GFits& fits) const m_energies.write(fits); // Write delta nodes - m_deltas.write(fits, "DELTAS"); + m_deltas.write(fits, gammalib::extname_deltas); // Set the nodes unit to "deg" - (*fits.table("DELTAS"))["Value"]->unit("deg"); + (*fits.table(gammalib::extname_deltas))["Value"]->unit("deg"); // Return return; diff --git a/inst/cta/src/GCTAEdisp2D.cpp b/inst/cta/src/GCTAEdisp2D.cpp index 39a1bb4..24c8741 100644 --- a/inst/cta/src/GCTAEdisp2D.cpp +++ b/inst/cta/src/GCTAEdisp2D.cpp @@ -430,7 +430,7 @@ void GCTAEdisp2D::write(GFitsBinTable& table) const * Loads the energy dispersion from a FITS file. * * If no extension name is provided, the energy dispersion will be loaded - * from the "ENERGY DISPERSION" extension. + * from the `ENERGY DISPERSION` extension. ***************************************************************************/ void GCTAEdisp2D::load(const GFilename& filename) { @@ -456,7 +456,7 @@ void GCTAEdisp2D::load(const GFilename& filename) * opens the existing file. The method will create a (or replace an existing) * energy dispersion extension. The extension name can be specified as part * of the @p filename, or if no extension name is given, is assumed to be - * "ENERGY DISPERSION". + * `ENERGY DISPERSION`. * * An existing file will only be modified if the @p clobber flag is set to * true. @@ -464,7 +464,7 @@ void GCTAEdisp2D::load(const GFilename& filename) void GCTAEdisp2D::save(const GFilename& filename, const bool& clobber) const { // Get extension name - std::string extname = filename.extname("ENERGY DISPERSION"); + std::string extname = filename.extname(gammalib::extname_cta_edisp2d); // Open or create FITS file (without extension name since the requested // extension may not yet exist in the file) @@ -745,7 +745,8 @@ void GCTAEdisp2D::fetch(void) const GFits fits(m_filename); // Initialise energy dispersion extension name - std::string extname = m_filename.extname("ENERGY DISPERSION"); + std::string extname = + m_filename.extname(gammalib::extname_cta_edisp2d); // Get energy dispersion table const GFitsTable& table = *fits.table(extname); diff --git a/inst/cta/src/GCTAEventCube.cpp b/inst/cta/src/GCTAEventCube.cpp index 0fad4e9..3f725c9 100644 --- a/inst/cta/src/GCTAEventCube.cpp +++ b/inst/cta/src/GCTAEventCube.cpp @@ -437,14 +437,14 @@ void GCTAEventCube::read(const GFits& fits) // Set counts cube HDU std::string counts_hdu("Primary"); - if (fits.contains("COUNTS")) { - counts_hdu = "COUNTS"; + if (fits.contains(gammalib::extname_cta_counts)) { + counts_hdu = gammalib::extname_cta_counts; } // Get HDUs const GFitsImage& hdu_cntmap = *fits.image(counts_hdu); - const GFitsTable& hdu_ebounds = *fits.table("EBOUNDS"); - const GFitsTable& hdu_gti = *fits.table("GTI"); + const GFitsTable& hdu_ebounds = *fits.table(gammalib::extname_ebounds); + const GFitsTable& hdu_gti = *fits.table(gammalib::extname_gti); // Load counts map read_cntmap(hdu_cntmap); @@ -456,10 +456,10 @@ void GCTAEventCube::read(const GFits& fits) read_gti(hdu_gti); // If a WEIGHTS HDU exist then load it from the FITS file ... - if (fits.contains("WEIGHTS")) { + if (fits.contains(gammalib::extname_cta_weights)) { // Get WEIGHTS HDU - const GFitsImage& hdu_weights = *fits.image("WEIGHTS"); + const GFitsImage& hdu_weights = *fits.image(gammalib::extname_cta_weights); // Read HDU m_weights.read(hdu_weights); @@ -500,27 +500,27 @@ void GCTAEventCube::read(const GFits& fits) void GCTAEventCube::write(GFits& fits) const { // Remove HDUs if they exist already - if (fits.contains("GTI")) { - fits.remove("GTI"); + if (fits.contains(gammalib::extname_gti)) { + fits.remove(gammalib::extname_gti); } - if (fits.contains("EBOUNDS")) { - fits.remove("EBOUNDS"); + if (fits.contains(gammalib::extname_ebounds)) { + fits.remove(gammalib::extname_ebounds); } - if (fits.contains("WEIGHTS")) { - fits.remove("WEIGHTS"); + if (fits.contains(gammalib::extname_cta_weights)) { + fits.remove(gammalib::extname_cta_weights); } - if (fits.contains("COUNTS")) { - fits.remove("COUNTS"); + if (fits.contains(gammalib::extname_cta_counts)) { + fits.remove(gammalib::extname_cta_counts); } if (fits.contains("Primary")) { fits.remove("Primary"); } // Write counts cube - m_map.write(fits, "COUNTS"); + m_map.write(fits, gammalib::extname_cta_counts); // Write cube weighting - m_weights.write(fits, "WEIGHTS"); + m_weights.write(fits, gammalib::extname_cta_weights); // Write energy boundaries ebounds().write(fits); diff --git a/inst/cta/src/GCTAEventList.cpp b/inst/cta/src/GCTAEventList.cpp index f238234..bef0241 100644 --- a/inst/cta/src/GCTAEventList.cpp +++ b/inst/cta/src/GCTAEventList.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GCTAEventList.cpp - CTA event list class * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2016 by Juergen Knoedlseder * + * copyright (C) 2010-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -325,17 +325,17 @@ void GCTAEventList::save(const GFilename& filename, * * Reads the event list from a FITS file. * - * The events will be read by default from the extension "EVENTS" unless + * The events will be read by default from the extension `EVENTS` unless * an extension name is explicitly specified in the FITS file name. The * FITS header of the extension will be scanned for data sub-space keywords * to extract the energy boundaries, the region of interest, as well as the * extension name for the Good Time Intervals. If no extension name for * Good Time Intervals is found it is expected that the Good Time Intervals - * reside in the "GTI" extension. + * reside in the `GTI` extension. * * If a Good Time Intervals is found in the same FITS file, the Good Time * Intervals will be loaded. Otherwise, a single Good Time Interval will - * be assumed based on the "TSTART" and "TSTOP" keywords found in the header + * be assumed based on the `TSTART` and `TSTOP` keywords found in the header * of the event list. * * The method clears the event list before reading, thus any events that @@ -356,7 +356,7 @@ void GCTAEventList::read(const GFits& fits) m_filename = fits.filename(); // Initialise events extension name - std::string extname = fits.filename().extname("EVENTS"); + std::string extname = fits.filename().extname(gammalib::extname_cta_events); // Get event list HDU const GFitsTable& events = *fits.table(extname); @@ -385,7 +385,7 @@ void GCTAEventList::read(const GFits& fits) // If no GTI extension name was found then if (gti_extname.empty()) { - gti_extname = "GTI"; + gti_extname = gammalib::extname_gti; } // If GTI extension is present in FITS file then read Good Time Intervals @@ -443,7 +443,7 @@ void GCTAEventList::read(const GFits& fits) * * Writes the CTA event list and the Good Time intervals into a FITS file. * - * The events will be written by default into the extension "EVENTS" unless + * The events will be written by default into the extension `EVENTS` unless * an extension name is explicitly specified in the FITS file name. The * method also writes the data sub-space keywords in the FITS header of the * events table. @@ -451,15 +451,16 @@ void GCTAEventList::read(const GFits& fits) * In addition, the method will also append a table containing the Good Time * Intervals of the events to the FITS file. The extension name for the Good * Time Intervals is either taken from the m_gti_extname member, or if empty, - * is set to "GTI". + * is set to `GTI`. ***************************************************************************/ void GCTAEventList::write(GFits& fits) const { // Set event extension name - std::string evtname = fits.filename().extname("EVENTS"); + std::string evtname = fits.filename().extname(gammalib::extname_cta_events); // Set GTI extension name - std::string gtiname = (m_gti_extname.empty()) ? "GTI" : m_gti_extname; + std::string gtiname = (m_gti_extname.empty()) + ? gammalib::extname_gti : m_gti_extname; // Write events and GTIs write(fits, evtname, gtiname); @@ -662,7 +663,7 @@ void GCTAEventList::fetch(void) const GFits fits(m_filename); // Initialise events extension name - std::string extname = fits.filename().extname("EVENTS"); + std::string extname = fits.filename().extname(gammalib::extname_cta_events); // Get event list HDU const GFitsTable& events = *fits.table(extname); @@ -869,7 +870,7 @@ void GCTAEventList::init_members(void) m_columns.clear(); m_filename.clear(); m_num_events = 0; - m_gti_extname = "GTI"; //!< Default GTI extension name + m_gti_extname = gammalib::extname_gti; //!< Default GTI extension name m_has_phase = false; m_has_detxy = true; @@ -1075,7 +1076,7 @@ void GCTAEventList::write_events(GFitsBinTable& hdu) const fetch(); // Set extension name - hdu.extname("EVENTS"); + hdu.extname(gammalib::extname_cta_events); // If there are events then write them now if (size() > 0) { diff --git a/inst/cta/src/GCTAObservation.cpp b/inst/cta/src/GCTAObservation.cpp index b768730..f21e2fa 100644 --- a/inst/cta/src/GCTAObservation.cpp +++ b/inst/cta/src/GCTAObservation.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GCTAObservation.cpp - CTA Observation class * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2016 by Juergen Knoedlseder * + * copyright (C) 2010-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -998,7 +998,7 @@ void GCTAObservation::write(GXmlElement& xml) const * depending of the information provided in the FITS file. If an extension * name is specified, the method checks whether the extension exists and * loads the extension as event list. Otherwise, it checks whether the file - * contains an "EVENTS" extension and loads the extension as event list. + * contains an `EVENTS` extension and loads the extension as event list. * If none of the above are satistified, the method loads a counts cube. ***************************************************************************/ void GCTAObservation::read(const GFits& fits) @@ -1012,7 +1012,7 @@ void GCTAObservation::read(const GFits& fits) GFilename filename(fits.filename()); // Get extension name - std::string extname = filename.extname("EVENTS"); + std::string extname = filename.extname(gammalib::extname_cta_events); // If FITS file contains an EVENTS extension we have an unbinned // observation ... @@ -1060,8 +1060,8 @@ void GCTAObservation::read(const GFits& fits) * @brief Write observation into FITS file. * * @param[in] fits FITS file. - * @param[in] evtname Events FITS extension name (default: "EVENTS"). - * @param[in] gtiname Good Time Intervals FITS extension name (default: "GTI"). + * @param[in] evtname Events FITS extension name. + * @param[in] gtiname Good Time Intervals FITS extension name. * * Writes the observation into a FITS file. * @@ -1264,7 +1264,7 @@ void GCTAObservation::load(const GFilename& cntcube, * If the CTA observation contains an event cube, the method will write the * cube into the primary image, followed by binary tables containing the * energy boundaries and the Good Time Intervals. The extension names of - * these binary tables are "EBOUNDS" and "GTI", and cannot be modified. + * these binary tables are `EBOUNDS` and `GTI`, and cannot be modified. ***************************************************************************/ void GCTAObservation::save(const GFilename& filename, const bool& clobber) const @@ -1274,8 +1274,8 @@ void GCTAObservation::save(const GFilename& filename, // The specific format that is implemented is [events;gti], where the // part before the semi-colon is the events extension name and the part // after the semi-colon is the Good Time Intervals extension name. - std::string evtname = "EVENTS"; - std::string gtiname = "GTI"; + std::string evtname = gammalib::extname_cta_events; + std::string gtiname = gammalib::extname_gti; if (filename.has_extname()) { std::vector extnames = gammalib::split(filename.extname(), ";"); if (extnames.size() > 0) { diff --git a/inst/cta/src/GCTAOnOffObservation.cpp b/inst/cta/src/GCTAOnOffObservation.cpp index af2f166..94d7238 100644 --- a/inst/cta/src/GCTAOnOffObservation.cpp +++ b/inst/cta/src/GCTAOnOffObservation.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GCTAOnOffObservation.cpp - CTA On/Off observation class * * ----------------------------------------------------------------------- * - * copyright (C) 2013-2016 by Chia-Chun Lu & Christoph Deil * + * copyright (C) 2013-2017 by Chia-Chun Lu & Christoph Deil * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -1007,7 +1007,7 @@ void GCTAOnOffObservation::compute_arf(const GCTAObservation& obs) * * Compute the background rate in units of events/s/MeV in all Off regions * and stores the background rate as additional column with name - * "BACKGROUND" in the Auxiliary Response File (ARF). + * `BACKGROUND` in the Auxiliary Response File (ARF). * * @todo Should implement integration of background model over region. * @todo Allow general region, not only circles. diff --git a/inst/cta/src/GCTAPsf2D.cpp b/inst/cta/src/GCTAPsf2D.cpp index 73270e4..7ee02a0 100644 --- a/inst/cta/src/GCTAPsf2D.cpp +++ b/inst/cta/src/GCTAPsf2D.cpp @@ -385,7 +385,7 @@ void GCTAPsf2D::write(GFitsBinTable& table) const * Loads the point spread function from a FITS file. * * If no extension name is provided, the point spread function will be loaded - * from the "POINT SPREAD FUNCTION" extension. + * from the `POINT SPREAD FUNCTION` extension. ***************************************************************************/ void GCTAPsf2D::load(const GFilename& filename) { @@ -393,7 +393,8 @@ void GCTAPsf2D::load(const GFilename& filename) GFits fits(filename); // Get PSFa table - const GFitsTable& table = *fits.table(filename.extname("POINT SPREAD FUNCTION")); + const GFitsTable& table = + *fits.table(filename.extname(gammalib::extname_cta_psf2d)); // Read PSF from table read(table); @@ -413,17 +414,17 @@ void GCTAPsf2D::load(const GFilename& filename) * @brief Save point spread function table into FITS file * * @param[in] filename FITS file name. - * @param[in] clobber Overwrite existing file? (default: false) + * @param[in] clobber Overwrite existing file? * * Save the point spread function into a FITS file. * * If no extension name is provided, the point spread function will be saved - * into the "POINT SPREAD FUNCTION" extension. + * into the `POINT SPREAD FUNCTION` extension. ***************************************************************************/ void GCTAPsf2D::save(const GFilename& filename, const bool& clobber) const { // Get extension name - std::string extname = filename.extname("POINT SPREAD FUNCTION"); + std::string extname = filename.extname(gammalib::extname_cta_psf2d); // Open or create FITS file (without extension name since the requested // extension may not yet exist in the file) diff --git a/inst/cta/src/GCTAPsfKing.cpp b/inst/cta/src/GCTAPsfKing.cpp index 859e201..43ac863 100644 --- a/inst/cta/src/GCTAPsfKing.cpp +++ b/inst/cta/src/GCTAPsfKing.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GCTAPsfKing.cpp - King profile CTA point spread function class * * ----------------------------------------------------------------------- * - * copyright (C) 2013-2016 by Michael Mayer * + * copyright (C) 2013-2017 by Michael Mayer * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -379,7 +379,7 @@ void GCTAPsfKing::write(GFitsBinTable& table) const * Loads the point spread function from a FITS file. * * If no extension name is provided, the point spread function will be loaded - * from the "POINT SPREAD FUNCTION" extension. + * from the `POINT SPREAD FUNCTION` extension. ***************************************************************************/ void GCTAPsfKing::load(const GFilename& filename) { @@ -387,7 +387,8 @@ void GCTAPsfKing::load(const GFilename& filename) GFits fits(filename); // Get PSFa table - const GFitsTable& table = *fits.table(filename.extname("POINT SPREAD FUNCTION")); + const GFitsTable& table = + *fits.table(filename.extname(gammalib::extname_cta_psfking)); // Read PSF from table read(table); @@ -406,14 +407,14 @@ void GCTAPsfKing::load(const GFilename& filename) * @brief Save point spread function table into FITS file * * @param[in] filename FITS file name. - * @param[in] clobber Overwrite existing file? (default: false) + * @param[in] clobber Overwrite existing file? * * Saves point spread function into a FITS file. If a file with the given * @p filename does not yet exist it will be created, otherwise the method * opens the existing file. The method will create a (or replace an existing) * point spread function extension. The extension name can be specified as * part of the @p filename, or if no extension name is given, is assumed to - * be "POINT SPREAD FUNCTION". + * be `POINT SPREAD FUNCTION`. * * An existing file will only be modified if the @p clobber flag is set to * true. @@ -421,7 +422,7 @@ void GCTAPsfKing::load(const GFilename& filename) void GCTAPsfKing::save(const GFilename& filename, const bool& clobber) const { // Get extension name - std::string extname = filename.extname("POINT SPREAD FUNCTION"); + std::string extname = filename.extname(gammalib::extname_cta_psfking); // Open or create FITS file (without extension name since the requested // extension may not yet exist in the file) diff --git a/inst/cta/src/GCTAPsfTable.cpp b/inst/cta/src/GCTAPsfTable.cpp index 88e3c07..cf5cd23 100644 --- a/inst/cta/src/GCTAPsfTable.cpp +++ b/inst/cta/src/GCTAPsfTable.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GCTAPsfTable.cpp - CTA point spread function table class * * ----------------------------------------------------------------------- * - * copyright (C) 2016 by Juergen Knoedlseder * + * copyright (C) 2016-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -355,7 +355,7 @@ void GCTAPsfTable::write(GFitsBinTable& table) const * Loads the point spread function from a FITS file. * * If no extension name is provided, the point spread function will be loaded - * from the "POINT SPREAD FUNCTION" extension. + * from the `POINT SPREAD FUNCTION` extension. ***************************************************************************/ void GCTAPsfTable::load(const GFilename& filename) { @@ -363,7 +363,8 @@ void GCTAPsfTable::load(const GFilename& filename) GFits fits(filename); // Get PSF table - const GFitsTable& table = *fits.table(filename.extname("POINT SPREAD FUNCTION")); + const GFitsTable& table = + *fits.table(filename.extname(gammalib::extname_cta_psftable)); // Read PSF from table read(table); @@ -382,14 +383,14 @@ void GCTAPsfTable::load(const GFilename& filename) * @brief Save point spread function table into FITS file * * @param[in] filename FITS file name. - * @param[in] clobber Overwrite existing file? (default: false) + * @param[in] clobber Overwrite existing file? * * Saves point spread function into a FITS file. If a file with the given * @p filename does not yet exist it will be created, otherwise the method * opens the existing file. The method will create a (or replace an existing) * point spread function extension. The extension name can be specified as * part of the @p filename, or if no extension name is given, is assumed to - * be "POINT SPREAD FUNCTION". + * be `POINT SPREAD FUNCTION`. * * An existing file will only be modified if the @p clobber flag is set to * true. @@ -397,7 +398,7 @@ void GCTAPsfTable::load(const GFilename& filename) void GCTAPsfTable::save(const GFilename& filename, const bool& clobber) const { // Get extension name - std::string extname = filename.extname("POINT SPREAD FUNCTION"); + std::string extname = filename.extname(gammalib::extname_cta_psftable); // Open or create FITS file (without extension name since the requested // extension may not yet exist in the file) diff --git a/inst/cta/src/GCTAResponseIrf.cpp b/inst/cta/src/GCTAResponseIrf.cpp index 865f2e4..dac8548 100644 --- a/inst/cta/src/GCTAResponseIrf.cpp +++ b/inst/cta/src/GCTAResponseIrf.cpp @@ -45,6 +45,7 @@ #include "GModelSpatialRadialShell.hpp" #include "GModelSpatialElliptical.hpp" #include "GModelSpatialComposite.hpp" +#include "GArf.hpp" #include "GCTAObservation.hpp" #include "GCTAResponseIrf.hpp" #include "GCTAResponse_helpers.hpp" @@ -1088,11 +1089,11 @@ void GCTAResponseIrf::load(const std::string& rspname) * * If the file is a FITS file, the method will either use the extension name * specified with the filename, or if no extension name is given, search for - * an "EFFECTIVE AREA" or "SPECRESP" extension in the file and open the - * corresponding FITS table. If a column named "SPECRESP" is found in the + * an `EFFECTIVE AREA` or `SPECRESP` extension in the file and open the + * corresponding FITS table. If a column named `SPECRESP` is found in the * table, a GCTAAeffArf object will be allocated. Otherwise, a GCTAAeff2D * object will be allocated. In both cases, the method will extract the - * optional "LO_THRES" and "HI_THRES" save energy thresholds from the FITS + * optional `LO_THRES` and `HI_THRES` save energy thresholds from the FITS * file header. * * If the file is not a FITS file, it will be interpreted as a @@ -1125,11 +1126,11 @@ void GCTAResponseIrf::load_aeff(const GFilename& filename) extname = filename.extname(); } else { - if (fits.contains("EFFECTIVE AREA")) { - extname = "EFFECTIVE AREA"; + if (fits.contains(gammalib::extname_cta_aeff2d)) { + extname = gammalib::extname_cta_aeff2d; } - else if (fits.contains("SPECRESP")) { - extname = "SPECRESP"; + else if (fits.contains(gammalib::extname_arf)) { + extname = gammalib::extname_arf; } } @@ -1148,7 +1149,7 @@ void GCTAResponseIrf::load_aeff(const GFilename& filename) } // Check for specific table column - if (table.contains("SPECRESP")) { + if (table.contains(gammalib::extname_arf)) { // Close file fits.close(); @@ -1212,13 +1213,13 @@ void GCTAResponseIrf::load_aeff(const GFilename& filename) * PSF * PSF_2D_TABLE * - * in the file and open the corresponding FITS table. If columns named "GAMMA" - * and "SIGMA" are found in the table, a GCTAPsfKing object will be allocated. + * in the file and open the corresponding FITS table. If columns named `GAMMA` + * and `SIGMA` are found in the table, a GCTAPsfKing object will be allocated. * - * If columns named "SCALE", "SIGMA_1", "AMPL_2", "SIGMA_2", "AMPL_3" and - * "SIGMA_3" are found in the table, a GCTAPsf2D object will be allocated. + * If columns named `SCALE`, `SIGMA_1`, `AMPL_2`, `SIGMA_2`, `AMPL_3` and + * `SIGMA_3` are found in the table, a GCTAPsf2D object will be allocated. * - * If columns named "RAD_LO", "RAD_HI", and "RPSF" are found in the table, a + * If columns named `RAD_LO`, `RAD_HI`, and `RPSF` are found in the table, a * GCTAPsfTable object will be allocated. * * Otherwise, a CTAPsfVector object will be allocated. @@ -1359,7 +1360,7 @@ void GCTAResponseIrf::load_psf(const GFilename& filename) * * If the file is a FITS file, the method will either use the extension name * specified with the filename, or if no extension name is given, search for - * an "ENERGY DISPERSION" or "MATRIX" extension in the file and open the + * an `ENERGY DISPERSION` or `MATRIX` extension in the file and open the * corresponding FITS table. If columns named "MIGRA_LO" and "MIGRA_HI" are * found in the table, a GCTAEdisp2D object will be allocated. Otherwise, a * GCTAEdispRmf object will be allocated. @@ -1387,18 +1388,18 @@ void GCTAResponseIrf::load_edisp(const GFilename& filename) GFits fits(filename); // Get the extension name. If an extension name has been specified - // then use this name, otherwise use either the "EFFECTIVE AREA" - // or the "SPECRESP" extension. + // then use this name, otherwise use either the "ENERGY DISPERSION" + // or the "MATRIX" extension. std::string extname = ""; if (filename.has_extname()) { extname = filename.extname(); } else { - if (fits.contains("ENERGY DISPERSION")) { - extname = "ENERGY DISPERSION"; + if (fits.contains(gammalib::extname_cta_edisp2d)) { + extname = gammalib::extname_cta_edisp2d; } - else if (fits.contains("MATRIX")) { - extname = "MATRIX"; + else if (fits.contains(gammalib::extname_rmf)) { + extname = gammalib::extname_rmf; } } diff --git a/inst/lat/include/GLATAeff.hpp b/inst/lat/include/GLATAeff.hpp index adac18a..3d3aca6 100644 --- a/inst/lat/include/GLATAeff.hpp +++ b/inst/lat/include/GLATAeff.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * GLATAeff.hpp - Fermi LAT effective area * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2016 by Juergen Knoedlseder * + * copyright (C) 2010-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -40,6 +40,12 @@ class GEnergy; class GFits; class GFitsTable; +/* __ Constants __________________________________________________________ */ +namespace gammalib { + const std::string extname_lat_aeff = "EFFECTIVE AREA"; + const std::string extname_lat_efficiency = "EFFICIENCY_PARAMS"; +} + /***********************************************************************//** * @class GLATAeff diff --git a/inst/lat/include/GLATEdisp.hpp b/inst/lat/include/GLATEdisp.hpp index 05cd7e4..7b8cbdb 100644 --- a/inst/lat/include/GLATEdisp.hpp +++ b/inst/lat/include/GLATEdisp.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * GLATEdisp.hpp - Fermi LAT energy dispersion * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2016 by Juergen Knoedlseder * + * copyright (C) 2010-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -38,6 +38,12 @@ class GFilename; class GFits; class GFitsTable; +/* __ Constants __________________________________________________________ */ +namespace gammalib { + const std::string extname_lat_edisp = "ENERGY DISPERSION"; + const std::string extname_lat_edisp_scale = "EDISP_SCALING_PARAMS"; +} + /***********************************************************************//** * @class GLATEdisp diff --git a/inst/lat/include/GLATEventList.hpp b/inst/lat/include/GLATEventList.hpp index bdc0af4..6ee0f62 100644 --- a/inst/lat/include/GLATEventList.hpp +++ b/inst/lat/include/GLATEventList.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * GLATEventList.hpp - Fermi/LAT event list class * * ----------------------------------------------------------------------- * - * copyright (C) 2009-2016 by Juergen Knoedlseder * + * copyright (C) 2009-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -40,6 +40,11 @@ /* __ Forward declarations _______________________________________________ */ class GFilename; +/* __ Constants __________________________________________________________ */ +namespace gammalib { + const std::string extname_lat_events = "EVENTS"; +} + /***********************************************************************//** * @class GLATEventList diff --git a/inst/lat/include/GLATLtCube.hpp b/inst/lat/include/GLATLtCube.hpp index 840ef9f..44c422e 100644 --- a/inst/lat/include/GLATLtCube.hpp +++ b/inst/lat/include/GLATLtCube.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * GLATLtCube.hpp - Fermi/LAT livetime cube class * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2016 by Juergen Knoedlseder * + * copyright (C) 2010-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -40,6 +40,13 @@ class GEnergy; class GLATAeff; class GLATPsf; +/* __ Constants __________________________________________________________ */ +namespace gammalib { + const std::string extname_lat_exposure = "EXPOSURE"; + const std::string extname_lat_wgtexposure = "WEIGHTED_EXPOSURE"; + const std::string extname_lat_cthetabounds = "CTHETABOUNDS"; +} + /***********************************************************************//** * @class GLATLtCube diff --git a/inst/lat/src/GLATAeff.cpp b/inst/lat/src/GLATAeff.cpp index c510d03..9e1cff3 100644 --- a/inst/lat/src/GLATAeff.cpp +++ b/inst/lat/src/GLATAeff.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GLATAeff.cpp - Fermi LAT effective area * * ----------------------------------------------------------------------- * - * copyright (C) 2008-2016 by Juergen Knoedlseder * + * copyright (C) 2008-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -309,10 +309,10 @@ void GLATAeff::save(const GFilename& filename, const bool& clobber) * @param[in] fits FITS file. * * Reads the effective area and efficiency parameter information form the - * FITS file. The effective area is read from the extension EFFECTIVE AREA - * (or EFFECTIVE AREA_ for Pass 8), the efficiency parameter - * information from the extension EFFICIENCY_PARAMS (or - * EFFICIENCY_PARAMS_ for Pass 8). If the latter extension does not + * FITS file. The effective area is read from the extension `EFFECTIVE AREA` + * (or `EFFECTIVE AREA_` for Pass 8), the efficiency parameter + * information from the extension `EFFICIENCY_PARAMS` (or + * `EFFICIENCY_PARAMS_` for Pass 8). If the latter extension does not * exist, no efficiency parameters will be loaded. * * @todo Implement reading of Phi-dependence information. @@ -325,8 +325,8 @@ void GLATAeff::read(const GFits& fits) m_evtype = evtype; // Set extension names - std::string effarea = "EFFECTIVE AREA"; - std::string effparms = "EFFICIENCY_PARAMS"; + std::string effarea = gammalib::extname_lat_aeff; + std::string effparms = gammalib::extname_lat_efficiency; if (!fits.contains(effarea)) { effarea += "_" + m_evtype; } @@ -702,7 +702,7 @@ void GLATAeff::write_aeff(GFits& file) const GFitsBinTable* hdu_aeff = new GFitsBinTable; // Set table attributes - hdu_aeff->extname("EFFECTIVE AREA"); + hdu_aeff->extname(gammalib::extname_lat_aeff); // Write boundaries into table m_aeff_bins.write(*hdu_aeff); diff --git a/inst/lat/src/GLATEdisp.cpp b/inst/lat/src/GLATEdisp.cpp index 76991ae..740227d 100644 --- a/inst/lat/src/GLATEdisp.cpp +++ b/inst/lat/src/GLATEdisp.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GLATEdisp.cpp - Fermi LAT energy dispersion * * ----------------------------------------------------------------------- * - * copyright (C) 2008-2016 by Juergen Knoedlseder * + * copyright (C) 2008-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -249,8 +249,8 @@ void GLATEdisp::read(const GFits& fits) m_evtype = evtype; // Set extension names - std::string engdisp = "ENERGY DISPERSION"; - std::string escales = "EDISP_SCALING_PARAMS"; + std::string engdisp = gammalib::extname_lat_edisp; + std::string escales = gammalib::extname_lat_edisp_scale; if (!fits.contains(engdisp)) { engdisp += "_" + m_evtype; } @@ -436,7 +436,7 @@ void GLATEdisp::write_edisp(GFits& file) const GFitsBinTable* hdu_edisp = new GFitsBinTable; // Set table attributes - hdu_edisp->extname("ENERGY DISPERSION"); + hdu_edisp->extname(gammalib::extname_lat_edisp); // Write boundaries into table m_edisp_bins.write(*hdu_edisp); diff --git a/inst/lat/src/GLATEventCube.cpp b/inst/lat/src/GLATEventCube.cpp index 036c459..b590155 100644 --- a/inst/lat/src/GLATEventCube.cpp +++ b/inst/lat/src/GLATEventCube.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GLATEventCube.cpp - Fermi/LAT event cube class * * ----------------------------------------------------------------------- * - * copyright (C) 2009-2016 by Juergen Knoedlseder * + * copyright (C) 2009-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -354,8 +354,8 @@ void GLATEventCube::save(const GFilename& filename, * @param[in] fits FITS file. * * It is assumed that the counts map resides in the primary extension of the - * FITS file, the energy boundaries reside in the EBOUNDS extension and the - * Good Time Intervals reside in the GTI extension. The method clears the + * FITS file, the energy boundaries reside in the `EBOUNDS` extension and the + * Good Time Intervals reside in the `GTI` extension. The method clears the * object before loading, thus any events residing in the object before * loading will be lost. ***************************************************************************/ @@ -366,8 +366,8 @@ void GLATEventCube::read(const GFits& fits) // Get HDUs const GFitsImage& hdu_cntmap = *fits.image("Primary"); - const GFitsTable& hdu_ebounds = *fits.table("EBOUNDS"); - const GFitsTable& hdu_gti = *fits.table("GTI"); + const GFitsTable& hdu_ebounds = *fits.table(gammalib::extname_ebounds); + const GFitsTable& hdu_gti = *fits.table(gammalib::extname_gti); // Load counts map read_cntmap(hdu_cntmap); diff --git a/inst/lat/src/GLATEventList.cpp b/inst/lat/src/GLATEventList.cpp index b4a494f..fb16e9d 100644 --- a/inst/lat/src/GLATEventList.cpp +++ b/inst/lat/src/GLATEventList.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GLATEventList.cpp - Fermi/LAT event list class * * ----------------------------------------------------------------------- * - * copyright (C) 2009-2016 by Juergen Knoedlseder * + * copyright (C) 2009-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -299,7 +299,7 @@ void GLATEventList::read(const GFits& file) clear(); // Get HDU (pointer is always valid) - const GFitsTable& hdu = *file.table("EVENTS"); + const GFitsTable& hdu = *file.table(gammalib::extname_lat_events); // Read event data read_events(hdu); @@ -309,8 +309,8 @@ void GLATEventList::read(const GFits& file) // If we have a GTI extension, then read Good Time Intervals from that // extension - if (file.contains("GTI")) { - const GFitsTable& gti = *file.table("GTI"); + if (file.contains(gammalib::extname_gti)) { + const GFitsTable& gti = *file.table(gammalib::extname_gti); m_gti.read(gti); } diff --git a/inst/lat/src/GLATLtCube.cpp b/inst/lat/src/GLATLtCube.cpp index 55b5c92..79562c6 100644 --- a/inst/lat/src/GLATLtCube.cpp +++ b/inst/lat/src/GLATLtCube.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GLATLtCube.cpp - Fermi/LAT livetime cube class * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2016 by Juergen Knoedlseder * + * copyright (C) 2010-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -399,10 +399,10 @@ void GLATLtCube::load(const GFilename& filename) GFits fits(filename); // Get HDUs - const GFitsTable& hdu_exposure = *fits.table("EXPOSURE"); - const GFitsTable& hdu_weighted_exposure = *fits.table("WEIGHTED_EXPOSURE"); - //const GFitsTable& hdu_cthetabounds = *fits.table("CTHETABOUNDS"); - const GFitsTable& hdu_gti = *fits.table("GTI"); + const GFitsTable& hdu_exposure = *fits.table(gammalib::extname_lat_exposure); + const GFitsTable& hdu_weighted_exposure = *fits.table(gammalib::extname_lat_wgtexposure); + //const GFitsTable& hdu_cthetabounds = *fits.table(gammalib::extname_lat_cthetabounds); + const GFitsTable& hdu_gti = *fits.table(gammalib::extname_gti); // Load exposure m_exposure.read(hdu_exposure); diff --git a/pyext/GEbounds.i b/pyext/GEbounds.i index 1f29aa1..e30a392 100644 --- a/pyext/GEbounds.i +++ b/pyext/GEbounds.i @@ -70,7 +70,7 @@ public: const std::string& unit = "keV") const; void read(const GFitsTable& table); void write(GFits& file, - const std::string& extname = "EBOUNDS", + const std::string& extname = gammalib::extname_ebounds, const std::string& unit = "keV") const; void read(const GXmlElement& xml); void write(GXmlElement& xml) const; diff --git a/pyext/GEnergies.i b/pyext/GEnergies.i index 078f15c..d27c8be 100644 --- a/pyext/GEnergies.i +++ b/pyext/GEnergies.i @@ -70,7 +70,7 @@ public: const bool& clobber = false) const; void read(const GFitsTable& table); void write(GFits& file, - const std::string& extname = "ENERGIES") const; + const std::string& extname = gammalib::extname_energies) const; }; diff --git a/pyext/GGti.i b/pyext/GGti.i index 9f2f3bd..91ab6ac 100644 --- a/pyext/GGti.i +++ b/pyext/GGti.i @@ -1,7 +1,7 @@ /*************************************************************************** * GGti.i - Good time interval class * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2016 by Juergen Knoedlseder * + * copyright (C) 2010-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -66,7 +66,7 @@ public: const bool& clobber = false) const; void read(const GFitsTable& table); void write(GFits& fits, - const std::string& extname = "GTI") const; + const std::string& extname = gammalib::extname_gti) const; void read(const GXmlElement& xml); void write(GXmlElement& xml) const; const GTime& tstart(void) const; diff --git a/src/obs/GEbounds.cpp b/src/obs/GEbounds.cpp index 59e0c7e..faf5277 100644 --- a/src/obs/GEbounds.cpp +++ b/src/obs/GEbounds.cpp @@ -642,7 +642,7 @@ void GEbounds::set_log(const int& num, const GEnergy& emin, const GEnergy& emax) * Loads the energy boundaries from a FITS file. * * If no extension name is provided, the energy boundaries are loaded from - * the "EBOUNDS" extension. + * the `EBOUNDS` extension. ***************************************************************************/ void GEbounds::load(const GFilename& filename) { @@ -650,7 +650,7 @@ void GEbounds::load(const GFilename& filename) GFits fits(filename); // Get energy boundary table - const GFitsTable& table = *fits.table(filename.extname("EBOUNDS")); + const GFitsTable& table = *fits.table(filename.extname(gammalib::extname_ebounds)); // Read energy boundaries from table read(table); @@ -673,7 +673,7 @@ void GEbounds::load(const GFilename& filename) * Saves energy boundaries into a FITS file. If a file with the given * @p filename does not yet exist it will be created, otherwise the method * opens the existing file. Energy boundaries can only be appended to an - * existing file if the @p clobber flag is set to `true` (otherwise an + * existing file if the @p clobber flag is set to "true" (otherwise an * exception is thrown). * * The method will append a binary FITS table containing the energy @@ -683,7 +683,7 @@ void GEbounds::load(const GFilename& filename) * myfile.fits[ENERGY BOUNDARIES] * * will save the energy boundaries in the `ENERGY BOUNDARIES` extension of - * the `myfile.fits` file. If the extension exists already in the file it + * the "myfile.fits" file. If the extension exists already in the file it * will be replaced, otherwise a new extension will be created. If no * extension name is provided, the method will use `EBOUNDS` as the default * extension name for energy boundaries. @@ -697,7 +697,7 @@ void GEbounds::save(const GFilename& filename, GFits fits(filename.url(), true); // Write energy boundaries to FITS file - write(fits, filename.extname("EBOUNDS"), unit); + write(fits, filename.extname(gammalib::extname_ebounds), unit); // Save to file fits.save(clobber); @@ -762,8 +762,8 @@ void GEbounds::read(const GFitsTable& table) * @brief Write energy boundaries into FITS object * * @param[in] fits FITS file. - * @param[in] extname Energy boundary extension name (defaults to "EBOUNDS") - * @param[in] unit Energy units (defaults to "keV") + * @param[in] extname Energy boundary extension name. + * @param[in] unit Energy units. * * Writes the energy boundaries into a FITS object. The @p unit parameter * specifies in which unit the energies are written. By default, the energy @@ -801,7 +801,7 @@ void GEbounds::write(GFits& fits, fits.remove(extname); } - // Append EBOUNDS table to FITS file + // Append energy boundary table to FITS file fits.append(table); // Return diff --git a/src/obs/GEnergies.cpp b/src/obs/GEnergies.cpp index 936ec28..df22753 100644 --- a/src/obs/GEnergies.cpp +++ b/src/obs/GEnergies.cpp @@ -610,7 +610,7 @@ void GEnergies::set_log(const int& num, * Loads the energies from FITS file. * * If no extension name is provided, the energies are loaded from the - * "ENERGIES" extension. + * `ENERGIES` extension. ***************************************************************************/ void GEnergies::load(const GFilename& filename) { @@ -618,7 +618,7 @@ void GEnergies::load(const GFilename& filename) GFits fits(filename); // Get energies table - const GFitsTable& table = *fits.table(filename.extname("ENERGIES")); + const GFitsTable& table = *fits.table(filename.extname(gammalib::extname_energies)); // Read energies from table read(table); @@ -661,7 +661,7 @@ void GEnergies::save(const GFilename& filename, const bool& clobber) const GFits fits(filename.url(), true); // Write energies to FITS file - write(fits, filename.extname("ENERGIES")); + write(fits, filename.extname(gammalib::extname_energies)); // Save to file fits.save(clobber); @@ -718,7 +718,7 @@ void GEnergies::read(const GFitsTable& table) * @brief Write energies into FITS object * * @param[in] fits FITS file. - * @param[in] extname Energy extension name (default: "ENERGIES") + * @param[in] extname Energy extension name. * * Writes energies into FITS object. ***************************************************************************/ @@ -747,7 +747,7 @@ void GEnergies::write(GFits& fits, const std::string& extname) const fits.remove(extname); } - // Append ENERGIES table to FITS file + // Append energies table to FITS file fits.append(table); // Return diff --git a/src/obs/GGti.cpp b/src/obs/GGti.cpp index 5daac77..22d6ebf 100644 --- a/src/obs/GGti.cpp +++ b/src/obs/GGti.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GGti.cpp - Good time interval class * * ----------------------------------------------------------------------- * - * copyright (C) 2008-2016 by Juergen Knoedlseder * + * copyright (C) 2008-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -580,7 +580,7 @@ void GGti::extend(const GGti& gti) * Loads the Good Time Intervals from FITS file. * * If no extension name is provided in the @p filename, the Good Time - * Intervals are loaded from the "GTI" extension. + * Intervals are loaded from the `GTI` extension. ***************************************************************************/ void GGti::load(const GFilename& filename) { @@ -588,7 +588,7 @@ void GGti::load(const GFilename& filename) GFits fits(filename); // Get GTI table - const GFitsTable& table = *fits.table(filename.extname("GTI")); + const GFitsTable& table = *fits.table(filename.extname(gammalib::extname_gti)); // Read GTI from table read(table); @@ -632,7 +632,7 @@ void GGti::save(const GFilename& filename, const bool& clobber) const GFits fits(filename.url(), true); // Write GTI to FITS object - write(fits, filename.extname("GTI")); + write(fits, filename.extname(gammalib::extname_gti)); // Save to file fits.save(clobber); @@ -685,14 +685,14 @@ void GGti::read(const GFitsTable& table) * @brief Write Good Time Intervals and time reference into FITS object * * @param[in] fits FITS file. - * @param[in] extname GTI extension name (defaults to "GTI") + * @param[in] extname GTI extension name. * * Writes Good Time Intervals and time reference into a FITS object. If an * extension with the same name does already exist in the FITS object, the * values in that extension will be replaced. * * The start and stop tims of the Good Time Intervals will be written into - * double precision columns named "START" and "STOP". + * double precision columns named `START` and `STOP`. ***************************************************************************/ void GGti::write(GFits& fits, const std::string& extname) const { diff --git a/src/xspec/GArf.cpp b/src/xspec/GArf.cpp index 05c6caf..848b42f 100644 --- a/src/xspec/GArf.cpp +++ b/src/xspec/GArf.cpp @@ -399,7 +399,7 @@ void GArf::load(const GFilename& filename) GFits fits(filename.url()); // Get ARF table - const GFitsTable& table = *fits.table("SPECRESP"); + const GFitsTable& table = *fits.table(gammalib::extname_arf); // Read ARF data read(table); @@ -554,8 +554,8 @@ void GArf::write(GFits& fits) const { // If the FITS object contains already an extension with the same // name then remove now this extension - if (fits.contains("SPECRESP")) { - fits.remove("SPECRESP"); + if (fits.contains(gammalib::extname_arf)) { + fits.remove(gammalib::extname_arf); } // Set column length @@ -585,7 +585,7 @@ void GArf::write(GFits& fits) const specresp.unit("cm^2"); // Set table attributes - hdu.extname("SPECRESP"); + hdu.extname(gammalib::extname_arf); // Append columns to table hdu.append(energy_lo); diff --git a/src/xspec/GPha.cpp b/src/xspec/GPha.cpp index 9a3a7b7..9c6f440 100644 --- a/src/xspec/GPha.cpp +++ b/src/xspec/GPha.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GPha.cpp - XSPEC Pulse Height Analyzer class * * ----------------------------------------------------------------------- * - * copyright (C) 2013-2016 by Juergen Knoedlseder * + * copyright (C) 2013-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -344,21 +344,21 @@ void GPha::load(const GFilename& filename) GFits fits(filename.url()); // Get PHA table - const GFitsTable& pha = *fits.table("SPECTRUM"); + const GFitsTable& pha = *fits.table(gammalib::extname_pha); // Read PHA data read(pha); - // Optionally read EBOUNDS data - if (fits.contains("EBOUNDS")) { + // Optionally read energy boundaries + if (fits.contains(gammalib::extname_ebounds)) { - // Get EBOUNDS table - const GFitsTable& ebounds = *fits.table("EBOUNDS"); + // Get energy boundary table + const GFitsTable& ebounds = *fits.table(gammalib::extname_ebounds); - // Read EBOUNDS data + // Read energy boundaries m_ebounds.read(ebounds); - } // endif: has EBOUNDS table + } // endif: had energy boundary table // Close FITS file fits.close(); @@ -484,11 +484,11 @@ void GPha::read(const GFitsTable& table) void GPha::write(GFits& fits) const { // Remove extensions if they exist already - if (fits.contains("EBOUNDS")) { - fits.remove("EBOUNDS"); + if (fits.contains(gammalib::extname_ebounds)) { + fits.remove(gammalib::extname_ebounds); } - if (fits.contains("SPECTRUM")) { - fits.remove("SPECTRUM"); + if (fits.contains(gammalib::extname_pha)) { + fits.remove(gammalib::extname_pha); } // Set column length @@ -517,7 +517,7 @@ void GPha::write(GFits& fits) const } // Set table attributes - hdu.extname("SPECTRUM"); + hdu.extname(gammalib::extname_pha); // Append columns to table hdu.append(col_chan); diff --git a/src/xspec/GRmf.cpp b/src/xspec/GRmf.cpp index 3efa0c3..6bb554a 100644 --- a/src/xspec/GRmf.cpp +++ b/src/xspec/GRmf.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GRmf.cpp - XSPEC Redistribution Matrix File class * * ----------------------------------------------------------------------- * - * copyright (C) 2013-2016 by Juergen Knoedlseder * + * copyright (C) 2013-2017 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -387,7 +387,7 @@ void GRmf::load(const GFilename& filename) m_ebds_measured.load(filename.url()); // Get RMF table - const GFitsTable& table = *fits.table("MATRIX"); + const GFitsTable& table = *fits.table(gammalib::extname_rmf); // Read RMF data read(table); @@ -547,11 +547,11 @@ void GRmf::read(const GFitsTable& table) void GRmf::write(GFits& fits, const std::string& unit) const { // Remove extensions if they exist already - if (fits.contains("MATRIX")) { - fits.remove("MATRIX"); + if (fits.contains(gammalib::extname_rmf)) { + fits.remove(gammalib::extname_rmf); } - if (fits.contains("EBOUNDS")) { - fits.remove("EBOUNDS"); + if (fits.contains(gammalib::extname_ebounds)) { + fits.remove(gammalib::extname_ebounds); } // Set table length @@ -648,7 +648,7 @@ void GRmf::write(GFits& fits, const std::string& unit) const energy_hi.unit(unit); // Set table attributes - hdu.extname("MATRIX"); + hdu.extname(gammalib::extname_rmf); // Append columns to table hdu.append(energy_lo); -- libgit2 0.21.4