-
Notifications
You must be signed in to change notification settings - Fork 194
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
Take observation time from GTI table #1908
Changes from 5 commits
5581e73
8ddb42b
edf1ebb
8c00dd9
06e5b97
0baba77
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,11 +8,7 @@ | |
from ...data import DataStore, EventList, GTI, ObservationCTA | ||
from ...irf import EffectiveAreaTable2D, EnergyDispersion2D, PSF3D | ||
from ...utils.testing import requires_data | ||
from ...utils.testing import ( | ||
assert_quantity_allclose, | ||
assert_time_allclose, | ||
assert_skycoord_allclose, | ||
) | ||
from ...utils.testing import assert_time_allclose, assert_skycoord_allclose | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
|
@@ -38,6 +34,26 @@ def test_data_store_observation(data_store): | |
assert_skycoord_allclose(obs.target_radec, c) | ||
|
||
|
||
@requires_data("gammapy-extra") | ||
def test_missing_gti(data_store): | ||
"""This tests the case when a GTI table is missing in the HDU index file. | ||
|
||
For backward compatibility we create a GTI table on-the-fly by means of the Obs Index file | ||
TODO: This method can be removed once GTI tables are explicitly required in Gammapy. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dcfidalgo - I'll remove this test already now. I've had very bad experiences with tests that modify fixture objects, and then depending on test execution order other tests broke and it was very hard to debug. I also don't like to have such complex tests where state is backed up and restored. |
||
""" | ||
obs = data_store.obs(20136) | ||
hdu_bkp = data_store.hdu_table.copy() | ||
# remove the row with the GTI file location for obs_id 20136 | ||
data_store.hdu_table.remove_row(1) | ||
|
||
try: | ||
gti = obs.gti | ||
finally: | ||
data_store.hdu_table = hdu_bkp | ||
|
||
assert type(gti) == GTI | ||
|
||
|
||
@requires_data("gammapy-extra") | ||
def test_data_store_observation_to_observation_cta(data_store): | ||
"""Test the DataStoreObservation.to_observation_cta conversion method""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think an
astype("float64")
here can be helpful; the spec says it should be 64-bit, and if it isn't going 32 -> 64 at this point doesn't help, if the precision is already low, the result will be the same.I'll do a small edit here to ensure the unit in the GTI table is "s". It should already be in the obs table, but given that you hardcode
self.meta.get("TIMEUNIT", "s")
above, I think it's a little less error-prone to also go to "s" for the value here.