add `select_time` to `Observations`
@@ -282,6 +282,28 @@ class Observations(object):
s += str(obs)
return s
+ def select_time(self, time_interval):
+ """Select a time interval of the observations.
+
+ Parameter
+ =========
+ time_interval : `astropy.time.Time`
+ Start and stop time of the selected time interval. For now we only support a single time interval.
+
+ Returns
+ =======
+ new_observations : `~gammapy.data.Observations`
+ A new observations instance of the specified time interval
+
+ """
+ new_obs_list = []
+ for obs in self:
+ new_obs = obs.select_time(time_interval)
+ if len(new_obs.events.table) > 0:
+ new_obs_list.append(new_obs)
+
+ return self.__class__(new_obs_list)
+
class ObservationChecker(Checker):
"""Check an observation.
