Commit c78029adbea71c1e18549f501398374c4967ef7c

Authored by Jürgen Knödlseder
1 parent 276c2fb9

Correct csobsselect time selection

Showing 1 changed file with 7 additions and 6 deletions
cscripts/csobsselect.py
@@ -136,7 +136,9 @@ class csobsselect(ctools.csobservation): @@ -136,7 +136,9 @@ class csobsselect(ctools.csobservation):
136 if obs.classname() == 'GCTAObservation': 136 if obs.classname() == 'GCTAObservation':
137 137
138 # Get observation start and stop time 138 # Get observation start and stop time
139 - obs_gti = obs.gti() 139 + obs_gti = obs.gti()
  140 + obs_tstart = obs_gti.tstart()
  141 + obs_tstop = obs_gti.tstop()
140 142
141 # Get User start and stop time in the time reference of the CTA 143 # Get User start and stop time in the time reference of the CTA
142 # observations 144 # observations
@@ -144,11 +146,10 @@ class csobsselect(ctools.csobservation): @@ -144,11 +146,10 @@ class csobsselect(ctools.csobservation):
144 tstart = gti.tstart() 146 tstart = gti.tstart()
145 tstop = gti.tstop() 147 tstop = gti.tstop()
146 148
147 - # If there is a valid User start and stop time and if that start  
148 - # or stop time is not within the observation GTI, then skip the  
149 - # observation  
150 - if gti.size() > 0 and not obs_gti.contains(tstart) and \  
151 - not obs_gti.contains(tstop): 149 + # If there is a valid User start and stop time and the observation
  150 + # stop is before the start time or the observation start after the
  151 + # stop time, then skip the observation
  152 + if gti.size() > 0 and (obs_tstop < tstart or obs_tstart > tstop):
152 self._log_selection(obs, 'outside time interval') 153 self._log_selection(obs, 'outside time interval')
153 154
154 # ... otherwise select spatially 155 # ... otherwise select spatially