Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up Observations.select_time #2580

Merged
merged 4 commits into from Nov 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions gammapy/data/observations.py
Expand Up @@ -340,9 +340,10 @@ def select_time(self, time_interval):
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.gti.table) > 0:
if (obs.tstart < time_interval[1]) & (obs.tstop > time_interval[0]):
new_obs = obs.select_time(time_interval)
new_obs_list.append(new_obs)

return self.__class__(new_obs_list)
Expand Down