Commit a62402b6181b0602898e7f31f831824a2fa191d1

Authored by Jürgen Knödlseder
1 parent 2624e245

Revise handling of MET time references.

Remove ctools::time_reference constant and handle the time reference for MET either by using the time reference from the input observation, or by adding a hidden "mjdref" parameter. The following tools transparently use the time reference of the input observation:
* ctselect (apply time reference of each input observation)
* ctbin (apply time reference of first input observation)
* csobsselect (apply time reference of each input observation)

A "mjdref" parameter was added the following tools:
* ctobssim
* cslightcrv
* cspull
* csviscube
* csobsdef
ChangeLog
1 -2018-06-12 1 +2018-06-13
2 2
3 * Version 1.6.0 released 3 * Version 1.6.0 released
4 ======================== 4 ========================
@@ -12,6 +12,8 @@ @@ -12,6 +12,8 @@
12 Allow specifying of input sky map in ctskymap (#2311) 12 Allow specifying of input sky map in ctskymap (#2311)
13 Add ras() and decs() methods to csobsinfo (#2313) 13 Add ras() and decs() methods to csobsinfo (#2313)
14 Accelerate IRF and RING background methods in ctskymap (#2309) 14 Accelerate IRF and RING background methods in ctskymap (#2309)
  15 + Define MET with respect to the observation time reference or "mjdref"
  16 + parameter (#2054)
15 17
16 18
17 2018-04-26 19 2018-04-26
1 New Features and Important Changes in ctools 1.6.0 1 New Features and Important Changes in ctools 1.6.0
2 2
3 -12 June 2018 3 +13 June 2018
4 4
5 5
6 Introduction 6 Introduction
@@ -26,13 +26,25 @@ None @@ -26,13 +26,25 @@ None
26 26
27 Base classes 27 Base classes
28 ------------ 28 ------------
  29 +The ctool::time_reference constant was removed since it is not required
  30 +anymore. The time reference is now transparently handled by the tools, and
  31 +if there is a choice, a "mjdref" parameter was added to the tools (#2054).
  32 +
  33 +The ctool::create_cta_obs() method now queries the optional "mjdref" parameter
  34 +so that a MJD reference time can be specified by the tool. This functionality
  35 +is now used by ctobssim (#2054).
  36 +
  37 +The ctools::get_gti() method now takes GTimeReference as argument to enable
  38 +tools to retrieve Mission Elapsed Time (MET) in the time reference of the
  39 +observation (#2054).
  40 +
29 The ctools::is_valid_filename() method was removed since the validity check 41 The ctools::is_valid_filename() method was removed since the validity check
30 of the filename is now done by the GApplicationPar class. 42 of the filename is now done by the GApplicationPar class.
31 43
32 44
33 ctbin - CTA event binning 45 ctbin - CTA event binning
34 ------------------------- 46 -------------------------
35 -None 47 +Copy the time reference from the first input observation (#2054).
36 48
37 49
38 ctbkgcube - CTA background cube generation 50 ctbkgcube - CTA background cube generation
@@ -82,7 +94,8 @@ None @@ -82,7 +94,8 @@ None
82 94
83 ctobssim - CTA observation simulation 95 ctobssim - CTA observation simulation
84 ------------------------------------- 96 -------------------------------------
85 -None 97 +Add "mjdref" parameter to allow specification of the MJD reference time
  98 +for the simulation (#2054).
86 99
87 100
88 ctphase - Event phase computation 101 ctphase - Event phase computation
@@ -102,7 +115,8 @@ None @@ -102,7 +115,8 @@ None
102 115
103 ctselect - CTA event selection 116 ctselect - CTA event selection
104 ------------------------------ 117 ------------------------------
105 -None 118 +Interpret MET specified by "tmin" and "tmax" parameters in the time reference
  119 +of the input observations (#2054).
106 120
107 121
108 ctskymap - CTA sky mapping 122 ctskymap - CTA sky mapping
@@ -172,7 +186,8 @@ None @@ -172,7 +186,8 @@ None
172 186
173 cslightcrv - Generate light curve 187 cslightcrv - Generate light curve
174 --------------------------------- 188 ---------------------------------
175 -None 189 +Add hidden "mjdref" parameter for the specification of the MET reference
  190 +(#2054).
176 191
177 192
178 csmodelinfo - Return model information 193 csmodelinfo - Return model information
@@ -202,7 +217,8 @@ None @@ -202,7 +217,8 @@ None
202 217
203 csobsdef - Generate observation definition XML file 218 csobsdef - Generate observation definition XML file
204 --------------------------------------------------- 219 ---------------------------------------------------
205 -None 220 +Add hidden "mjdref" parameter for the specification of the MET reference
  221 +(#2054).
206 222
207 223
208 csobsinfo - Return observation definition information 224 csobsinfo - Return observation definition information
@@ -212,7 +228,8 @@ Add ras() and decs() methods (#2313) @@ -212,7 +228,8 @@ Add ras() and decs() methods (#2313)
212 228
213 csobsselect - Select observations 229 csobsselect - Select observations
214 --------------------------------- 230 ---------------------------------
215 -None 231 +Use time reference of input observations if time selection is given in MET
  232 +(#2054).
216 233
217 234
218 csphagen - Generate On/Off observations 235 csphagen - Generate On/Off observations
@@ -233,7 +250,8 @@ None @@ -233,7 +250,8 @@ None
233 250
234 cspull - Generate pull distributions 251 cspull - Generate pull distributions
235 ------------------------------------ 252 ------------------------------------
236 -None 253 +Add hidden "mjdref" parameter for the specification of the MET reference
  254 +(#2054).
237 255
238 256
239 csresmap - Generate residual map 257 csresmap - Generate residual map
@@ -284,7 +302,8 @@ None @@ -284,7 +302,8 @@ None
284 302
285 csviscube - Generate visibility cube 303 csviscube - Generate visibility cube
286 ------------------------------------ 304 ------------------------------------
287 -None 305 +Add hidden "mjdref" parameter for the specification of the MET reference
  306 +(#2054).
288 307
289 308
290 csworkflow - Execute workflow 309 csworkflow - Execute workflow
@@ -309,7 +328,7 @@ None @@ -309,7 +328,7 @@ None
309 328
310 obsutils - Observation utilities 329 obsutils - Observation utilities
311 -------------------------------- 330 --------------------------------
312 -None 331 +Add "mjdref" parameter to set_obs() function (#2054).
313 332
314 333
315 Examples 334 Examples
cscripts/cslightcrv.par
@@ -31,6 +31,7 @@ outfile, f, a, lightcurve.fits,,, "Output light curve file" @@ -31,6 +31,7 @@ outfile, f, a, lightcurve.fits,,, "Output light curve file"
31 tbinalg, s, a, GTI,FILE|LIN|GTI,, "Algorithm for defining time bins" 31 tbinalg, s, a, GTI,FILE|LIN|GTI,, "Algorithm for defining time bins"
32 tmin, t, a, MJD 51544.5,,,"Lightcurve start time (UTC string, JD, MJD or MET in seconds)" 32 tmin, t, a, MJD 51544.5,,,"Lightcurve start time (UTC string, JD, MJD or MET in seconds)"
33 tmax, t, a, MJD 51544.6,,,"Lightcurve stop time (UTC string, JD, MJD or MET in seconds)" 33 tmax, t, a, MJD 51544.6,,,"Lightcurve stop time (UTC string, JD, MJD or MET in seconds)"
  34 +mjdref, r, h, 51544.5,,, "Reference MJD for MET"
34 tbins, i, a, 5,1,10000, "Number of time bins" 35 tbins, i, a, 5,1,10000, "Number of time bins"
35 tbinfile, f, a, NONE,,, "File defining the time binning" 36 tbinfile, f, a, NONE,,, "File defining the time binning"
36 method, s, a, 3D, 3D|ONOFF,, "Analysis method" 37 method, s, a, 3D, 3D|ONOFF,, "Analysis method"
cscripts/cslightcrv.py
@@ -137,8 +137,11 @@ class cslightcrv(ctools.csobservation): @@ -137,8 +137,11 @@ class cslightcrv(ctools.csobservation):
137 gti : `~gammalib.GGti` 137 gti : `~gammalib.GGti`
138 Light curve bins in form of Good Time Intervals 138 Light curve bins in form of Good Time Intervals
139 """ 139 """
  140 + # Get MET time reference
  141 + tref = gammalib.GTimeReference(self['mjdref'].real(),'s','TT','LOCAL')
  142 +
140 # Initialise Good Time Intervals 143 # Initialise Good Time Intervals
141 - gti = gammalib.GGti() 144 + gti = gammalib.GGti(tref)
142 145
143 # Get algorithm to use for defining the time intervals. Possible 146 # Get algorithm to use for defining the time intervals. Possible
144 # values are "FILE", "LIN" and "GTI". This is enforced at 147 # values are "FILE", "LIN" and "GTI". This is enforced at
@@ -173,8 +176,8 @@ class cslightcrv(ctools.csobservation): @@ -173,8 +176,8 @@ class cslightcrv(ctools.csobservation):
173 elif algorithm == 'LIN': 176 elif algorithm == 'LIN':
174 177
175 # Get start and stop time and number of time bins 178 # Get start and stop time and number of time bins
176 - time_min = self['tmin'].time(ctools.time_reference)  
177 - time_max = self['tmax'].time(ctools.time_reference) 179 + time_min = self['tmin'].time(tref)
  180 + time_max = self['tmax'].time(tref)
178 nbins = self['tbins'].integer() 181 nbins = self['tbins'].integer()
179 182
180 # Compute time step in seconds and setup the GTIs 183 # Compute time step in seconds and setup the GTIs
@@ -385,8 +388,8 @@ class cslightcrv(ctools.csobservation): @@ -385,8 +388,8 @@ class cslightcrv(ctools.csobservation):
385 select = ctools.ctselect(self.obs()) 388 select = ctools.ctselect(self.obs())
386 select['emin'] = self['emin'].real() 389 select['emin'] = self['emin'].real()
387 select['emax'] = self['emax'].real() 390 select['emax'] = self['emax'].real()
388 - select['tmin'] = tmin.convert(ctools.time_reference)  
389 - select['tmax'] = tmax.convert(ctools.time_reference) 391 + select['tmin'] = tmin
  392 + select['tmax'] = tmax
390 select['rad'] = 'UNDEFINED' 393 select['rad'] = 'UNDEFINED'
391 select['ra'] = 'UNDEFINED' 394 select['ra'] = 'UNDEFINED'
392 select['dec'] = 'UNDEFINED' 395 select['dec'] = 'UNDEFINED'
@@ -444,8 +447,8 @@ class cslightcrv(ctools.csobservation): @@ -444,8 +447,8 @@ class cslightcrv(ctools.csobservation):
444 select = ctools.ctselect(self.obs()) 447 select = ctools.ctselect(self.obs())
445 select['emin'] = self['emin'].real() 448 select['emin'] = self['emin'].real()
446 select['emax'] = self['emax'].real() 449 select['emax'] = self['emax'].real()
447 - select['tmin'] = tmin.convert(ctools.time_reference)  
448 - select['tmax'] = tmax.convert(ctools.time_reference) 450 + select['tmin'] = tmin
  451 + select['tmax'] = tmax
449 select['rad'] = 'UNDEFINED' 452 select['rad'] = 'UNDEFINED'
450 select['ra'] = 'UNDEFINED' 453 select['ra'] = 'UNDEFINED'
451 select['dec'] = 'UNDEFINED' 454 select['dec'] = 'UNDEFINED'
cscripts/csobsdef.par
@@ -30,6 +30,7 @@ emin, r, h, UNDEF,,, "Lower energy limit (TeV)" @@ -30,6 +30,7 @@ emin, r, h, UNDEF,,, "Lower energy limit (TeV)"
30 emax, r, h, UNDEF,,, "Upper energy limit (TeV)" 30 emax, r, h, UNDEF,,, "Upper energy limit (TeV)"
31 rad, r, h, UNDEF,,, "Radius of ROI (degrees)" 31 rad, r, h, UNDEF,,, "Radius of ROI (degrees)"
32 deadc, r, h, 0.98,,, "Deadtime correction factor" 32 deadc, r, h, 0.98,,, "Deadtime correction factor"
  33 +mjdref, r, h, 51544.5,,, "Reference MJD for observations"
33 34
34 # 35 #
35 # Standard parameters 36 # Standard parameters
cscripts/csobsdef.py
@@ -272,11 +272,12 @@ class csobsdef(ctools.cscript): @@ -272,11 +272,12 @@ class csobsdef(ctools.cscript):
272 duration = float(self._pntdef[row, header.index('duration')]) 272 duration = float(self._pntdef[row, header.index('duration')])
273 else: 273 else:
274 duration = self['duration'].real() 274 duration = self['duration'].real()
  275 + tref = gammalib.GTimeReference(self['mjdref'].real(),'s')
275 tmin = self._tmin 276 tmin = self._tmin
276 tmax = self._tmin + duration 277 tmax = self._tmin + duration
277 - gti = gammalib.GGti(ctools.time_reference)  
278 - tstart = gammalib.GTime(tmin, ctools.time_reference)  
279 - tstop = gammalib.GTime(tmax, ctools.time_reference) 278 + gti = gammalib.GGti(tref)
  279 + tstart = gammalib.GTime(tmin, tref)
  280 + tstop = gammalib.GTime(tmax, tref)
280 self._tmin = tmax 281 self._tmin = tmax
281 gti.append(tstart, tstop) 282 gti.append(tstart, tstop)
282 obs.ontime(gti.ontime()) 283 obs.ontime(gti.ontime())
cscripts/csobsinfo.py
@@ -289,10 +289,11 @@ class csobsinfo(ctools.csobservation): @@ -289,10 +289,11 @@ class csobsinfo(ctools.csobservation):
289 self._log_value(gammalib.NORMAL, 'Maximum energy', max_value) 289 self._log_value(gammalib.NORMAL, 'Maximum energy', max_value)
290 290
291 # Log time range 291 # Log time range
  292 + ref = obs.gti().reference()
292 mjd = '%.3f - %.3f' % (self._gti.tstart().mjd(), self._gti.tstop().mjd()) 293 mjd = '%.3f - %.3f' % (self._gti.tstart().mjd(), self._gti.tstop().mjd())
293 utc = '%s - %s' % (self._gti.tstart().utc(), self._gti.tstop().utc()) 294 utc = '%s - %s' % (self._gti.tstart().utc(), self._gti.tstop().utc())
294 - met = '%.3f - %.3f' % (self._gti.tstart().convert(ctools.time_reference),  
295 - self._gti.tstop().convert(ctools.time_reference)) 295 + met = '%.3f - %.3f' % (self._gti.tstart().convert(ref),
  296 + self._gti.tstop().convert(ref))
296 self._log_header3(gammalib.NORMAL, 'Time range') 297 self._log_header3(gammalib.NORMAL, 'Time range')
297 self._log_value(gammalib.NORMAL, 'MJD (days)', mjd) 298 self._log_value(gammalib.NORMAL, 'MJD (days)', mjd)
298 self._log_value(gammalib.NORMAL, 'UTC', utc) 299 self._log_value(gammalib.NORMAL, 'UTC', utc)
cscripts/csobsselect.py
@@ -68,8 +68,10 @@ class csobsselect(ctools.csobservation): @@ -68,8 +68,10 @@ class csobsselect(ctools.csobservation):
68 self['width'].real() 68 self['width'].real()
69 self['height'].real() 69 self['height'].real()
70 70
71 - # Query time interval  
72 - self._get_gti() 71 + # Query time interval. The GammaLib time reference is specified as a
  72 + # dummy argument since the relevant intervals will be queried later
  73 + # using the time reference for each observation
  74 + self._get_gti(gammalib.GTimeReference())
73 75
74 # Query ahead output model filename 76 # Query ahead output model filename
75 if self._read_ahead(): 77 if self._read_ahead():
@@ -113,7 +115,7 @@ class csobsselect(ctools.csobservation): @@ -113,7 +115,7 @@ class csobsselect(ctools.csobservation):
113 # Return 115 # Return
114 return 116 return
115 117
116 - def _select_observation(self, obs, gti): 118 + def _select_observation(self, obs):
117 """ 119 """
118 Select observation 120 Select observation
119 121
@@ -121,8 +123,6 @@ class csobsselect(ctools.csobservation): @@ -121,8 +123,6 @@ class csobsselect(ctools.csobservation):
121 ---------- 123 ----------
122 obs : `~gammalib.GObservation` 124 obs : `~gammalib.GObservation`
123 Observation 125 Observation
124 - gti : `~gammalib.GGti`  
125 - Good time intervals  
126 126
127 Returns 127 Returns
128 ------- 128 -------
@@ -140,6 +140,10 @@ class csobsselect(ctools.csobservation): @@ -140,6 +140,10 @@ class csobsselect(ctools.csobservation):
140 tstart = obs_gti.tstart() 140 tstart = obs_gti.tstart()
141 tstop = obs_gti.tstop() 141 tstop = obs_gti.tstop()
142 142
  143 + # Get User start and stop time in the time reference of the CTA
  144 + # observations
  145 + gti = self._get_gti(obs_gti.reference())
  146 +
143 # If the observation is not within the time selection then skip it 147 # If the observation is not within the time selection then skip it
144 if gti.size() > 0 and not gti.contains(tstart) and \ 148 if gti.size() > 0 and not gti.contains(tstart) and \
145 not gti.contains(tstop): 149 not gti.contains(tstop):
@@ -294,9 +298,6 @@ class csobsselect(ctools.csobservation): @@ -294,9 +298,6 @@ class csobsselect(ctools.csobservation):
294 # Get parameters 298 # Get parameters
295 self._get_parameters() 299 self._get_parameters()
296 300
297 - # Get Good Time Interval (empty if no time selection is applied)  
298 - gti = self._get_gti()  
299 -  
300 # Initialise empty observation container for selected observations 301 # Initialise empty observation container for selected observations
301 selected_obs = gammalib.GObservations() 302 selected_obs = gammalib.GObservations()
302 303
@@ -310,7 +311,7 @@ class csobsselect(ctools.csobservation): @@ -310,7 +311,7 @@ class csobsselect(ctools.csobservation):
310 for obs in self.obs(): 311 for obs in self.obs():
311 312
312 # If observation is selected then append observation 313 # If observation is selected then append observation
313 - if self._select_observation(obs, gti): 314 + if self._select_observation(obs):
314 selected_obs.append(obs) 315 selected_obs.append(obs)
315 316
316 # Copy selected observations into observation 317 # Copy selected observations into observation
cscripts/cspull.par
@@ -40,6 +40,7 @@ emax, r, a, 100.0,,, "Upper energy limit (TeV)" @@ -40,6 +40,7 @@ emax, r, a, 100.0,,, "Upper energy limit (TeV)"
40 enumbins, i, a, 0,,, "Number of energy bins (0=unbinned)" 40 enumbins, i, a, 0,,, "Number of energy bins (0=unbinned)"
41 tmin, t, a, 2020-01-01T00:00:00,,, "Start time (UTC string, JD, MJD or MET in seconds)" 41 tmin, t, a, 2020-01-01T00:00:00,,, "Start time (UTC string, JD, MJD or MET in seconds)"
42 tmax, t, a, 2020-01-01T00:30:00,,, "Stop time (UTC string, JD, MJD or MET in seconds)" 42 tmax, t, a, 2020-01-01T00:30:00,,, "Stop time (UTC string, JD, MJD or MET in seconds)"
  43 +mjdref, r, h, 51544.5,,, "Reference MJD for MET"
43 npix, i, a, 200,,, "Number of pixels for binned" 44 npix, i, a, 200,,, "Number of pixels for binned"
44 binsz, r, a, 0.05,,, "Pixel size for binned (degrees/pixel)" 45 binsz, r, a, 0.05,,, "Pixel size for binned (degrees/pixel)"
45 statistic, s, h, DEFAULT,DEFAULT|CSTAT|WSTAT|CHI2,, "Optimization statistic" 46 statistic, s, h, DEFAULT,DEFAULT|CSTAT|WSTAT|CHI2,, "Optimization statistic"
cscripts/csviscube.par
@@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
18 #=================== 18 #===================
19 tmin, t, a, 2020-01-01T00:00:00,,, "Start time of observation (UTC string, JD, MJD or MET in seconds)" 19 tmin, t, a, 2020-01-01T00:00:00,,, "Start time of observation (UTC string, JD, MJD or MET in seconds)"
20 tmax, t, a, 2021-01-01T00:00:00,,, "Stop time of observation (UTC string, JD, MJD or MET in seconds)" 20 tmax, t, a, 2021-01-01T00:00:00,,, "Stop time of observation (UTC string, JD, MJD or MET in seconds)"
  21 +mjdref, r, h, 51544.5,,, "Reference MJD for MET"
21 geolon, r, a, 79.4041,,, "Geographic longitude of array (deg)" 22 geolon, r, a, 79.4041,,, "Geographic longitude of array (deg)"
22 geolat, r, a, -24.6272,,, "Geographic latitude of array (deg)" 23 geolat, r, a, -24.6272,,, "Geographic latitude of array (deg)"
23 sunzenith, r, h, 105.0,,, "Minimum Sun zenith angle for observations (deg)" 24 sunzenith, r, h, 105.0,,, "Minimum Sun zenith angle for observations (deg)"
cscripts/csviscube.py
@@ -64,6 +64,7 @@ class csviscube(ctools.cscript): @@ -64,6 +64,7 @@ class csviscube(ctools.cscript):
64 Get all parameters 64 Get all parameters
65 """ 65 """
66 # Query parameters 66 # Query parameters
  67 + self['mjdref'].real()
67 self['tmin'].time() 68 self['tmin'].time()
68 self['tmax'].time() 69 self['tmax'].time()
69 self['geolon'].real() 70 self['geolon'].real()
@@ -259,9 +260,12 @@ class csviscube(ctools.cscript): @@ -259,9 +260,12 @@ class csviscube(ctools.cscript):
259 # Get array geographic longitude 260 # Get array geographic longitude
260 #geolon = self['geolon'].real() 261 #geolon = self['geolon'].real()
261 262
  263 + # Get MET time reference
  264 + tref = gammalib.GTimeReference(self['mjdref'].real(),'s','TT','LOCAL')
  265 +
262 # Get time interval 266 # Get time interval
263 - tmin = self['tmin'].time(ctools.time_reference)  
264 - tmax = self['tmax'].time(ctools.time_reference) 267 + tmin = self['tmin'].time(tref)
  268 + tmax = self['tmax'].time(tref)
265 269
266 # Initialise hour angle list 270 # Initialise hour angle list
267 hour_angles = [] 271 hour_angles = []
cscripts/obsutils.py
@@ -224,7 +224,7 @@ def sim(obs, log=False, debug=False, chatter=2, edisp=False, seed=0, @@ -224,7 +224,7 @@ def sim(obs, log=False, debug=False, chatter=2, edisp=False, seed=0,
224 # ======================= # 224 # ======================= #
225 def set_obs(pntdir, tstart=0.0, duration=1800.0, deadc=0.98, \ 225 def set_obs(pntdir, tstart=0.0, duration=1800.0, deadc=0.98, \
226 emin=0.1, emax=100.0, rad=5.0, \ 226 emin=0.1, emax=100.0, rad=5.0, \
227 - irf='South_50h', caldb='prod2', obsid='000000'): 227 + irf='South_50h', caldb='prod2', obsid='000000', mjdref=51544.5):
228 """ 228 """
229 Set a single CTA observation 229 Set a single CTA observation
230 230
@@ -283,9 +283,10 @@ def set_obs(pntdir, tstart=0.0, duration=1800.0, deadc=0.98, \ @@ -283,9 +283,10 @@ def set_obs(pntdir, tstart=0.0, duration=1800.0, deadc=0.98, \
283 roi.radius(rad) 283 roi.radius(rad)
284 284
285 # Set GTI 285 # Set GTI
286 - gti = gammalib.GGti(ctools.time_reference)  
287 - gti.append(gammalib.GTime(tstart, ctools.time_reference),  
288 - gammalib.GTime(tstart+duration, ctools.time_reference)) 286 + ref = gammalib.GTimeReference(mjdref,'s','TT','LOCAL')
  287 + gti = gammalib.GGti(ref)
  288 + gti.append(gammalib.GTime(tstart, ref),
  289 + gammalib.GTime(tstart+duration, ref))
289 290
290 # Set energy boundaries 291 # Set energy boundaries
291 ebounds = gammalib.GEbounds(gammalib.GEnergy(emin, 'TeV'), 292 ebounds = gammalib.GEbounds(gammalib.GEnergy(emin, 'TeV'),
doc/source/admin/release_history/1.6.rst
@@ -36,6 +36,9 @@ Improvements @@ -36,6 +36,9 @@ Improvements
36 Allow specifying of input skymap to :ref:`ctskymap` tool 36 Allow specifying of input skymap to :ref:`ctskymap` tool
37 * [`2309 <https://cta-redmine.irap.omp.eu/issues/2309>`_] - 37 * [`2309 <https://cta-redmine.irap.omp.eu/issues/2309>`_] -
38 Accelerate `IRF` and `RING` background methods in :ref:`ctskymap` 38 Accelerate `IRF` and `RING` background methods in :ref:`ctskymap`
  39 +* [`2045 <https://cta-redmine.irap.omp.eu/issues/2045>`_] -
  40 + Define MET with respect to the observation time reference or the ``mjdref``
  41 + user parameter (#2054)
39 42
40 43
41 New features 44 New features
@@ -48,3 +51,5 @@ Clean up @@ -48,3 +51,5 @@ Clean up
48 -------- 51 --------
49 52
50 * Remove ``ctools::is_valid_filename()`` method 53 * Remove ``ctools::is_valid_filename()`` method
  54 +* [`2045 <https://cta-redmine.irap.omp.eu/issues/2045>`_] -
  55 + Remove ``ctools::time_reference`` constant
doc/source/users/reference_manual/cslightcrv.rst
@@ -77,6 +77,9 @@ General parameters @@ -77,6 +77,9 @@ General parameters
77 ``tmax [time]`` 77 ``tmax [time]``
78 Lightcurve stop time (UTC string, JD, MJD or MET in seconds). 78 Lightcurve stop time (UTC string, JD, MJD or MET in seconds).
79 79
  80 +``(mjdref = 51544.5) [real]``
  81 + Reference Modified Julian Day (MJD) for Mission Elapsed Time (MET).
  82 +
80 ``tbins [integer]`` 83 ``tbins [integer]``
81 Number of time bins. 84 Number of time bins.
82 85
doc/source/users/reference_manual/csobsdef.rst
@@ -82,6 +82,9 @@ General parameters @@ -82,6 +82,9 @@ General parameters
82 ``(deadc = 0.95) [real]`` 82 ``(deadc = 0.95) [real]``
83 Average deadtime correction factor. 83 Average deadtime correction factor.
84 84
  85 +``(mjdref = 51544.5) [real]``
  86 + Reference Modified Julian Day (MJD) for observations.
  87 +
85 88
86 Standard parameters 89 Standard parameters
87 ------------------- 90 -------------------
doc/source/users/reference_manual/csobsselect.rst
@@ -52,12 +52,16 @@ General parameters @@ -52,12 +52,16 @@ General parameters
52 Height of selection box (degrees). 52 Height of selection box (degrees).
53 53
54 ``tmin [time]`` 54 ``tmin [time]``
55 - Start time (UTC string, JD, MJD or time in seconds). 55 + Start time for observation selection (UTC string, JD, MJD or MET in seconds).
  56 + Start times given in MET seconds are counted with respect to the time
  57 + reference of the input observation(s).
56 If ``INDEF``, ``NONE``, ``UNDEF`` or ``UNDEFINED`` is passed as value, no time 58 If ``INDEF``, ``NONE``, ``UNDEF`` or ``UNDEFINED`` is passed as value, no time
57 selection will be performed. 59 selection will be performed.
58 60
59 ``tmax [time]`` 61 ``tmax [time]``
60 - Stop time (UTC string, JD, MJD or time in seconds). 62 + Stop time for observation selection (UTC string, JD, MJD or MET in seconds).
  63 + Stop times given in MET seconds are counted with respect to the time
  64 + reference of the input observation(s).
61 If ``INDEF``, ``NONE``, ``UNDEF`` or ``UNDEFINED`` is passed as value, no time 65 If ``INDEF``, ``NONE``, ``UNDEF`` or ``UNDEFINED`` is passed as value, no time
62 selection will be performed. 66 selection will be performed.
63 67
doc/source/users/reference_manual/cspull.rst
@@ -106,6 +106,9 @@ General parameters @@ -106,6 +106,9 @@ General parameters
106 ``tmax [time]`` 106 ``tmax [time]``
107 Stop time (UTC string, JD, MJD or MET in seconds). 107 Stop time (UTC string, JD, MJD or MET in seconds).
108 108
  109 +``(mjdref = 51544.5) [real]``
  110 + Reference Modified Julian Day (MJD) for MET.
  111 +
109 ``npix [integer]`` 112 ``npix [integer]``
110 Number of pixels for binned analysis. 113 Number of pixels for binned analysis.
111 114
doc/source/users/reference_manual/csviscube.rst
@@ -30,6 +30,9 @@ General parameters @@ -30,6 +30,9 @@ General parameters
30 ``tmax [time]`` 30 ``tmax [time]``
31 Stop time of observation (UTC string, JD, MJD or MET in seconds). 31 Stop time of observation (UTC string, JD, MJD or MET in seconds).
32 32
  33 +``(mjdref = 51544.5) [real]``
  34 + Reference Modified Julian Day (MJD) for MET.
  35 +
33 ``geolon [real]`` 36 ``geolon [real]``
34 Geographic longitude of the IACT array in degrees. 37 Geographic longitude of the IACT array in degrees.
35 38
doc/source/users/reference_manual/ctobssim.rst
@@ -89,6 +89,10 @@ General parameters @@ -89,6 +89,10 @@ General parameters
89 ``tmax [time]`` 89 ``tmax [time]``
90 Stop time (UTC string, JD, MJD or MET in seconds). 90 Stop time (UTC string, JD, MJD or MET in seconds).
91 91
  92 +``(mjdref = 51544.5) [real]``
  93 + Reference Modified Julian Day (MJD) for simulated events. The times in
  94 + seconds for each event are counted from this reference time on.
  95 +
92 ``emin [real]`` 96 ``emin [real]``
93 Lower energy limit of simulated events (in TeV). 97 Lower energy limit of simulated events (in TeV).
94 98
doc/source/users/reference_manual/ctselect.rst
@@ -66,12 +66,16 @@ General parameters @@ -66,12 +66,16 @@ General parameters
66 selection will be performed. 66 selection will be performed.
67 67
68 ``tmin [time]`` 68 ``tmin [time]``
69 - Start time (UTC string, JD, MJD or time in seconds). 69 + Start time for event selection (UTC string, JD, MJD or MET in seconds).
  70 + Start times given in MET seconds are counted with respect to the time
  71 + reference of the input observation(s).
70 If ``INDEF``, ``NONE``, ``UNDEF`` or ``UNDEFINED`` is passed as value, no time 72 If ``INDEF``, ``NONE``, ``UNDEF`` or ``UNDEFINED`` is passed as value, no time
71 selection will be performed. 73 selection will be performed.
72 74
73 ``tmax [time]`` 75 ``tmax [time]``
74 - Stop time (UTC string, JD, MJD or time in seconds). 76 + Stop time for event selection (UTC string, JD, MJD or MET in seconds).
  77 + Stop times given in MET seconds are counted with respect to the time
  78 + reference of the input observation(s).
75 If ``INDEF``, ``NONE``, ``UNDEF`` or ``UNDEFINED`` is passed as value, no time 79 If ``INDEF``, ``NONE``, ``UNDEF`` or ``UNDEFINED`` is passed as value, no time
76 selection will be performed. 80 selection will be performed.
77 81
pyext/ctool.i
@@ -57,10 +57,6 @@ public: @@ -57,10 +57,6 @@ public:
57 %include "argcargv.i" 57 %include "argcargv.i"
58 58
59 /* __ Constants __________________________________________________________ */ 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 /***********************************************************************//**
@@ -142,7 +138,7 @@ public: @@ -142,7 +138,7 @@ public:
142 // Protected methods that extract user parameters 138 // Protected methods that extract user parameters
143 GCTARoi get_roi(const GCTAPointing& pnt = GCTAPointing()); 139 GCTARoi get_roi(const GCTAPointing& pnt = GCTAPointing());
144 GEbounds get_ebounds(void); 140 GEbounds get_ebounds(void);
145 - GGti get_gti(void); 141 + GGti get_gti(const GTimeReference& ref);
146 GCTAPointing get_pointing(void); 142 GCTAPointing get_pointing(void);
147 GSkyDir get_skydir(void); 143 GSkyDir get_skydir(void);
148 std::string set_outfile_name(const std::string& filename); 144 std::string set_outfile_name(const std::string& filename);
src/ctbin/ctbin.cpp
@@ -385,9 +385,6 @@ void ctbin::init_members(void) @@ -385,9 +385,6 @@ void ctbin::init_members(void)
385 // Initialise cache members 385 // Initialise cache members
386 m_dirs.clear(); 386 m_dirs.clear();
387 387
388 - // Set CTA reference time  
389 - m_gti.reference(ctools::time_reference);  
390 -  
391 // Return 388 // Return
392 return; 389 return;
393 } 390 }
@@ -586,6 +583,12 @@ void ctbin::fill_cube(GCTAObservation* obs) @@ -586,6 +583,12 @@ void ctbin::fill_cube(GCTAObservation* obs)
586 // Update time information 583 // Update time information
587 #pragma omp critical(ctbin_fill_cube) 584 #pragma omp critical(ctbin_fill_cube)
588 { 585 {
  586 + // If GTI is empty then set its time reference from the observation.
  587 + // From then on we keep that time reference
  588 + if (m_gti.is_empty()) {
  589 + m_gti.reference(events->gti().reference());
  590 + }
  591 +
589 // Append GTIs 592 // Append GTIs
590 m_gti.extend(events->gti()); 593 m_gti.extend(events->gti());
591 594
src/ctobssim/ctobssim.cpp
@@ -784,9 +784,10 @@ void ctobssim::simulate_source(GCTAObservation* obs, @@ -784,9 +784,10 @@ void ctobssim::simulate_source(GCTAObservation* obs,
784 // Loop over all Good Time Intervals 784 // Loop over all Good Time Intervals
785 for (int it = 0; it < events->gti().size(); ++it) { 785 for (int it = 0; it < events->gti().size(); ++it) {
786 786
787 - // Extract time interval  
788 - GTime tmin = events->gti().tstart(it);  
789 - GTime tmax = events->gti().tstop(it); 787 + // Extract time interval and time reference
  788 + GTime tmin = events->gti().tstart(it);
  789 + GTime tmax = events->gti().tstop(it);
  790 + GTimeReference tref = events->gti().reference();
790 791
791 // Log time interval. Increment indentation if there are 792 // Log time interval. Increment indentation if there are
792 // several Good Time Intervals. 793 // several Good Time Intervals.
@@ -796,9 +797,9 @@ void ctobssim::simulate_source(GCTAObservation* obs, @@ -796,9 +797,9 @@ void ctobssim::simulate_source(GCTAObservation* obs,
796 wrklog->indent(indent); 797 wrklog->indent(indent);
797 } 798 }
798 *wrklog << gammalib::parformat("Time interval", indent); 799 *wrklog << gammalib::parformat("Time interval", indent);
799 - *wrklog << tmin.convert(ctools::time_reference); 800 + *wrklog << tmin.convert(tref);
800 *wrklog << " - "; 801 *wrklog << " - ";
801 - *wrklog << tmax.convert(ctools::time_reference); 802 + *wrklog << tmax.convert(tref);
802 *wrklog << " s" << std::endl; 803 *wrklog << " s" << std::endl;
803 } 804 }
804 805
@@ -1063,8 +1064,8 @@ void ctobssim::simulate_interval(GCTAObservation* obs, @@ -1063,8 +1064,8 @@ void ctobssim::simulate_interval(GCTAObservation* obs,
1063 wrklog->indent(indent); 1064 wrklog->indent(indent);
1064 } 1065 }
1065 *wrklog << gammalib::parformat("Time slice", indent); 1066 *wrklog << gammalib::parformat("Time slice", indent);
1066 - *wrklog << tstart.convert(ctools::time_reference) << " - ";  
1067 - *wrklog << tstop.convert(ctools::time_reference) << " s"; 1067 + *wrklog << tstart.convert(obs->gti().reference()) << " - ";
  1068 + *wrklog << tstop.convert(obs->gti().reference()) << " s";
1068 if (model->name().length() > 0) { 1069 if (model->name().length() > 0) {
1069 *wrklog << " [" << model->name() << "]"; 1070 *wrklog << " [" << model->name() << "]";
1070 } 1071 }
src/ctobssim/ctobssim.par
@@ -34,6 +34,7 @@ dec, r, a, 22.51,-90,90, &quot;Dec of pointing (degrees)&quot; @@ -34,6 +34,7 @@ dec, r, a, 22.51,-90,90, &quot;Dec of pointing (degrees)&quot;
34 rad, r, a, 5.0,0,180, "Radius of FOV (degrees)" 34 rad, r, a, 5.0,0,180, "Radius of FOV (degrees)"
35 tmin, t, a, 2020-01-01T00:00:00,,, "Start time (UTC string, JD, MJD or MET in seconds)" 35 tmin, t, a, 2020-01-01T00:00:00,,, "Start time (UTC string, JD, MJD or MET in seconds)"
36 tmax, t, a, 2020-01-01T00:30:00,,, "Stop time (UTC string, JD, MJD or MET in seconds)" 36 tmax, t, a, 2020-01-01T00:30:00,,, "Stop time (UTC string, JD, MJD or MET in seconds)"
  37 +mjdref, r, h, 51544.5,,, "Reference MJD for simulated events"
37 emin, r, a, 0.1,,, "Lower energy limit (TeV)" 38 emin, r, a, 0.1,,, "Lower energy limit (TeV)"
38 emax, r, a, 100.0,,, "Upper energy limit (TeV)" 39 emax, r, a, 100.0,,, "Upper energy limit (TeV)"
39 deadc, r, h, 0.98,0,1, "Average deadtime correction factor" 40 deadc, r, h, 0.98,0,1, "Average deadtime correction factor"
src/ctselect/ctselect.cpp
@@ -465,7 +465,6 @@ void ctselect::init_members(void) @@ -465,7 +465,6 @@ void ctselect::init_members(void)
465 { 465 {
466 // Initialise parameters 466 // Initialise parameters
467 m_outobs.clear(); 467 m_outobs.clear();
468 - m_gti.clear();  
469 m_emin = 0.0; 468 m_emin = 0.0;
470 m_emax = 0.0; 469 m_emax = 0.0;
471 m_expr.clear(); 470 m_expr.clear();
@@ -476,8 +475,6 @@ void ctselect::init_members(void) @@ -476,8 +475,6 @@ void ctselect::init_members(void)
476 m_infiles.clear(); 475 m_infiles.clear();
477 m_evtname.clear(); 476 m_evtname.clear();
478 m_gtiname.clear(); 477 m_gtiname.clear();
479 - m_timemin.clear();  
480 - m_timemax.clear();  
481 m_phases.clear(); 478 m_phases.clear();
482 m_select_energy = false; 479 m_select_energy = false;
483 m_select_phase = false; 480 m_select_phase = false;
@@ -496,7 +493,6 @@ void ctselect::copy_members(const ctselect&amp; app) @@ -496,7 +493,6 @@ void ctselect::copy_members(const ctselect&amp; app)
496 { 493 {
497 // Copy parameters 494 // Copy parameters
498 m_outobs = app.m_outobs; 495 m_outobs = app.m_outobs;
499 - m_gti = app.m_gti;  
500 m_emin = app.m_emin; 496 m_emin = app.m_emin;
501 m_emax = app.m_emax; 497 m_emax = app.m_emax;
502 m_expr = app.m_expr; 498 m_expr = app.m_expr;
@@ -507,8 +503,6 @@ void ctselect::copy_members(const ctselect&amp; app) @@ -507,8 +503,6 @@ void ctselect::copy_members(const ctselect&amp; app)
507 m_infiles = app.m_infiles; 503 m_infiles = app.m_infiles;
508 m_evtname = app.m_evtname; 504 m_evtname = app.m_evtname;
509 m_gtiname = app.m_gtiname; 505 m_gtiname = app.m_gtiname;
510 - m_timemin = app.m_timemin;  
511 - m_timemax = app.m_timemax;  
512 m_phases = app.m_phases; 506 m_phases = app.m_phases;
513 m_select_energy = app.m_select_energy; 507 m_select_energy = app.m_select_energy;
514 m_select_phase = app.m_select_phase; 508 m_select_phase = app.m_select_phase;
@@ -555,8 +549,10 @@ void ctselect::get_parameters(void) @@ -555,8 +549,10 @@ void ctselect::get_parameters(void)
555 GCTAPointing pnt; 549 GCTAPointing pnt;
556 GCTARoi roi = get_roi(pnt); 550 GCTARoi roi = get_roi(pnt);
557 551
558 - // Get Good Time Intervals (empty if no selection is done)  
559 - m_gti = get_gti(); 552 + // Query Good Time Intervals. The GammaLib time reference is specified
  553 + // as a dummy argument since the relevant intervals will be queried later
  554 + // using the time reference for each observation
  555 + get_gti(GTimeReference());
560 556
561 // Get energy selection parameters 557 // Get energy selection parameters
562 if ((*this)["emin"].is_valid() && (*this)["emax"].is_valid()) { 558 if ((*this)["emin"].is_valid() && (*this)["emax"].is_valid()) {
@@ -653,11 +649,6 @@ void ctselect::get_parameters(void) @@ -653,11 +649,6 @@ void ctselect::get_parameters(void)
653 (*this)["prefix"].query(); 649 (*this)["prefix"].query();
654 } 650 }
655 651
656 - // Set time interval with input times given in CTA reference  
657 - // time (in seconds)  
658 - m_timemin = m_gti.tstart();  
659 - m_timemax = m_gti.tstop();  
660 -  
661 // Write parameters into logger 652 // Write parameters into logger
662 log_parameters(TERSE); 653 log_parameters(TERSE);
663 654
@@ -685,7 +676,7 @@ void ctselect::get_parameters(void) @@ -685,7 +676,7 @@ void ctselect::get_parameters(void)
685 * observation is replaced by selected event list read from the FITS file. 676 * observation is replaced by selected event list read from the FITS file.
686 * 677 *
687 * Good Time Intervals of the observation will be limited to the time 678 * Good Time Intervals of the observation will be limited to the time
688 - * interval [m_timemin, m_timemax]. 679 + * interval specified by the User parameters tmin and tmax.
689 ***************************************************************************/ 680 ***************************************************************************/
690 void ctselect::select_events(GCTAObservation* obs, 681 void ctselect::select_events(GCTAObservation* obs,
691 const std::string& filename, 682 const std::string& filename,
@@ -706,6 +697,12 @@ void ctselect::select_events(GCTAObservation* obs, @@ -706,6 +697,12 @@ void ctselect::select_events(GCTAObservation* obs,
706 GCTAEventList* list = 697 GCTAEventList* list =
707 static_cast<GCTAEventList*>(const_cast<GEvents*>(obs->events())); 698 static_cast<GCTAEventList*>(const_cast<GEvents*>(obs->events()));
708 699
  700 + // Get User GTI with MET in the time reference that is specified for the
  701 + // observation
  702 + GGti user_gti = get_gti(list->gti().reference());
  703 + GTime timemin = user_gti.tstart();
  704 + GTime timemax = user_gti.tstop();
  705 +
709 // Get existing Roi and energy bounds for possible later use 706 // Get existing Roi and energy bounds for possible later use
710 // (will be empty if unavailable) 707 // (will be empty if unavailable)
711 GCTARoi old_roi = list->roi(); 708 GCTARoi old_roi = list->roi();
@@ -736,12 +733,12 @@ void ctselect::select_events(GCTAObservation* obs, @@ -736,12 +733,12 @@ void ctselect::select_events(GCTAObservation* obs,
736 // Set time selection interval. We make sure here that the time selection 733 // Set time selection interval. We make sure here that the time selection
737 // interval cannot be wider than the GTIs covering the data. This is done 734 // interval cannot be wider than the GTIs covering the data. This is done
738 // using GGti's reduce() method. 735 // using GGti's reduce() method.
739 - if (!m_gti.is_empty()) { 736 + if (!user_gti.is_empty()) {
740 737
741 // Reduce GTIs to specified time interval. The complicated cast is 738 // Reduce GTIs to specified time interval. The complicated cast is
742 // necessary here because the gti() method is declared const, so 739 // necessary here because the gti() method is declared const, so
743 // we're not officially allowed to modify the GTIs. 740 // we're not officially allowed to modify the GTIs.
744 - ((GGti*)(&list->gti()))->reduce(m_timemin, m_timemax); 741 + ((GGti*)(&list->gti()))->reduce(timemin, timemax);
745 742
746 } // endif: time selection was required 743 } // endif: time selection was required
747 744
@@ -749,7 +746,7 @@ void ctselect::select_events(GCTAObservation* obs, @@ -749,7 +746,7 @@ void ctselect::select_events(GCTAObservation* obs,
749 GGti gti = list->gti(); 746 GGti gti = list->gti();
750 747
751 // Make time selection 748 // Make time selection
752 - if (!m_gti.is_empty()) { 749 + if (!user_gti.is_empty()) {
753 750
754 // If there are no GTIs then request removal of all events 751 // If there are no GTIs then request removal of all events
755 if (list->gti().is_empty()) { 752 if (list->gti().is_empty()) {
src/ctselect/ctselect.hpp
1 /*************************************************************************** 1 /***************************************************************************
2 * ctselect - Data selection tool * 2 * ctselect - Data selection tool *
3 * ----------------------------------------------------------------------- * 3 * ----------------------------------------------------------------------- *
4 - * copyright (C) 2010-2017 by Juergen Knoedlseder * 4 + * copyright (C) 2010-2018 by Juergen Knoedlseder *
5 * ----------------------------------------------------------------------- * 5 * ----------------------------------------------------------------------- *
6 * * 6 * *
7 * This program is free software: you can redistribute it and/or modify * 7 * This program is free software: you can redistribute it and/or modify *
@@ -81,7 +81,7 @@ protected: @@ -81,7 +81,7 @@ protected:
81 81
82 // User parameters 82 // User parameters
83 std::string m_outobs; //!< Output event list or XML file 83 std::string m_outobs; //!< Output event list or XML file
84 - GGti m_gti; //!< Time selection 84 + //GGti m_gti; //!< Time selection
85 double m_emin; //!< Lower energy 85 double m_emin; //!< Lower energy
86 double m_emax; //!< Upper energy 86 double m_emax; //!< Upper energy
87 std::string m_expr; //!< Selection expression 87 std::string m_expr; //!< Selection expression
@@ -92,8 +92,8 @@ protected: @@ -92,8 +92,8 @@ protected:
92 std::vector<std::string> m_infiles; //!< Input event filenames 92 std::vector<std::string> m_infiles; //!< Input event filenames
93 std::vector<std::string> m_evtname; //!< Event extension names 93 std::vector<std::string> m_evtname; //!< Event extension names
94 std::vector<std::string> m_gtiname; //!< GTI extension names 94 std::vector<std::string> m_gtiname; //!< GTI extension names
95 - GTime m_timemin; //!< Earliest time  
96 - GTime m_timemax; //!< Latest time 95 + //GTime m_timemin; //!< Earliest time
  96 + //GTime m_timemax; //!< Latest time
97 GPhases m_phases; //!< Phase intervals 97 GPhases m_phases; //!< Phase intervals
98 bool m_select_energy; //!< Perform energy selection 98 bool m_select_energy; //!< Perform energy selection
99 bool m_select_phase; //!< Perform phase selection 99 bool m_select_phase; //!< Perform phase selection
src/support/ctool.cpp
@@ -751,14 +751,18 @@ GCTAEventCube ctool::create_cube(const GObservations&amp; obs) @@ -751,14 +751,18 @@ GCTAEventCube ctool::create_cube(const GObservations&amp; obs)
751 * 751 *
752 * The following parameters are read 752 * The following parameters are read
753 * 753 *
754 - * ra: Right Ascension of pointing and RoI centre (deg)  
755 - * dec: Declination of pointing and RoI centre (deg)  
756 - * rad: Radius of RoI (deg)  
757 - * deadc: Deadtime correction factor  
758 - * tmin: Start time  
759 - * tmax: Stop time  
760 - * emin: Minimum energy (TeV)  
761 - * emax: Maximum energy (TeV) 754 + * ra: Right Ascension of pointing and RoI centre (deg)
  755 + * dec: Declination of pointing and RoI centre (deg)
  756 + * rad: Radius of RoI (deg)
  757 + * deadc: Deadtime correction factor
  758 + * tmin: Start time
  759 + * tmax: Stop time
  760 + * emin: Minimum energy (TeV)
  761 + * emax: Maximum energy (TeV)
  762 + * mjdref: Time reference (optional)
  763 + *
  764 + * If the time reference parametere "mjdref" is not available, the CTA time
  765 + * reference will be assumed.
762 ***************************************************************************/ 766 ***************************************************************************/
763 GCTAObservation ctool::create_cta_obs(void) 767 GCTAObservation ctool::create_cta_obs(void)
764 { 768 {
@@ -775,8 +779,13 @@ GCTAObservation ctool::create_cta_obs(void) @@ -775,8 +779,13 @@ GCTAObservation ctool::create_cta_obs(void)
775 // Set RoI 779 // Set RoI
776 GCTARoi roi = get_roi(pnt); 780 GCTARoi roi = get_roi(pnt);
777 781
  782 + // Set time reference
  783 + GTimeReference ref = (has_par("mjdref"))
  784 + ? GTimeReference((*this)["mjdref"].real(), "s", "TT", "LOCAL")
  785 + : GTimeReference(G_CTA_MJDREF, "s", "TT", "LOCAL");
  786 +
778 // Set GTI 787 // Set GTI
779 - GGti gti = get_gti(); 788 + GGti gti = get_gti(ref);
780 789
781 // Set energy boundaries 790 // Set energy boundaries
782 GEbounds ebounds = get_ebounds(); 791 GEbounds ebounds = get_ebounds();
@@ -1057,6 +1066,7 @@ GEbounds ctool::get_ebounds(void) @@ -1057,6 +1066,7 @@ GEbounds ctool::get_ebounds(void)
1057 /***********************************************************************//** 1066 /***********************************************************************//**
1058 * @brief Return Good Time Intervals from User parameter 1067 * @brief Return Good Time Intervals from User parameter
1059 * 1068 *
  1069 + * @param[in] ref Time reference.
1060 * @return Good Time Intervals. 1070 * @return Good Time Intervals.
1061 * 1071 *
1062 * Returns Good Time Intervals from the User parameters `tmin` and `tmax`, 1072 * Returns Good Time Intervals from the User parameters `tmin` and `tmax`,
@@ -1064,17 +1074,18 @@ GEbounds ctool::get_ebounds(void) @@ -1064,17 +1074,18 @@ GEbounds ctool::get_ebounds(void)
1064 * If one of `tmin` or `tmax` is not valid, an empty Good Time Interval 1074 * If one of `tmin` or `tmax` is not valid, an empty Good Time Interval
1065 * object is returned. If `tmin` is not valid, `tmax` is not queried. 1075 * object is returned. If `tmin` is not valid, `tmax` is not queried.
1066 ***************************************************************************/ 1076 ***************************************************************************/
1067 -GGti ctool::get_gti(void) 1077 +GGti ctool::get_gti(const GTimeReference& ref)
1068 { 1078 {
1069 - // Initialise Good Time Intervals with CTA reference time  
1070 - GGti gti(ctools::time_reference); 1079 + // Initialise Good Time Intervals with reference time
  1080 + GGti gti(ref);
1071 1081
1072 // Continue only if "tmin" has a valid time value 1082 // Continue only if "tmin" has a valid time value
1073 if ((*this)["tmin"].is_valid() && (*this)["tmax"].is_valid()) { 1083 if ((*this)["tmin"].is_valid() && (*this)["tmax"].is_valid()) {
1074 1084
1075 - // Get minimum and maximum time for CTA time reference  
1076 - GTime tmin = (*this)["tmin"].time(ctools::time_reference);  
1077 - GTime tmax = (*this)["tmax"].time(ctools::time_reference); 1085 + // Get minimum and maximum time using the time reference for MET
  1086 + // times
  1087 + GTime tmin = (*this)["tmin"].time(ref);
  1088 + GTime tmax = (*this)["tmax"].time(ref);
1078 1089
1079 // Append GTI 1090 // Append GTI
1080 gti.append(tmin, tmax); 1091 gti.append(tmin, tmax);
@@ -1630,11 +1641,8 @@ GObservations ctool::get_observations(const bool&amp; get_response) @@ -1630,11 +1641,8 @@ GObservations ctool::get_observations(const bool&amp; get_response)
1630 // and load file into observation 1641 // and load file into observation
1631 if (GFilename(filename).is_fits()) { 1642 if (GFilename(filename).is_fits()) {
1632 1643
1633 - // Allocate empty CTA observation  
1634 - GCTAObservation cta_obs;  
1635 -  
1636 - // Load data  
1637 - cta_obs.load(filename); 1644 + // Load CTA observation
  1645 + GCTAObservation cta_obs(filename);
1638 1646
1639 // Get response if required 1647 // Get response if required
1640 if (get_response) { 1648 if (get_response) {
src/support/ctool.hpp
@@ -34,10 +34,6 @@ @@ -34,10 +34,6 @@
34 /* __Definitions _________________________________________________________ */ 34 /* __Definitions _________________________________________________________ */
35 35
36 /* __ Constants __________________________________________________________ */ 36 /* __ Constants __________________________________________________________ */
37 -namespace ctools {  
38 - const GTimeReference time_reference =  
39 - GTimeReference(G_CTA_MJDREF, "s", "TT", "LOCAL");  
40 -}  
41 37
42 38
43 /***********************************************************************//** 39 /***********************************************************************//**
@@ -102,7 +98,7 @@ protected: @@ -102,7 +98,7 @@ protected:
102 // Protected methods that extract user parameters 98 // Protected methods that extract user parameters
103 GCTARoi get_roi(const GCTAPointing& pnt = GCTAPointing()); 99 GCTARoi get_roi(const GCTAPointing& pnt = GCTAPointing());
104 GEbounds get_ebounds(void); 100 GEbounds get_ebounds(void);
105 - GGti get_gti(void); 101 + GGti get_gti(const GTimeReference& ref);
106 GCTAPointing get_pointing(void); 102 GCTAPointing get_pointing(void);
107 GSkyDir get_skydir(void); 103 GSkyDir get_skydir(void);
108 std::string set_outfile_name(const std::string& filename); 104 std::string set_outfile_name(const std::string& filename);