Commit a9ac5437b135a4a0c6b3101a8b4f1c3fe27f8331

Authored by Jürgen Knödlseder
1 parent b6ac0bdb

Use empty GTime() object as default argument in GObservation::deadc().

ChangeLog
... ... @@ -3,6 +3,7 @@
3 3 * Version 1.1.0 released
4 4 =========================
5 5  
  6 + Use default GTime in GObservation::deadc() method (#1670)
6 7 The GApplicationPar::filename() methods now take and return GFilename (#1671)
7 8 Add GFilename methods and remove equivalents from GTools (#1666)
8 9 Use column names for CTA response table access (#1656)
... ...
... ... @@ -125,6 +125,11 @@ A non-const GObservation::events() method has been added to allow for
125 125 the manipulation of events within an observation without the need to
126 126 create a local copy.
127 127  
  128 +The argument of GObservation::deadc(GTime) now defaults to GTime() so
  129 +that no argument is needed when calling the method. This reflects the
  130 +fact that the deadtime correction is often computed as an average value
  131 +over the observation, and does in fact not depend on time (#1670).
  132 +
128 133  
129 134 11. Optimization module
130 135 -----------------------
... ...
include/GObservation.hpp
... ... @@ -31,13 +31,17 @@
31 31 #include <string>
32 32 #include "GBase.hpp"
33 33 #include "GEvents.hpp"
34   -#include "GResponse.hpp"
35   -#include "GModels.hpp"
36 34 #include "GTime.hpp"
37   -#include "GEnergy.hpp"
38 35 #include "GFunction.hpp"
39   -#include "GVector.hpp"
40   -#include "GMatrixSparse.hpp"
  36 +
  37 +/* __ Forward declarations _______________________________________________ */
  38 +class GVector;
  39 +class GMatrixSparse;
  40 +class GModel;
  41 +class GModels;
  42 +class GModelPar;
  43 +class GResponse;
  44 +class GXmlElement;
41 45  
42 46  
43 47 /***********************************************************************//**
... ... @@ -82,7 +86,7 @@ public:
82 86 virtual std::string instrument(void) const = 0;
83 87 virtual double ontime(void) const = 0;
84 88 virtual double livetime(void) const = 0;
85   - virtual double deadc(const GTime& time) const = 0;
  89 + virtual double deadc(const GTime& time = GTime()) const = 0;
86 90 virtual void read(const GXmlElement& xml) = 0;
87 91 virtual void write(GXmlElement& xml) const = 0;
88 92 virtual std::string print(const GChatter& chatter = NORMAL) const = 0;
... ...
inst/com/include/GCOMObservation.hpp
... ... @@ -28,12 +28,20 @@
28 28 #define GCOMOBSERVATION_HPP
29 29  
30 30 /* __ Includes ___________________________________________________________ */
  31 +#include <string>
31 32 #include "GObservation.hpp"
32 33 #include "GTime.hpp"
33   -#include "GModel.hpp"
  34 +#include "GFilename.hpp"
  35 +#include "GSkyDir.hpp"
34 36 #include "GSkyMap.hpp"
35 37 #include "GCOMResponse.hpp"
36   -#include "GCaldb.hpp"
  38 +//#include "GCaldb.hpp"
  39 +
  40 +/* __ Forward declarations _______________________________________________ */
  41 +class GCaldb;
  42 +class GResponse;
  43 +class GXmlElement;
  44 +class GFitsHDU;
37 45  
38 46  
39 47 /***********************************************************************//**
... ... @@ -52,10 +60,10 @@ class GCOMObservation : public GObservation {
52 60 public:
53 61 // Constructors and destructors
54 62 GCOMObservation(void);
55   - GCOMObservation(const std::string& drename,
56   - const std::string& drbname,
57   - const std::string& drgname,
58   - const std::string& drxname);
  63 + GCOMObservation(const GFilename& drename,
  64 + const GFilename& drbname,
  65 + const GFilename& drgname,
  66 + const GFilename& drxname);
59 67 GCOMObservation(const GCOMObservation& obs);
60 68 virtual ~GCOMObservation(void);
61 69  
... ... @@ -71,16 +79,16 @@ public:
71 79 virtual std::string instrument(void) const;
72 80 virtual double ontime(void) const;
73 81 virtual double livetime(void) const;
74   - virtual double deadc(const GTime& time) const;
  82 + virtual double deadc(const GTime& time = GTime()) const;
75 83 virtual void read(const GXmlElement& xml);
76 84 virtual void write(GXmlElement& xml) const;
77 85 virtual std::string print(const GChatter& chatter = NORMAL) const;
78 86  
79 87 // Other methods
80   - void load(const std::string& drename,
81   - const std::string& drbname,
82   - const std::string& drgname,
83   - const std::string& drxname);
  88 + void load(const GFilename& drename,
  89 + const GFilename& drbname,
  90 + const GFilename& drgname,
  91 + const GFilename& drxname);
84 92 void response(const std::string& rspname, const GCaldb& caldb);
85 93 void obs_id(const double& id);
86 94 void ontime(const double& ontime);
... ... @@ -98,20 +106,20 @@ protected:
98 106 void init_members(void);
99 107 void copy_members(const GCOMObservation& obs);
100 108 void free_members(void);
101   - void load_dre(const std::string& drename);
102   - void load_drb(const std::string& drbname);
103   - void load_drg(const std::string& drgname);
104   - void load_drx(const std::string& drxname);
  109 + void load_dre(const GFilename& drename);
  110 + void load_drb(const GFilename& drbname);
  111 + void load_drg(const GFilename& drgname);
  112 + void load_drx(const GFilename& drxname);
105 113 bool check_map(const GSkyMap& map) const;
106 114 void read_attributes(const GFitsHDU* hdu);
107 115 void write_attributes(GFitsHDU* hdu) const;
108 116  
109 117 // Protected members
110 118 std::string m_instrument; //!< Instrument name
111   - std::string m_drename; //!< DRE filename
112   - std::string m_drbname; //!< DRB filename
113   - std::string m_drgname; //!< DRG filename
114   - std::string m_drxname; //!< DRX filename
  119 + GFilename m_drename; //!< DRE filename
  120 + GFilename m_drbname; //!< DRB filename
  121 + GFilename m_drgname; //!< DRG filename
  122 + GFilename m_drxname; //!< DRX filename
115 123 GSkyMap m_drb; //!< Background model
116 124 GSkyMap m_drg; //!< Geometry factors
117 125 GSkyMap m_drx; //!< Exposure map
... ...
inst/com/pyext/GCOMObservation.i
1 1 /***************************************************************************
2 2 * GCOMObservation.i - COMPTEL observation class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2012-2015 by Juergen Knoedlseder *
  4 + * copyright (C) 2012-2016 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -38,10 +38,10 @@ class GCOMObservation : public GObservation {
38 38 public:
39 39 // Constructors and destructors
40 40 GCOMObservation(void);
41   - GCOMObservation(const std::string& drename,
42   - const std::string& drbname,
43   - const std::string& drgname,
44   - const std::string& drxname);
  41 + GCOMObservation(const GFilename& drename,
  42 + const GFilename& drbname,
  43 + const GFilename& drgname,
  44 + const GFilename& drxname);
45 45 GCOMObservation(const GCOMObservation& obs);
46 46 virtual ~GCOMObservation(void);
47 47  
... ... @@ -54,15 +54,15 @@ public:
54 54 virtual std::string instrument(void) const;
55 55 virtual double ontime(void) const;
56 56 virtual double livetime(void) const;
57   - virtual double deadc(const GTime& time) const;
  57 + virtual double deadc(const GTime& time = GTime()) const;
58 58 virtual void read(const GXmlElement& xml);
59 59 virtual void write(GXmlElement& xml) const;
60 60  
61 61 // Other methods
62   - void load(const std::string& drename,
63   - const std::string& drbname,
64   - const std::string& drgname,
65   - const std::string& drxname);
  62 + void load(const GFilename& drename,
  63 + const GFilename& drbname,
  64 + const GFilename& drgname,
  65 + const GFilename& drxname);
66 66 void response(const std::string& rspname, const GCaldb& caldb);
67 67 void obs_id(const double& id);
68 68 void ontime(const double& ontime);
... ...
inst/com/src/GCOMObservation.cpp
... ... @@ -30,9 +30,10 @@
30 30 #endif
31 31 #include <typeinfo>
32 32 #include "GObservationRegistry.hpp"
  33 +#include "GTools.hpp"
33 34 #include "GException.hpp"
34 35 #include "GFits.hpp"
35   -#include "GTools.hpp"
  36 +#include "GCaldb.hpp"
36 37 #include "GCOMObservation.hpp"
37 38 #include "GCOMEventCube.hpp"
38 39 #include "GCOMSupport.hpp"
... ... @@ -45,8 +46,8 @@ const GObservationRegistry g_obs_com_registry(&amp;g_obs_com_seed);
45 46 #define G_RESPONSE "GCOMObservation::response(GResponse&)"
46 47 #define G_READ "GCOMObservation::read(GXmlElement&)"
47 48 #define G_WRITE "GCOMObservation::write(GXmlElement&)"
48   -#define G_LOAD_DRB "GCOMObservation::load_drb(std::string&)"
49   -#define G_LOAD_DRG "GCOMObservation::load_drg(std::string&)"
  49 +#define G_LOAD_DRB "GCOMObservation::load_drb(GFilename&)"
  50 +#define G_LOAD_DRG "GCOMObservation::load_drg(GFilename&)"
50 51  
51 52 /* __ Macros _____________________________________________________________ */
52 53  
... ... @@ -93,10 +94,10 @@ GCOMObservation::GCOMObservation(void) : GObservation()
93 94 *
94 95 * Each of the four files is mandatory.
95 96 ***************************************************************************/
96   -GCOMObservation::GCOMObservation(const std::string& drename,
97   - const std::string& drbname,
98   - const std::string& drgname,
99   - const std::string& drxname) : GObservation()
  97 +GCOMObservation::GCOMObservation(const GFilename& drename,
  98 + const GFilename& drbname,
  99 + const GFilename& drgname,
  100 + const GFilename& drxname) : GObservation()
100 101 {
101 102 // Initialise members
102 103 init_members();
... ... @@ -374,10 +375,10 @@ void GCOMObservation::write(GXmlElement&amp; xml) const
374 375 * factors from DRG file and the exposure map from the DRX file. All files
375 376 * are mandatory.
376 377 ***************************************************************************/
377   -void GCOMObservation::load(const std::string& drename,
378   - const std::string& drbname,
379   - const std::string& drgname,
380   - const std::string& drxname)
  378 +void GCOMObservation::load(const GFilename& drename,
  379 + const GFilename& drbname,
  380 + const GFilename& drgname,
  381 + const GFilename& drxname)
381 382 {
382 383 // Load DRE
383 384 load_dre(drename);
... ... @@ -529,8 +530,10 @@ void GCOMObservation::free_members(void)
529 530 * @brief Load event cube data from DRE file
530 531 *
531 532 * @param[in] drename DRE filename.
  533 + *
  534 + * Loads the event cube from a DRE file.
532 535 ***************************************************************************/
533   -void GCOMObservation::load_dre(const std::string& drename)
  536 +void GCOMObservation::load_dre(const GFilename& drename)
534 537 {
535 538 // Delete any existing event container (do not call clear() as we do not
536 539 // want to delete the response function)
... ... @@ -541,17 +544,17 @@ void GCOMObservation::load_dre(const std::string&amp; drename)
541 544 m_events = new GCOMEventCube;
542 545  
543 546 // Open FITS file
544   - GFits file(drename);
  547 + GFits fits(drename);
545 548  
546 549 // Read event cube
547   - m_events->read(file);
  550 + m_events->read(fits);
548 551  
549 552 // Read observation attributes from primary extension
550   - GFitsHDU* hdu = file[0];
  553 + GFitsHDU* hdu = fits[0];
551 554 read_attributes(hdu);
552 555  
553 556 // Close FITS file
554   - file.close();
  557 + fits.close();
555 558  
556 559 // Store event filename
557 560 m_drename = drename;
... ... @@ -572,13 +575,13 @@ void GCOMObservation::load_dre(const std::string&amp; drename)
572 575 * Load the background model from the primary image of the specified FITS
573 576 * file.
574 577 ***************************************************************************/
575   -void GCOMObservation::load_drb(const std::string& drbname)
  578 +void GCOMObservation::load_drb(const GFilename& drbname)
576 579 {
577 580 // Open FITS file
578   - GFits file(drbname);
  581 + GFits fits(drbname);
579 582  
580 583 // Get image
581   - const GFitsImage& image = *file.image("Primary");
  584 + const GFitsImage& image = *fits.image("Primary");
582 585  
583 586 // Load background model as sky map
584 587 m_drb.read(image);
... ... @@ -587,7 +590,7 @@ void GCOMObservation::load_drb(const std::string&amp; drbname)
587 590 com_wcs_mer2car(m_drb);
588 591  
589 592 // Close FITS file
590   - file.close();
  593 + fits.close();
591 594  
592 595 // Check map dimensions
593 596 if (!check_map(m_drb)) {
... ... @@ -615,13 +618,13 @@ void GCOMObservation::load_drb(const std::string&amp; drbname)
615 618 * Load the geometry factors from the primary image of the specified FITS
616 619 * file.
617 620 ***************************************************************************/
618   -void GCOMObservation::load_drg(const std::string& drgname)
  621 +void GCOMObservation::load_drg(const GFilename& drgname)
619 622 {
620 623 // Open FITS file
621   - GFits file(drgname);
  624 + GFits fits(drgname);
622 625  
623 626 // Get image
624   - const GFitsImage& image = *file.image("Primary");
  627 + const GFitsImage& image = *fits.image("Primary");
625 628  
626 629 // Load geometry factors as sky map
627 630 m_drg.read(image);
... ... @@ -630,7 +633,7 @@ void GCOMObservation::load_drg(const std::string&amp; drgname)
630 633 com_wcs_mer2car(m_drg);
631 634  
632 635 // Close FITS file
633   - file.close();
  636 + fits.close();
634 637  
635 638 // Check map dimensions
636 639 if (!check_map(m_drg)) {
... ... @@ -654,13 +657,13 @@ void GCOMObservation::load_drg(const std::string&amp; drgname)
654 657 *
655 658 * Load the exposure map from the primary image of the specified FITS file.
656 659 ***************************************************************************/
657   -void GCOMObservation::load_drx(const std::string& drxname)
  660 +void GCOMObservation::load_drx(const GFilename& drxname)
658 661 {
659 662 // Open FITS file
660   - GFits file(drxname);
  663 + GFits fits(drxname);
661 664  
662 665 // Get HDU
663   - const GFitsImage& image = *file.image("Primary");
  666 + const GFitsImage& image = *fits.image("Primary");
664 667  
665 668 // Load exposure map as sky map
666 669 m_drx.read(image);
... ... @@ -669,7 +672,7 @@ void GCOMObservation::load_drx(const std::string&amp; drxname)
669 672 com_wcs_mer2car(m_drx);
670 673  
671 674 // Close FITS file
672   - file.close();
  675 + fits.close();
673 676  
674 677 // Store DRX filename
675 678 m_drxname = drxname;
... ...
inst/lat/include/GLATObservation.hpp
1 1 /***************************************************************************
2 2 * GLATObservation.hpp - Fermi/LAT observation class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2008-2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2008-2016 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -29,12 +29,14 @@
29 29  
30 30 /* __ Includes ___________________________________________________________ */
31 31 #include <string>
  32 +#include "GTime.hpp"
32 33 #include "GObservation.hpp"
33 34 #include "GLATResponse.hpp"
34 35 #include "GLATLtCube.hpp"
35   -#include "GTime.hpp"
36   -#include "GModel.hpp"
37   -#include "GModels.hpp"
  36 +
  37 +/* __ Forward declarations _______________________________________________ */
  38 +class GResponse;
  39 +class GXmlElement;
38 40  
39 41  
40 42 /***********************************************************************//**
... ... @@ -64,7 +66,7 @@ public:
64 66 virtual std::string instrument(void) const;
65 67 virtual double ontime(void) const;
66 68 virtual double livetime(void) const;
67   - virtual double deadc(const GTime& time) const;
  69 + virtual double deadc(const GTime& time = GTime()) const;
68 70 virtual void read(const GXmlElement& xml);
69 71 virtual void write(GXmlElement& xml) const;
70 72 virtual std::string print(const GChatter& chatter = NORMAL) const;
... ...
inst/lat/pyext/GLATObservation.i
1 1 /***************************************************************************
2 2 * GLATObservation.i - Fermi/LAT observation class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2008-2014 by Juergen Knoedlseder *
  4 + * copyright (C) 2008-2016 by Juergen Knoedlseder *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -50,7 +50,7 @@ public:
50 50 virtual std::string instrument(void) const;
51 51 virtual double ontime(void) const;
52 52 virtual double livetime(void) const;
53   - virtual double deadc(const GTime& time) const;
  53 + virtual double deadc(const GTime& time = GTime()) const;
54 54 virtual void read(const GXmlElement& xml);
55 55 virtual void write(GXmlElement& xml) const;
56 56  
... ...
inst/mwl/include/GMWLObservation.hpp
... ... @@ -28,12 +28,15 @@
28 28 #define GMWLOBSERVATION_HPP
29 29  
30 30 /* __ Includes ___________________________________________________________ */
  31 +#include <string>
  32 +#include "GTime.hpp"
31 33 #include "GFilename.hpp"
32 34 #include "GObservation.hpp"
33 35 #include "GMWLResponse.hpp"
34 36  
35 37 /* __ Forward declarations _______________________________________________ */
36   -class GTime;
  38 +class GResponse;
  39 +class GXmlElement;
37 40  
38 41  
39 42 /***********************************************************************//**
... ... @@ -66,7 +69,7 @@ public:
66 69 virtual std::string instrument(void) const;
67 70 virtual double ontime(void) const;
68 71 virtual double livetime(void) const;
69   - virtual double deadc(const GTime& time) const;
  72 + virtual double deadc(const GTime& time = GTime()) const;
70 73 virtual void read(const GXmlElement& xml);
71 74 virtual void write(GXmlElement& xml) const;
72 75 virtual std::string print(const GChatter& chatter = NORMAL) const;
... ...
inst/mwl/pyext/GMWLObservation.i
... ... @@ -56,7 +56,7 @@ public:
56 56 virtual std::string instrument(void) const;
57 57 virtual double ontime(void) const;
58 58 virtual double livetime(void) const;
59   - virtual double deadc(const GTime& time) const;
  59 + virtual double deadc(const GTime& time = GTime()) const;
60 60 virtual void read(const GXmlElement& xml);
61 61 virtual void write(GXmlElement& xml) const;
62 62  
... ...
src/obs/GObservation.cpp
... ... @@ -28,16 +28,22 @@
28 28 #ifdef HAVE_CONFIG_H
29 29 #include <config.h>
30 30 #endif
  31 +#include "GTools.hpp"
31 32 #include "GException.hpp"
32   -#include "GObservation.hpp"
33   -#include "GModelSky.hpp"
34   -#include "GModelData.hpp"
35 33 #include "GIntegral.hpp"
36 34 #include "GDerivative.hpp"
37   -#include "GTools.hpp"
  35 +#include "GVector.hpp"
  36 +#include "GMatrixSparse.hpp"
  37 +#include "GObservation.hpp"
  38 +#include "GResponse.hpp"
38 39 #include "GEventCube.hpp"
39 40 #include "GEventList.hpp"
40 41 #include "GEventBin.hpp"
  42 +#include "GModel.hpp"
  43 +#include "GModels.hpp"
  44 +#include "GModelPar.hpp"
  45 +#include "GModelSky.hpp"
  46 +#include "GModelData.hpp"
41 47  
42 48 /* __ Method name definitions ____________________________________________ */
43 49 #define G_LIKELIHOOD "GObservation::likelihood(GModels&, GVector*,"\
... ...