Commit a62402b6181b0602898e7f31f831824a2fa191d1
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
Showing
28 changed files
with
170 additions
and
103 deletions
ChangeLog
| 1 | -2018-06-12 | |
| 1 | +2018-06-13 | |
| 2 | 2 | |
| 3 | 3 | * Version 1.6.0 released |
| 4 | 4 | ======================== |
| ... | ... | @@ -12,6 +12,8 @@ |
| 12 | 12 | Allow specifying of input sky map in ctskymap (#2311) |
| 13 | 13 | Add ras() and decs() methods to csobsinfo (#2313) |
| 14 | 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 | 19 | 2018-04-26 | ... | ... |
NEWS
| 1 | 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 | 6 | Introduction |
| ... | ... | @@ -26,13 +26,25 @@ None |
| 26 | 26 | |
| 27 | 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 | 41 | The ctools::is_valid_filename() method was removed since the validity check |
| 30 | 42 | of the filename is now done by the GApplicationPar class. |
| 31 | 43 | |
| 32 | 44 | |
| 33 | 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 | 50 | ctbkgcube - CTA background cube generation |
| ... | ... | @@ -82,7 +94,8 @@ None |
| 82 | 94 | |
| 83 | 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 | 101 | ctphase - Event phase computation |
| ... | ... | @@ -102,7 +115,8 @@ None |
| 102 | 115 | |
| 103 | 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 | 122 | ctskymap - CTA sky mapping |
| ... | ... | @@ -172,7 +186,8 @@ None |
| 172 | 186 | |
| 173 | 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 | 193 | csmodelinfo - Return model information |
| ... | ... | @@ -202,7 +217,8 @@ None |
| 202 | 217 | |
| 203 | 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 | 224 | csobsinfo - Return observation definition information |
| ... | ... | @@ -212,7 +228,8 @@ Add ras() and decs() methods (#2313) |
| 212 | 228 | |
| 213 | 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 | 235 | csphagen - Generate On/Off observations |
| ... | ... | @@ -233,7 +250,8 @@ None |
| 233 | 250 | |
| 234 | 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 | 257 | csresmap - Generate residual map |
| ... | ... | @@ -284,7 +302,8 @@ None |
| 284 | 302 | |
| 285 | 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 | 309 | csworkflow - Execute workflow |
| ... | ... | @@ -309,7 +328,7 @@ None |
| 309 | 328 | |
| 310 | 329 | obsutils - Observation utilities |
| 311 | 330 | -------------------------------- |
| 312 | -None | |
| 331 | +Add "mjdref" parameter to set_obs() function (#2054). | |
| 313 | 332 | |
| 314 | 333 | |
| 315 | 334 | Examples | ... | ... |
cscripts/cslightcrv.par
| ... | ... | @@ -31,6 +31,7 @@ outfile, f, a, lightcurve.fits,,, "Output light curve file" |
| 31 | 31 | tbinalg, s, a, GTI,FILE|LIN|GTI,, "Algorithm for defining time bins" |
| 32 | 32 | tmin, t, a, MJD 51544.5,,,"Lightcurve start time (UTC string, JD, MJD or MET in seconds)" |
| 33 | 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 | 35 | tbins, i, a, 5,1,10000, "Number of time bins" |
| 35 | 36 | tbinfile, f, a, NONE,,, "File defining the time binning" |
| 36 | 37 | method, s, a, 3D, 3D|ONOFF,, "Analysis method" | ... | ... |
cscripts/cslightcrv.py
| ... | ... | @@ -137,8 +137,11 @@ class cslightcrv(ctools.csobservation): |
| 137 | 137 | gti : `~gammalib.GGti` |
| 138 | 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 | 143 | # Initialise Good Time Intervals |
| 141 | - gti = gammalib.GGti() | |
| 144 | + gti = gammalib.GGti(tref) | |
| 142 | 145 | |
| 143 | 146 | # Get algorithm to use for defining the time intervals. Possible |
| 144 | 147 | # values are "FILE", "LIN" and "GTI". This is enforced at |
| ... | ... | @@ -173,8 +176,8 @@ class cslightcrv(ctools.csobservation): |
| 173 | 176 | elif algorithm == 'LIN': |
| 174 | 177 | |
| 175 | 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 | 181 | nbins = self['tbins'].integer() |
| 179 | 182 | |
| 180 | 183 | # Compute time step in seconds and setup the GTIs |
| ... | ... | @@ -385,8 +388,8 @@ class cslightcrv(ctools.csobservation): |
| 385 | 388 | select = ctools.ctselect(self.obs()) |
| 386 | 389 | select['emin'] = self['emin'].real() |
| 387 | 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 | 393 | select['rad'] = 'UNDEFINED' |
| 391 | 394 | select['ra'] = 'UNDEFINED' |
| 392 | 395 | select['dec'] = 'UNDEFINED' |
| ... | ... | @@ -444,8 +447,8 @@ class cslightcrv(ctools.csobservation): |
| 444 | 447 | select = ctools.ctselect(self.obs()) |
| 445 | 448 | select['emin'] = self['emin'].real() |
| 446 | 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 | 452 | select['rad'] = 'UNDEFINED' |
| 450 | 453 | select['ra'] = 'UNDEFINED' |
| 451 | 454 | select['dec'] = 'UNDEFINED' | ... | ... |
cscripts/csobsdef.par
| ... | ... | @@ -30,6 +30,7 @@ emin, r, h, UNDEF,,, "Lower energy limit (TeV)" |
| 30 | 30 | emax, r, h, UNDEF,,, "Upper energy limit (TeV)" |
| 31 | 31 | rad, r, h, UNDEF,,, "Radius of ROI (degrees)" |
| 32 | 32 | deadc, r, h, 0.98,,, "Deadtime correction factor" |
| 33 | +mjdref, r, h, 51544.5,,, "Reference MJD for observations" | |
| 33 | 34 | |
| 34 | 35 | # |
| 35 | 36 | # Standard parameters | ... | ... |
cscripts/csobsdef.py
| ... | ... | @@ -272,11 +272,12 @@ class csobsdef(ctools.cscript): |
| 272 | 272 | duration = float(self._pntdef[row, header.index('duration')]) |
| 273 | 273 | else: |
| 274 | 274 | duration = self['duration'].real() |
| 275 | + tref = gammalib.GTimeReference(self['mjdref'].real(),'s') | |
| 275 | 276 | tmin = self._tmin |
| 276 | 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 | 281 | self._tmin = tmax |
| 281 | 282 | gti.append(tstart, tstop) |
| 282 | 283 | obs.ontime(gti.ontime()) | ... | ... |
cscripts/csobsinfo.py
| ... | ... | @@ -289,10 +289,11 @@ class csobsinfo(ctools.csobservation): |
| 289 | 289 | self._log_value(gammalib.NORMAL, 'Maximum energy', max_value) |
| 290 | 290 | |
| 291 | 291 | # Log time range |
| 292 | + ref = obs.gti().reference() | |
| 292 | 293 | mjd = '%.3f - %.3f' % (self._gti.tstart().mjd(), self._gti.tstop().mjd()) |
| 293 | 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 | 297 | self._log_header3(gammalib.NORMAL, 'Time range') |
| 297 | 298 | self._log_value(gammalib.NORMAL, 'MJD (days)', mjd) |
| 298 | 299 | self._log_value(gammalib.NORMAL, 'UTC', utc) | ... | ... |
cscripts/csobsselect.py
| ... | ... | @@ -68,8 +68,10 @@ class csobsselect(ctools.csobservation): |
| 68 | 68 | self['width'].real() |
| 69 | 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 | 76 | # Query ahead output model filename |
| 75 | 77 | if self._read_ahead(): |
| ... | ... | @@ -113,7 +115,7 @@ class csobsselect(ctools.csobservation): |
| 113 | 115 | # Return |
| 114 | 116 | return |
| 115 | 117 | |
| 116 | - def _select_observation(self, obs, gti): | |
| 118 | + def _select_observation(self, obs): | |
| 117 | 119 | """ |
| 118 | 120 | Select observation |
| 119 | 121 | |
| ... | ... | @@ -121,8 +123,6 @@ class csobsselect(ctools.csobservation): |
| 121 | 123 | ---------- |
| 122 | 124 | obs : `~gammalib.GObservation` |
| 123 | 125 | Observation |
| 124 | - gti : `~gammalib.GGti` | |
| 125 | - Good time intervals | |
| 126 | 126 | |
| 127 | 127 | Returns |
| 128 | 128 | ------- |
| ... | ... | @@ -140,6 +140,10 @@ class csobsselect(ctools.csobservation): |
| 140 | 140 | tstart = obs_gti.tstart() |
| 141 | 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 | 147 | # If the observation is not within the time selection then skip it |
| 144 | 148 | if gti.size() > 0 and not gti.contains(tstart) and \ |
| 145 | 149 | not gti.contains(tstop): |
| ... | ... | @@ -294,9 +298,6 @@ class csobsselect(ctools.csobservation): |
| 294 | 298 | # Get parameters |
| 295 | 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 | 301 | # Initialise empty observation container for selected observations |
| 301 | 302 | selected_obs = gammalib.GObservations() |
| 302 | 303 | |
| ... | ... | @@ -310,7 +311,7 @@ class csobsselect(ctools.csobservation): |
| 310 | 311 | for obs in self.obs(): |
| 311 | 312 | |
| 312 | 313 | # If observation is selected then append observation |
| 313 | - if self._select_observation(obs, gti): | |
| 314 | + if self._select_observation(obs): | |
| 314 | 315 | selected_obs.append(obs) |
| 315 | 316 | |
| 316 | 317 | # Copy selected observations into observation | ... | ... |
cscripts/cspull.par
| ... | ... | @@ -40,6 +40,7 @@ emax, r, a, 100.0,,, "Upper energy limit (TeV)" |
| 40 | 40 | enumbins, i, a, 0,,, "Number of energy bins (0=unbinned)" |
| 41 | 41 | tmin, t, a, 2020-01-01T00:00:00,,, "Start time (UTC string, JD, MJD or MET in seconds)" |
| 42 | 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 | 44 | npix, i, a, 200,,, "Number of pixels for binned" |
| 44 | 45 | binsz, r, a, 0.05,,, "Pixel size for binned (degrees/pixel)" |
| 45 | 46 | statistic, s, h, DEFAULT,DEFAULT|CSTAT|WSTAT|CHI2,, "Optimization statistic" | ... | ... |
cscripts/csviscube.par
| ... | ... | @@ -18,6 +18,7 @@ |
| 18 | 18 | #=================== |
| 19 | 19 | tmin, t, a, 2020-01-01T00:00:00,,, "Start time of observation (UTC string, JD, MJD or MET in seconds)" |
| 20 | 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 | 22 | geolon, r, a, 79.4041,,, "Geographic longitude of array (deg)" |
| 22 | 23 | geolat, r, a, -24.6272,,, "Geographic latitude of array (deg)" |
| 23 | 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 | 64 | Get all parameters |
| 65 | 65 | """ |
| 66 | 66 | # Query parameters |
| 67 | + self['mjdref'].real() | |
| 67 | 68 | self['tmin'].time() |
| 68 | 69 | self['tmax'].time() |
| 69 | 70 | self['geolon'].real() |
| ... | ... | @@ -259,9 +260,12 @@ class csviscube(ctools.cscript): |
| 259 | 260 | # Get array geographic longitude |
| 260 | 261 | #geolon = self['geolon'].real() |
| 261 | 262 | |
| 263 | + # Get MET time reference | |
| 264 | + tref = gammalib.GTimeReference(self['mjdref'].real(),'s','TT','LOCAL') | |
| 265 | + | |
| 262 | 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 | 270 | # Initialise hour angle list |
| 267 | 271 | hour_angles = [] | ... | ... |
cscripts/obsutils.py
| ... | ... | @@ -224,7 +224,7 @@ def sim(obs, log=False, debug=False, chatter=2, edisp=False, seed=0, |
| 224 | 224 | # ======================= # |
| 225 | 225 | def set_obs(pntdir, tstart=0.0, duration=1800.0, deadc=0.98, \ |
| 226 | 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 | 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 | 283 | roi.radius(rad) |
| 284 | 284 | |
| 285 | 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 | 291 | # Set energy boundaries |
| 291 | 292 | ebounds = gammalib.GEbounds(gammalib.GEnergy(emin, 'TeV'), | ... | ... |
doc/source/admin/release_history/1.6.rst
| ... | ... | @@ -36,6 +36,9 @@ Improvements |
| 36 | 36 | Allow specifying of input skymap to :ref:`ctskymap` tool |
| 37 | 37 | * [`2309 <https://cta-redmine.irap.omp.eu/issues/2309>`_] - |
| 38 | 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 | 44 | New features |
| ... | ... | @@ -48,3 +51,5 @@ Clean up |
| 48 | 51 | -------- |
| 49 | 52 | |
| 50 | 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 | 77 | ``tmax [time]`` |
| 78 | 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 | 83 | ``tbins [integer]`` |
| 81 | 84 | Number of time bins. |
| 82 | 85 | ... | ... |
doc/source/users/reference_manual/csobsdef.rst
doc/source/users/reference_manual/csobsselect.rst
| ... | ... | @@ -52,12 +52,16 @@ General parameters |
| 52 | 52 | Height of selection box (degrees). |
| 53 | 53 | |
| 54 | 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 | 58 | If ``INDEF``, ``NONE``, ``UNDEF`` or ``UNDEFINED`` is passed as value, no time |
| 57 | 59 | selection will be performed. |
| 58 | 60 | |
| 59 | 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 | 65 | If ``INDEF``, ``NONE``, ``UNDEF`` or ``UNDEFINED`` is passed as value, no time |
| 62 | 66 | selection will be performed. |
| 63 | 67 | ... | ... |
doc/source/users/reference_manual/cspull.rst
| ... | ... | @@ -106,6 +106,9 @@ General parameters |
| 106 | 106 | ``tmax [time]`` |
| 107 | 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 | 112 | ``npix [integer]`` |
| 110 | 113 | Number of pixels for binned analysis. |
| 111 | 114 | ... | ... |
doc/source/users/reference_manual/csviscube.rst
| ... | ... | @@ -30,6 +30,9 @@ General parameters |
| 30 | 30 | ``tmax [time]`` |
| 31 | 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 | 36 | ``geolon [real]`` |
| 34 | 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 | 89 | ``tmax [time]`` |
| 90 | 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 | 96 | ``emin [real]`` |
| 93 | 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 | 66 | selection will be performed. |
| 67 | 67 | |
| 68 | 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 | 72 | If ``INDEF``, ``NONE``, ``UNDEF`` or ``UNDEFINED`` is passed as value, no time |
| 71 | 73 | selection will be performed. |
| 72 | 74 | |
| 73 | 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 | 79 | If ``INDEF``, ``NONE``, ``UNDEF`` or ``UNDEFINED`` is passed as value, no time |
| 76 | 80 | selection will be performed. |
| 77 | 81 | ... | ... |
pyext/ctool.i
| ... | ... | @@ -57,10 +57,6 @@ public: |
| 57 | 57 | %include "argcargv.i" |
| 58 | 58 | |
| 59 | 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 | 138 | // Protected methods that extract user parameters |
| 143 | 139 | GCTARoi get_roi(const GCTAPointing& pnt = GCTAPointing()); |
| 144 | 140 | GEbounds get_ebounds(void); |
| 145 | - GGti get_gti(void); | |
| 141 | + GGti get_gti(const GTimeReference& ref); | |
| 146 | 142 | GCTAPointing get_pointing(void); |
| 147 | 143 | GSkyDir get_skydir(void); |
| 148 | 144 | std::string set_outfile_name(const std::string& filename); | ... | ... |
src/ctbin/ctbin.cpp
| ... | ... | @@ -385,9 +385,6 @@ void ctbin::init_members(void) |
| 385 | 385 | // Initialise cache members |
| 386 | 386 | m_dirs.clear(); |
| 387 | 387 | |
| 388 | - // Set CTA reference time | |
| 389 | - m_gti.reference(ctools::time_reference); | |
| 390 | - | |
| 391 | 388 | // Return |
| 392 | 389 | return; |
| 393 | 390 | } |
| ... | ... | @@ -586,6 +583,12 @@ void ctbin::fill_cube(GCTAObservation* obs) |
| 586 | 583 | // Update time information |
| 587 | 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 | 592 | // Append GTIs |
| 590 | 593 | m_gti.extend(events->gti()); |
| 591 | 594 | ... | ... |
src/ctobssim/ctobssim.cpp
| ... | ... | @@ -784,9 +784,10 @@ void ctobssim::simulate_source(GCTAObservation* obs, |
| 784 | 784 | // Loop over all Good Time Intervals |
| 785 | 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 | 792 | // Log time interval. Increment indentation if there are |
| 792 | 793 | // several Good Time Intervals. |
| ... | ... | @@ -796,9 +797,9 @@ void ctobssim::simulate_source(GCTAObservation* obs, |
| 796 | 797 | wrklog->indent(indent); |
| 797 | 798 | } |
| 798 | 799 | *wrklog << gammalib::parformat("Time interval", indent); |
| 799 | - *wrklog << tmin.convert(ctools::time_reference); | |
| 800 | + *wrklog << tmin.convert(tref); | |
| 800 | 801 | *wrklog << " - "; |
| 801 | - *wrklog << tmax.convert(ctools::time_reference); | |
| 802 | + *wrklog << tmax.convert(tref); | |
| 802 | 803 | *wrklog << " s" << std::endl; |
| 803 | 804 | } |
| 804 | 805 | |
| ... | ... | @@ -1063,8 +1064,8 @@ void ctobssim::simulate_interval(GCTAObservation* obs, |
| 1063 | 1064 | wrklog->indent(indent); |
| 1064 | 1065 | } |
| 1065 | 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 | 1069 | if (model->name().length() > 0) { |
| 1069 | 1070 | *wrklog << " [" << model->name() << "]"; |
| 1070 | 1071 | } | ... | ... |
src/ctobssim/ctobssim.par
| ... | ... | @@ -34,6 +34,7 @@ dec, r, a, 22.51,-90,90, "Dec of pointing (degrees)" |
| 34 | 34 | rad, r, a, 5.0,0,180, "Radius of FOV (degrees)" |
| 35 | 35 | tmin, t, a, 2020-01-01T00:00:00,,, "Start time (UTC string, JD, MJD or MET in seconds)" |
| 36 | 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 | 38 | emin, r, a, 0.1,,, "Lower energy limit (TeV)" |
| 38 | 39 | emax, r, a, 100.0,,, "Upper energy limit (TeV)" |
| 39 | 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 | 465 | { |
| 466 | 466 | // Initialise parameters |
| 467 | 467 | m_outobs.clear(); |
| 468 | - m_gti.clear(); | |
| 469 | 468 | m_emin = 0.0; |
| 470 | 469 | m_emax = 0.0; |
| 471 | 470 | m_expr.clear(); |
| ... | ... | @@ -476,8 +475,6 @@ void ctselect::init_members(void) |
| 476 | 475 | m_infiles.clear(); |
| 477 | 476 | m_evtname.clear(); |
| 478 | 477 | m_gtiname.clear(); |
| 479 | - m_timemin.clear(); | |
| 480 | - m_timemax.clear(); | |
| 481 | 478 | m_phases.clear(); |
| 482 | 479 | m_select_energy = false; |
| 483 | 480 | m_select_phase = false; |
| ... | ... | @@ -496,7 +493,6 @@ void ctselect::copy_members(const ctselect& app) |
| 496 | 493 | { |
| 497 | 494 | // Copy parameters |
| 498 | 495 | m_outobs = app.m_outobs; |
| 499 | - m_gti = app.m_gti; | |
| 500 | 496 | m_emin = app.m_emin; |
| 501 | 497 | m_emax = app.m_emax; |
| 502 | 498 | m_expr = app.m_expr; |
| ... | ... | @@ -507,8 +503,6 @@ void ctselect::copy_members(const ctselect& app) |
| 507 | 503 | m_infiles = app.m_infiles; |
| 508 | 504 | m_evtname = app.m_evtname; |
| 509 | 505 | m_gtiname = app.m_gtiname; |
| 510 | - m_timemin = app.m_timemin; | |
| 511 | - m_timemax = app.m_timemax; | |
| 512 | 506 | m_phases = app.m_phases; |
| 513 | 507 | m_select_energy = app.m_select_energy; |
| 514 | 508 | m_select_phase = app.m_select_phase; |
| ... | ... | @@ -555,8 +549,10 @@ void ctselect::get_parameters(void) |
| 555 | 549 | GCTAPointing pnt; |
| 556 | 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 | 557 | // Get energy selection parameters |
| 562 | 558 | if ((*this)["emin"].is_valid() && (*this)["emax"].is_valid()) { |
| ... | ... | @@ -653,11 +649,6 @@ void ctselect::get_parameters(void) |
| 653 | 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 | 652 | // Write parameters into logger |
| 662 | 653 | log_parameters(TERSE); |
| 663 | 654 | |
| ... | ... | @@ -685,7 +676,7 @@ void ctselect::get_parameters(void) |
| 685 | 676 | * observation is replaced by selected event list read from the FITS file. |
| 686 | 677 | * |
| 687 | 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 | 681 | void ctselect::select_events(GCTAObservation* obs, |
| 691 | 682 | const std::string& filename, |
| ... | ... | @@ -706,6 +697,12 @@ void ctselect::select_events(GCTAObservation* obs, |
| 706 | 697 | GCTAEventList* list = |
| 707 | 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 | 706 | // Get existing Roi and energy bounds for possible later use |
| 710 | 707 | // (will be empty if unavailable) |
| 711 | 708 | GCTARoi old_roi = list->roi(); |
| ... | ... | @@ -736,12 +733,12 @@ void ctselect::select_events(GCTAObservation* obs, |
| 736 | 733 | // Set time selection interval. We make sure here that the time selection |
| 737 | 734 | // interval cannot be wider than the GTIs covering the data. This is done |
| 738 | 735 | // using GGti's reduce() method. |
| 739 | - if (!m_gti.is_empty()) { | |
| 736 | + if (!user_gti.is_empty()) { | |
| 740 | 737 | |
| 741 | 738 | // Reduce GTIs to specified time interval. The complicated cast is |
| 742 | 739 | // necessary here because the gti() method is declared const, so |
| 743 | 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 | 743 | } // endif: time selection was required |
| 747 | 744 | |
| ... | ... | @@ -749,7 +746,7 @@ void ctselect::select_events(GCTAObservation* obs, |
| 749 | 746 | GGti gti = list->gti(); |
| 750 | 747 | |
| 751 | 748 | // Make time selection |
| 752 | - if (!m_gti.is_empty()) { | |
| 749 | + if (!user_gti.is_empty()) { | |
| 753 | 750 | |
| 754 | 751 | // If there are no GTIs then request removal of all events |
| 755 | 752 | if (list->gti().is_empty()) { | ... | ... |
src/ctselect/ctselect.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 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 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -81,7 +81,7 @@ protected: |
| 81 | 81 | |
| 82 | 82 | // User parameters |
| 83 | 83 | std::string m_outobs; //!< Output event list or XML file |
| 84 | - GGti m_gti; //!< Time selection | |
| 84 | + //GGti m_gti; //!< Time selection | |
| 85 | 85 | double m_emin; //!< Lower energy |
| 86 | 86 | double m_emax; //!< Upper energy |
| 87 | 87 | std::string m_expr; //!< Selection expression |
| ... | ... | @@ -92,8 +92,8 @@ protected: |
| 92 | 92 | std::vector<std::string> m_infiles; //!< Input event filenames |
| 93 | 93 | std::vector<std::string> m_evtname; //!< Event extension names |
| 94 | 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 | 97 | GPhases m_phases; //!< Phase intervals |
| 98 | 98 | bool m_select_energy; //!< Perform energy selection |
| 99 | 99 | bool m_select_phase; //!< Perform phase selection | ... | ... |
src/support/ctool.cpp
| ... | ... | @@ -751,14 +751,18 @@ GCTAEventCube ctool::create_cube(const GObservations& obs) |
| 751 | 751 | * |
| 752 | 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 | 767 | GCTAObservation ctool::create_cta_obs(void) |
| 764 | 768 | { |
| ... | ... | @@ -775,8 +779,13 @@ GCTAObservation ctool::create_cta_obs(void) |
| 775 | 779 | // Set RoI |
| 776 | 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 | 787 | // Set GTI |
| 779 | - GGti gti = get_gti(); | |
| 788 | + GGti gti = get_gti(ref); | |
| 780 | 789 | |
| 781 | 790 | // Set energy boundaries |
| 782 | 791 | GEbounds ebounds = get_ebounds(); |
| ... | ... | @@ -1057,6 +1066,7 @@ GEbounds ctool::get_ebounds(void) |
| 1057 | 1066 | /***********************************************************************//** |
| 1058 | 1067 | * @brief Return Good Time Intervals from User parameter |
| 1059 | 1068 | * |
| 1069 | + * @param[in] ref Time reference. | |
| 1060 | 1070 | * @return Good Time Intervals. |
| 1061 | 1071 | * |
| 1062 | 1072 | * Returns Good Time Intervals from the User parameters `tmin` and `tmax`, |
| ... | ... | @@ -1064,17 +1074,18 @@ GEbounds ctool::get_ebounds(void) |
| 1064 | 1074 | * If one of `tmin` or `tmax` is not valid, an empty Good Time Interval |
| 1065 | 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 | 1082 | // Continue only if "tmin" has a valid time value |
| 1073 | 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 | 1090 | // Append GTI |
| 1080 | 1091 | gti.append(tmin, tmax); |
| ... | ... | @@ -1630,11 +1641,8 @@ GObservations ctool::get_observations(const bool& get_response) |
| 1630 | 1641 | // and load file into observation |
| 1631 | 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 | 1647 | // Get response if required |
| 1640 | 1648 | if (get_response) { | ... | ... |
src/support/ctool.hpp
| ... | ... | @@ -34,10 +34,6 @@ |
| 34 | 34 | /* __Definitions _________________________________________________________ */ |
| 35 | 35 | |
| 36 | 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 | 98 | // Protected methods that extract user parameters |
| 103 | 99 | GCTARoi get_roi(const GCTAPointing& pnt = GCTAPointing()); |
| 104 | 100 | GEbounds get_ebounds(void); |
| 105 | - GGti get_gti(void); | |
| 101 | + GGti get_gti(const GTimeReference& ref); | |
| 106 | 102 | GCTAPointing get_pointing(void); |
| 107 | 103 | GSkyDir get_skydir(void); |
| 108 | 104 | std::string set_outfile_name(const std::string& filename); | ... | ... |