Commit edd8ccb76fcd8566dde29af1b1f1061b7d9a4360
1 parent
376dca09
Add ctools::time_reference constant and remove ctools::time_reference() method (#2295)
Showing
13 changed files
with
55 additions
and
49 deletions
ChangeLog
| ... | ... | @@ -3,6 +3,7 @@ |
| 3 | 3 | * Version 1.5.0 released |
| 4 | 4 | ======================== |
| 5 | 5 | |
| 6 | + Add ctools::time_reference constant and remove ctools::time_reference() method (#2295) | |
| 6 | 7 | Correctly strip .gz suffix from output filenames (#2287) |
| 7 | 8 | Support On/Off analysis in cslightcrv and csphasecrv (#2273) |
| 8 | 9 | Add tutorial for classical analysis (#2267) | ... | ... |
NEWS
cscripts/cslightcrv.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # Generates a lightcurve. |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2014-2017 Michael Mayer | |
| 5 | +# Copyright (C) 2014-2018 Michael Mayer | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -174,8 +174,8 @@ class cslightcrv(ctools.csobservation): |
| 174 | 174 | elif algorithm == 'LIN': |
| 175 | 175 | |
| 176 | 176 | # Get start and stop time and number of time bins |
| 177 | - time_min = self['tmin'].time(self._time_reference()) | |
| 178 | - time_max = self['tmax'].time(self._time_reference()) | |
| 177 | + time_min = self['tmin'].time(ctools.time_reference) | |
| 178 | + time_max = self['tmax'].time(ctools.time_reference) | |
| 179 | 179 | nbins = self['tbins'].integer() |
| 180 | 180 | |
| 181 | 181 | # Compute time step in seconds and setup the GTIs |
| ... | ... | @@ -386,8 +386,8 @@ class cslightcrv(ctools.csobservation): |
| 386 | 386 | select = ctools.ctselect(self.obs()) |
| 387 | 387 | select['emin'] = self['emin'].real() |
| 388 | 388 | select['emax'] = self['emax'].real() |
| 389 | - select['tmin'] = tmin.convert(self._time_reference()) | |
| 390 | - select['tmax'] = tmax.convert(self._time_reference()) | |
| 389 | + select['tmin'] = tmin.convert(ctools.time_reference) | |
| 390 | + select['tmax'] = tmax.convert(ctools.time_reference) | |
| 391 | 391 | select['rad'] = 'UNDEFINED' |
| 392 | 392 | select['ra'] = 'UNDEFINED' |
| 393 | 393 | select['dec'] = 'UNDEFINED' |
| ... | ... | @@ -445,8 +445,8 @@ class cslightcrv(ctools.csobservation): |
| 445 | 445 | select = ctools.ctselect(self.obs()) |
| 446 | 446 | select['emin'] = self['emin'].real() |
| 447 | 447 | select['emax'] = self['emax'].real() |
| 448 | - select['tmin'] = tmin.convert(self._time_reference()) | |
| 449 | - select['tmax'] = tmax.convert(self._time_reference()) | |
| 448 | + select['tmin'] = tmin.convert(ctools.time_reference) | |
| 449 | + select['tmax'] = tmax.convert(ctools.time_reference) | |
| 450 | 450 | select['rad'] = 'UNDEFINED' |
| 451 | 451 | select['ra'] = 'UNDEFINED' |
| 452 | 452 | select['dec'] = 'UNDEFINED' | ... | ... |
cscripts/csobsdef.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # Generation of an observation definition file |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2015-2017 Juergen Knoedlseder | |
| 5 | +# Copyright (C) 2015-2018 Juergen Knoedlseder | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -274,9 +274,9 @@ class csobsdef(ctools.cscript): |
| 274 | 274 | duration = self['duration'].real() |
| 275 | 275 | tmin = self._tmin |
| 276 | 276 | tmax = self._tmin + duration |
| 277 | - gti = gammalib.GGti(self._time_reference()) | |
| 278 | - tstart = gammalib.GTime(tmin, self._time_reference()) | |
| 279 | - tstop = gammalib.GTime(tmax, self._time_reference()) | |
| 277 | + gti = gammalib.GGti(ctools.time_reference) | |
| 278 | + tstart = gammalib.GTime(tmin, ctools.time_reference) | |
| 279 | + tstop = gammalib.GTime(tmax, ctools.time_reference) | |
| 280 | 280 | self._tmin = tmax |
| 281 | 281 | gti.append(tstart, tstop) |
| 282 | 282 | obs.ontime(gti.ontime()) | ... | ... |
cscripts/csobsinfo.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # Dump information about observation into log file |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2015-2017 Michael Mayer | |
| 5 | +# Copyright (C) 2015-2018 Michael Mayer | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -291,8 +291,8 @@ class csobsinfo(ctools.csobservation): |
| 291 | 291 | # Log time range |
| 292 | 292 | mjd = '%.3f - %.3f' % (self._gti.tstart().mjd(), self._gti.tstop().mjd()) |
| 293 | 293 | utc = '%s - %s' % (self._gti.tstart().utc(), self._gti.tstop().utc()) |
| 294 | - met = '%.3f - %.3f' % (self._gti.tstart().convert(self._time_reference()), | |
| 295 | - self._gti.tstop().convert(self._time_reference())) | |
| 294 | + met = '%.3f - %.3f' % (self._gti.tstart().convert(ctools.time_reference), | |
| 295 | + self._gti.tstop().convert(ctools.time_reference)) | |
| 296 | 296 | self._log_header3(gammalib.NORMAL, 'Time range') |
| 297 | 297 | self._log_value(gammalib.NORMAL, 'MJD (days)', mjd) |
| 298 | 298 | self._log_value(gammalib.NORMAL, 'UTC', utc) | ... | ... |
cscripts/csviscube.py
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # ========================================================================== |
| 3 | 3 | # Compute a visibility cube |
| 4 | 4 | # |
| 5 | -# Copyright (C) 2016-2017 Juergen Knoedlseder | |
| 5 | +# Copyright (C) 2016-2018 Juergen Knoedlseder | |
| 6 | 6 | # |
| 7 | 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | 8 | # it under the terms of the GNU General Public License as published by |
| ... | ... | @@ -260,8 +260,8 @@ class csviscube(ctools.cscript): |
| 260 | 260 | #geolon = self['geolon'].real() |
| 261 | 261 | |
| 262 | 262 | # Get time interval |
| 263 | - tmin = self['tmin'].time(self._time_reference()) | |
| 264 | - tmax = self['tmax'].time(self._time_reference()) | |
| 263 | + tmin = self['tmin'].time(ctools.time_reference) | |
| 264 | + tmax = self['tmax'].time(ctools.time_reference) | |
| 265 | 265 | |
| 266 | 266 | # Initialise hour angle list |
| 267 | 267 | hour_angles = [] | ... | ... |
cscripts/obsutils.py
| ... | ... | @@ -280,8 +280,9 @@ def set_obs(pntdir, tstart=0.0, duration=1800.0, deadc=0.98, \ |
| 280 | 280 | roi.radius(rad) |
| 281 | 281 | |
| 282 | 282 | # Set GTI |
| 283 | - gti = gammalib.GGti() | |
| 284 | - gti.append(gammalib.GTime(tstart), gammalib.GTime(tstart+duration)) | |
| 283 | + gti = gammalib.GGti(ctools.time_reference) | |
| 284 | + gti.append(gammalib.GTime(tstart, ctools.time_reference), | |
| 285 | + gammalib.GTime(tstart+duration, ctools.time_reference)) | |
| 285 | 286 | |
| 286 | 287 | # Set energy boundaries |
| 287 | 288 | ebounds = gammalib.GEbounds(gammalib.GEnergy(emin, 'TeV'), | ... | ... |
doc/source/admin/release_history/1.5.rst
| ... | ... | @@ -26,6 +26,9 @@ Bug fixes |
| 26 | 26 | Improvements |
| 27 | 27 | ------------ |
| 28 | 28 | |
| 29 | +* [`2295 <https://cta-redmine.irap.omp.eu/issues/2295>`_] - | |
| 30 | + Add ``ctools::time_reference`` constant and remove ``ctools::time_reference()`` | |
| 31 | + method | |
| 29 | 32 | * [`2273 <https://cta-redmine.irap.omp.eu/issues/2273>`_] - |
| 30 | 33 | Support On/Off analysis in :ref:`cslightcrv` and :ref:`csphasecrv` |
| 31 | 34 | * [`2267 <https://cta-redmine.irap.omp.eu/issues/2267>`_] - | ... | ... |
pyext/ctool.i
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * ctool - ctool base class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2014-2017 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2014-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -28,7 +28,6 @@ |
| 28 | 28 | #define SWIG |
| 29 | 29 | #include "ctool.hpp" |
| 30 | 30 | |
| 31 | - | |
| 32 | 31 | /***********************************************************************//** |
| 33 | 32 | * @class cscript |
| 34 | 33 | * |
| ... | ... | @@ -57,6 +56,12 @@ public: |
| 57 | 56 | // arguments to GApplication constructor |
| 58 | 57 | %include "argcargv.i" |
| 59 | 58 | |
| 59 | +/* __ Constants __________________________________________________________ */ | |
| 60 | +namespace ctools { | |
| 61 | + const GTimeReference time_reference = | |
| 62 | + GTimeReference(G_CTA_MJDREF, "s", "TT", "LOCAL"); | |
| 63 | +} | |
| 64 | + | |
| 60 | 65 | |
| 61 | 66 | /***********************************************************************//** |
| 62 | 67 | * @class ctool |
| ... | ... | @@ -83,7 +88,6 @@ public: |
| 83 | 88 | |
| 84 | 89 | // Make methods private in Python by prepending an underscore |
| 85 | 90 | %rename(_read_ahead) read_ahead; |
| 86 | - %rename(_time_reference) time_reference; | |
| 87 | 91 | %rename(_get_observations) get_observations; |
| 88 | 92 | %rename(_setup_observations) setup_observations; |
| 89 | 93 | %rename(_setup_models) setup_models; |
| ... | ... | @@ -119,7 +123,6 @@ public: |
| 119 | 123 | |
| 120 | 124 | // Protected methods |
| 121 | 125 | const bool& read_ahead(void) const; |
| 122 | - const GTimeReference& time_reference(void) const; | |
| 123 | 126 | |
| 124 | 127 | // Protected high-level setup methods |
| 125 | 128 | void setup_observations(GObservations& obs, const bool& response = true, | ... | ... |
src/ctbin/ctbin.cpp
src/ctobssim/ctobssim.cpp
| ... | ... | @@ -790,9 +790,9 @@ void ctobssim::simulate_source(GCTAObservation* obs, |
| 790 | 790 | wrklog->indent(indent); |
| 791 | 791 | } |
| 792 | 792 | *wrklog << gammalib::parformat("Time interval", indent); |
| 793 | - *wrklog << tmin.convert(m_cta_ref); | |
| 793 | + *wrklog << tmin.convert(ctools::time_reference); | |
| 794 | 794 | *wrklog << " - "; |
| 795 | - *wrklog << tmax.convert(m_cta_ref); | |
| 795 | + *wrklog << tmax.convert(ctools::time_reference); | |
| 796 | 796 | *wrklog << " s" << std::endl; |
| 797 | 797 | } |
| 798 | 798 | |
| ... | ... | @@ -1057,8 +1057,8 @@ void ctobssim::simulate_interval(GCTAObservation* obs, |
| 1057 | 1057 | wrklog->indent(indent); |
| 1058 | 1058 | } |
| 1059 | 1059 | *wrklog << gammalib::parformat("Time slice", indent); |
| 1060 | - *wrklog << tstart.convert(m_cta_ref) << " - "; | |
| 1061 | - *wrklog << tstop.convert(m_cta_ref) << " s"; | |
| 1060 | + *wrklog << tstart.convert(ctools::time_reference) << " - "; | |
| 1061 | + *wrklog << tstop.convert(ctools::time_reference) << " s"; | |
| 1062 | 1062 | if (model->name().length() > 0) { |
| 1063 | 1063 | *wrklog << " [" << model->name() << "]"; |
| 1064 | 1064 | } | ... | ... |
src/support/ctool.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * ctool - ctool base class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2014-2017 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2014-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -253,7 +253,7 @@ void ctool::init_members(void) |
| 253 | 253 | // Set CTA time reference. G_CTA_MJDREF is the CTA reference MJD, |
| 254 | 254 | // which is defined in GCTALib.hpp. This is somehow a kluge. We need |
| 255 | 255 | // a better mechanism to implement the CTA reference MJD. |
| 256 | - m_cta_ref.set(G_CTA_MJDREF, "s", "TT", "LOCAL"); | |
| 256 | + //m_cta_ref.set(G_CTA_MJDREF, "s", "TT", "LOCAL"); | |
| 257 | 257 | |
| 258 | 258 | // Set logger properties |
| 259 | 259 | log.date(true); |
| ... | ... | @@ -276,7 +276,7 @@ void ctool::copy_members(const ctool& app) |
| 276 | 276 | // Copy members |
| 277 | 277 | m_read_ahead = app.m_read_ahead; |
| 278 | 278 | m_use_xml = app.m_use_xml; |
| 279 | - m_cta_ref = app.m_cta_ref; | |
| 279 | + //m_cta_ref = app.m_cta_ref; | |
| 280 | 280 | |
| 281 | 281 | // Return |
| 282 | 282 | return; |
| ... | ... | @@ -1059,14 +1059,14 @@ GEbounds ctool::get_ebounds(void) |
| 1059 | 1059 | GGti ctool::get_gti(void) |
| 1060 | 1060 | { |
| 1061 | 1061 | // Initialise Good Time Intervals with CTA reference time |
| 1062 | - GGti gti(m_cta_ref); | |
| 1062 | + GGti gti(ctools::time_reference); | |
| 1063 | 1063 | |
| 1064 | 1064 | // Continue only if "tmin" has a valid time value |
| 1065 | 1065 | if ((*this)["tmin"].is_valid() && (*this)["tmax"].is_valid()) { |
| 1066 | 1066 | |
| 1067 | 1067 | // Get minimum and maximum time for CTA time reference |
| 1068 | - GTime tmin = (*this)["tmin"].time(m_cta_ref); | |
| 1069 | - GTime tmax = (*this)["tmax"].time(m_cta_ref); | |
| 1068 | + GTime tmin = (*this)["tmin"].time(ctools::time_reference); | |
| 1069 | + GTime tmax = (*this)["tmax"].time(ctools::time_reference); | |
| 1070 | 1070 | |
| 1071 | 1071 | // Append GTI |
| 1072 | 1072 | gti.append(tmin, tmax); | ... | ... |
src/support/ctool.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * ctool - ctool base class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2014-2017 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2014-2018 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -33,6 +33,12 @@ |
| 33 | 33 | |
| 34 | 34 | /* __Definitions _________________________________________________________ */ |
| 35 | 35 | |
| 36 | +/* __ Constants __________________________________________________________ */ | |
| 37 | +namespace ctools { | |
| 38 | + const GTimeReference time_reference = | |
| 39 | + GTimeReference(G_CTA_MJDREF, "s", "TT", "LOCAL"); | |
| 40 | +} | |
| 41 | + | |
| 36 | 42 | |
| 37 | 43 | /***********************************************************************//** |
| 38 | 44 | * @class ctool |
| ... | ... | @@ -75,7 +81,6 @@ protected: |
| 75 | 81 | void copy_members(const ctool& app); |
| 76 | 82 | void free_members(void); |
| 77 | 83 | const bool& read_ahead(void) const; |
| 78 | - const GTimeReference& time_reference(void) const; | |
| 79 | 84 | |
| 80 | 85 | // Protected high-level setup methods |
| 81 | 86 | void setup_observations(GObservations& obs, const bool& response = true, |
| ... | ... | @@ -151,7 +156,6 @@ protected: |
| 151 | 156 | |
| 152 | 157 | // Protected members |
| 153 | 158 | bool m_use_xml; //!< Use XML file instead of FITS file for observations |
| 154 | - GTimeReference m_cta_ref; //!< CTA time reference | |
| 155 | 159 | }; |
| 156 | 160 | |
| 157 | 161 | |
| ... | ... | @@ -173,18 +177,6 @@ const bool& ctool::read_ahead(void) const |
| 173 | 177 | |
| 174 | 178 | |
| 175 | 179 | /***********************************************************************//** |
| 176 | - * @brief Return time reference | |
| 177 | - * | |
| 178 | - * @return Reference to time reference | |
| 179 | - ***************************************************************************/ | |
| 180 | -inline | |
| 181 | -const GTimeReference& ctool::time_reference(void) const | |
| 182 | -{ | |
| 183 | - return (m_cta_ref); | |
| 184 | -} | |
| 185 | - | |
| 186 | - | |
| 187 | -/***********************************************************************//** | |
| 188 | 180 | * @brief Check of a filename is valid |
| 189 | 181 | * |
| 190 | 182 | * @return True if filename is valid | ... | ... |