diff --git a/ChangeLog b/ChangeLog index 9585b41..d1ce26d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ * Version 1.1.0 released ========================= + Use default GTime in GObservation::deadc() method (#1670) The GApplicationPar::filename() methods now take and return GFilename (#1671) Add GFilename methods and remove equivalents from GTools (#1666) Use column names for CTA response table access (#1656) diff --git a/NEWS b/NEWS index 989bddb..c672ea9 100644 --- a/NEWS +++ b/NEWS @@ -125,6 +125,11 @@ A non-const GObservation::events() method has been added to allow for the manipulation of events within an observation without the need to create a local copy. +The argument of GObservation::deadc(GTime) now defaults to GTime() so +that no argument is needed when calling the method. This reflects the +fact that the deadtime correction is often computed as an average value +over the observation, and does in fact not depend on time (#1670). + 11. Optimization module ----------------------- diff --git a/include/GObservation.hpp b/include/GObservation.hpp index 5c92560..5b9aa5a 100644 --- a/include/GObservation.hpp +++ b/include/GObservation.hpp @@ -31,13 +31,17 @@ #include #include "GBase.hpp" #include "GEvents.hpp" -#include "GResponse.hpp" -#include "GModels.hpp" #include "GTime.hpp" -#include "GEnergy.hpp" #include "GFunction.hpp" -#include "GVector.hpp" -#include "GMatrixSparse.hpp" + +/* __ Forward declarations _______________________________________________ */ +class GVector; +class GMatrixSparse; +class GModel; +class GModels; +class GModelPar; +class GResponse; +class GXmlElement; /***********************************************************************//** @@ -82,7 +86,7 @@ public: virtual std::string instrument(void) const = 0; virtual double ontime(void) const = 0; virtual double livetime(void) const = 0; - virtual double deadc(const GTime& time) const = 0; + virtual double deadc(const GTime& time = GTime()) const = 0; virtual void read(const GXmlElement& xml) = 0; virtual void write(GXmlElement& xml) const = 0; virtual std::string print(const GChatter& chatter = NORMAL) const = 0; diff --git a/inst/com/include/GCOMObservation.hpp b/inst/com/include/GCOMObservation.hpp index f60b100..edccd82 100644 --- a/inst/com/include/GCOMObservation.hpp +++ b/inst/com/include/GCOMObservation.hpp @@ -28,12 +28,20 @@ #define GCOMOBSERVATION_HPP /* __ Includes ___________________________________________________________ */ +#include #include "GObservation.hpp" #include "GTime.hpp" -#include "GModel.hpp" +#include "GFilename.hpp" +#include "GSkyDir.hpp" #include "GSkyMap.hpp" #include "GCOMResponse.hpp" -#include "GCaldb.hpp" +//#include "GCaldb.hpp" + +/* __ Forward declarations _______________________________________________ */ +class GCaldb; +class GResponse; +class GXmlElement; +class GFitsHDU; /***********************************************************************//** @@ -52,10 +60,10 @@ class GCOMObservation : public GObservation { public: // Constructors and destructors GCOMObservation(void); - GCOMObservation(const std::string& drename, - const std::string& drbname, - const std::string& drgname, - const std::string& drxname); + GCOMObservation(const GFilename& drename, + const GFilename& drbname, + const GFilename& drgname, + const GFilename& drxname); GCOMObservation(const GCOMObservation& obs); virtual ~GCOMObservation(void); @@ -71,16 +79,16 @@ public: virtual std::string instrument(void) const; virtual double ontime(void) const; virtual double livetime(void) const; - virtual double deadc(const GTime& time) const; + virtual double deadc(const GTime& time = GTime()) const; virtual void read(const GXmlElement& xml); virtual void write(GXmlElement& xml) const; virtual std::string print(const GChatter& chatter = NORMAL) const; // Other methods - void load(const std::string& drename, - const std::string& drbname, - const std::string& drgname, - const std::string& drxname); + void load(const GFilename& drename, + const GFilename& drbname, + const GFilename& drgname, + const GFilename& drxname); void response(const std::string& rspname, const GCaldb& caldb); void obs_id(const double& id); void ontime(const double& ontime); @@ -98,20 +106,20 @@ protected: void init_members(void); void copy_members(const GCOMObservation& obs); void free_members(void); - void load_dre(const std::string& drename); - void load_drb(const std::string& drbname); - void load_drg(const std::string& drgname); - void load_drx(const std::string& drxname); + void load_dre(const GFilename& drename); + void load_drb(const GFilename& drbname); + void load_drg(const GFilename& drgname); + void load_drx(const GFilename& drxname); bool check_map(const GSkyMap& map) const; void read_attributes(const GFitsHDU* hdu); void write_attributes(GFitsHDU* hdu) const; // Protected members std::string m_instrument; //!< Instrument name - std::string m_drename; //!< DRE filename - std::string m_drbname; //!< DRB filename - std::string m_drgname; //!< DRG filename - std::string m_drxname; //!< DRX filename + GFilename m_drename; //!< DRE filename + GFilename m_drbname; //!< DRB filename + GFilename m_drgname; //!< DRG filename + GFilename m_drxname; //!< DRX filename GSkyMap m_drb; //!< Background model GSkyMap m_drg; //!< Geometry factors GSkyMap m_drx; //!< Exposure map diff --git a/inst/com/pyext/GCOMObservation.i b/inst/com/pyext/GCOMObservation.i index 3688ce0..0065bc7 100644 --- a/inst/com/pyext/GCOMObservation.i +++ b/inst/com/pyext/GCOMObservation.i @@ -1,7 +1,7 @@ /*************************************************************************** * GCOMObservation.i - COMPTEL observation class * * ----------------------------------------------------------------------- * - * copyright (C) 2012-2015 by Juergen Knoedlseder * + * copyright (C) 2012-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -38,10 +38,10 @@ class GCOMObservation : public GObservation { public: // Constructors and destructors GCOMObservation(void); - GCOMObservation(const std::string& drename, - const std::string& drbname, - const std::string& drgname, - const std::string& drxname); + GCOMObservation(const GFilename& drename, + const GFilename& drbname, + const GFilename& drgname, + const GFilename& drxname); GCOMObservation(const GCOMObservation& obs); virtual ~GCOMObservation(void); @@ -54,15 +54,15 @@ public: virtual std::string instrument(void) const; virtual double ontime(void) const; virtual double livetime(void) const; - virtual double deadc(const GTime& time) const; + virtual double deadc(const GTime& time = GTime()) const; virtual void read(const GXmlElement& xml); virtual void write(GXmlElement& xml) const; // Other methods - void load(const std::string& drename, - const std::string& drbname, - const std::string& drgname, - const std::string& drxname); + void load(const GFilename& drename, + const GFilename& drbname, + const GFilename& drgname, + const GFilename& drxname); void response(const std::string& rspname, const GCaldb& caldb); void obs_id(const double& id); void ontime(const double& ontime); diff --git a/inst/com/src/GCOMObservation.cpp b/inst/com/src/GCOMObservation.cpp index a74ef70..a399bc0 100644 --- a/inst/com/src/GCOMObservation.cpp +++ b/inst/com/src/GCOMObservation.cpp @@ -30,9 +30,10 @@ #endif #include #include "GObservationRegistry.hpp" +#include "GTools.hpp" #include "GException.hpp" #include "GFits.hpp" -#include "GTools.hpp" +#include "GCaldb.hpp" #include "GCOMObservation.hpp" #include "GCOMEventCube.hpp" #include "GCOMSupport.hpp" @@ -45,8 +46,8 @@ const GObservationRegistry g_obs_com_registry(&g_obs_com_seed); #define G_RESPONSE "GCOMObservation::response(GResponse&)" #define G_READ "GCOMObservation::read(GXmlElement&)" #define G_WRITE "GCOMObservation::write(GXmlElement&)" -#define G_LOAD_DRB "GCOMObservation::load_drb(std::string&)" -#define G_LOAD_DRG "GCOMObservation::load_drg(std::string&)" +#define G_LOAD_DRB "GCOMObservation::load_drb(GFilename&)" +#define G_LOAD_DRG "GCOMObservation::load_drg(GFilename&)" /* __ Macros _____________________________________________________________ */ @@ -93,10 +94,10 @@ GCOMObservation::GCOMObservation(void) : GObservation() * * Each of the four files is mandatory. ***************************************************************************/ -GCOMObservation::GCOMObservation(const std::string& drename, - const std::string& drbname, - const std::string& drgname, - const std::string& drxname) : GObservation() +GCOMObservation::GCOMObservation(const GFilename& drename, + const GFilename& drbname, + const GFilename& drgname, + const GFilename& drxname) : GObservation() { // Initialise members init_members(); @@ -374,10 +375,10 @@ void GCOMObservation::write(GXmlElement& xml) const * factors from DRG file and the exposure map from the DRX file. All files * are mandatory. ***************************************************************************/ -void GCOMObservation::load(const std::string& drename, - const std::string& drbname, - const std::string& drgname, - const std::string& drxname) +void GCOMObservation::load(const GFilename& drename, + const GFilename& drbname, + const GFilename& drgname, + const GFilename& drxname) { // Load DRE load_dre(drename); @@ -529,8 +530,10 @@ void GCOMObservation::free_members(void) * @brief Load event cube data from DRE file * * @param[in] drename DRE filename. + * + * Loads the event cube from a DRE file. ***************************************************************************/ -void GCOMObservation::load_dre(const std::string& drename) +void GCOMObservation::load_dre(const GFilename& drename) { // Delete any existing event container (do not call clear() as we do not // want to delete the response function) @@ -541,17 +544,17 @@ void GCOMObservation::load_dre(const std::string& drename) m_events = new GCOMEventCube; // Open FITS file - GFits file(drename); + GFits fits(drename); // Read event cube - m_events->read(file); + m_events->read(fits); // Read observation attributes from primary extension - GFitsHDU* hdu = file[0]; + GFitsHDU* hdu = fits[0]; read_attributes(hdu); // Close FITS file - file.close(); + fits.close(); // Store event filename m_drename = drename; @@ -572,13 +575,13 @@ void GCOMObservation::load_dre(const std::string& drename) * Load the background model from the primary image of the specified FITS * file. ***************************************************************************/ -void GCOMObservation::load_drb(const std::string& drbname) +void GCOMObservation::load_drb(const GFilename& drbname) { // Open FITS file - GFits file(drbname); + GFits fits(drbname); // Get image - const GFitsImage& image = *file.image("Primary"); + const GFitsImage& image = *fits.image("Primary"); // Load background model as sky map m_drb.read(image); @@ -587,7 +590,7 @@ void GCOMObservation::load_drb(const std::string& drbname) com_wcs_mer2car(m_drb); // Close FITS file - file.close(); + fits.close(); // Check map dimensions if (!check_map(m_drb)) { @@ -615,13 +618,13 @@ void GCOMObservation::load_drb(const std::string& drbname) * Load the geometry factors from the primary image of the specified FITS * file. ***************************************************************************/ -void GCOMObservation::load_drg(const std::string& drgname) +void GCOMObservation::load_drg(const GFilename& drgname) { // Open FITS file - GFits file(drgname); + GFits fits(drgname); // Get image - const GFitsImage& image = *file.image("Primary"); + const GFitsImage& image = *fits.image("Primary"); // Load geometry factors as sky map m_drg.read(image); @@ -630,7 +633,7 @@ void GCOMObservation::load_drg(const std::string& drgname) com_wcs_mer2car(m_drg); // Close FITS file - file.close(); + fits.close(); // Check map dimensions if (!check_map(m_drg)) { @@ -654,13 +657,13 @@ void GCOMObservation::load_drg(const std::string& drgname) * * Load the exposure map from the primary image of the specified FITS file. ***************************************************************************/ -void GCOMObservation::load_drx(const std::string& drxname) +void GCOMObservation::load_drx(const GFilename& drxname) { // Open FITS file - GFits file(drxname); + GFits fits(drxname); // Get HDU - const GFitsImage& image = *file.image("Primary"); + const GFitsImage& image = *fits.image("Primary"); // Load exposure map as sky map m_drx.read(image); @@ -669,7 +672,7 @@ void GCOMObservation::load_drx(const std::string& drxname) com_wcs_mer2car(m_drx); // Close FITS file - file.close(); + fits.close(); // Store DRX filename m_drxname = drxname; diff --git a/inst/lat/include/GLATObservation.hpp b/inst/lat/include/GLATObservation.hpp index 05899c4..9d59916 100644 --- a/inst/lat/include/GLATObservation.hpp +++ b/inst/lat/include/GLATObservation.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * GLATObservation.hpp - Fermi/LAT observation class * * ----------------------------------------------------------------------- * - * copyright (C) 2008-2014 by Juergen Knoedlseder * + * copyright (C) 2008-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -29,12 +29,14 @@ /* __ Includes ___________________________________________________________ */ #include +#include "GTime.hpp" #include "GObservation.hpp" #include "GLATResponse.hpp" #include "GLATLtCube.hpp" -#include "GTime.hpp" -#include "GModel.hpp" -#include "GModels.hpp" + +/* __ Forward declarations _______________________________________________ */ +class GResponse; +class GXmlElement; /***********************************************************************//** @@ -64,7 +66,7 @@ public: virtual std::string instrument(void) const; virtual double ontime(void) const; virtual double livetime(void) const; - virtual double deadc(const GTime& time) const; + virtual double deadc(const GTime& time = GTime()) const; virtual void read(const GXmlElement& xml); virtual void write(GXmlElement& xml) const; virtual std::string print(const GChatter& chatter = NORMAL) const; diff --git a/inst/lat/pyext/GLATObservation.i b/inst/lat/pyext/GLATObservation.i index 4fd3eb1..bba0028 100644 --- a/inst/lat/pyext/GLATObservation.i +++ b/inst/lat/pyext/GLATObservation.i @@ -1,7 +1,7 @@ /*************************************************************************** * GLATObservation.i - Fermi/LAT observation class * * ----------------------------------------------------------------------- * - * copyright (C) 2008-2014 by Juergen Knoedlseder * + * copyright (C) 2008-2016 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -50,7 +50,7 @@ public: virtual std::string instrument(void) const; virtual double ontime(void) const; virtual double livetime(void) const; - virtual double deadc(const GTime& time) const; + virtual double deadc(const GTime& time = GTime()) const; virtual void read(const GXmlElement& xml); virtual void write(GXmlElement& xml) const; diff --git a/inst/mwl/include/GMWLObservation.hpp b/inst/mwl/include/GMWLObservation.hpp index 418ae6d..759270c 100644 --- a/inst/mwl/include/GMWLObservation.hpp +++ b/inst/mwl/include/GMWLObservation.hpp @@ -28,12 +28,15 @@ #define GMWLOBSERVATION_HPP /* __ Includes ___________________________________________________________ */ +#include +#include "GTime.hpp" #include "GFilename.hpp" #include "GObservation.hpp" #include "GMWLResponse.hpp" /* __ Forward declarations _______________________________________________ */ -class GTime; +class GResponse; +class GXmlElement; /***********************************************************************//** @@ -66,7 +69,7 @@ public: virtual std::string instrument(void) const; virtual double ontime(void) const; virtual double livetime(void) const; - virtual double deadc(const GTime& time) const; + virtual double deadc(const GTime& time = GTime()) const; virtual void read(const GXmlElement& xml); virtual void write(GXmlElement& xml) const; virtual std::string print(const GChatter& chatter = NORMAL) const; diff --git a/inst/mwl/pyext/GMWLObservation.i b/inst/mwl/pyext/GMWLObservation.i index 8f0184c..cebd642 100644 --- a/inst/mwl/pyext/GMWLObservation.i +++ b/inst/mwl/pyext/GMWLObservation.i @@ -56,7 +56,7 @@ public: virtual std::string instrument(void) const; virtual double ontime(void) const; virtual double livetime(void) const; - virtual double deadc(const GTime& time) const; + virtual double deadc(const GTime& time = GTime()) const; virtual void read(const GXmlElement& xml); virtual void write(GXmlElement& xml) const; diff --git a/src/obs/GObservation.cpp b/src/obs/GObservation.cpp index d6fd374..87144ca 100644 --- a/src/obs/GObservation.cpp +++ b/src/obs/GObservation.cpp @@ -28,16 +28,22 @@ #ifdef HAVE_CONFIG_H #include #endif +#include "GTools.hpp" #include "GException.hpp" -#include "GObservation.hpp" -#include "GModelSky.hpp" -#include "GModelData.hpp" #include "GIntegral.hpp" #include "GDerivative.hpp" -#include "GTools.hpp" +#include "GVector.hpp" +#include "GMatrixSparse.hpp" +#include "GObservation.hpp" +#include "GResponse.hpp" #include "GEventCube.hpp" #include "GEventList.hpp" #include "GEventBin.hpp" +#include "GModel.hpp" +#include "GModels.hpp" +#include "GModelPar.hpp" +#include "GModelSky.hpp" +#include "GModelData.hpp" /* __ Method name definitions ____________________________________________ */ #define G_LIKELIHOOD "GObservation::likelihood(GModels&, GVector*,"\