Skip to content

Commit

Permalink
assume existence of t_obs key
Browse files Browse the repository at this point in the history
  • Loading branch information
wtbarnes committed Sep 23, 2024
1 parent 1c14d4e commit 90412d9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
12 changes: 3 additions & 9 deletions aiapy/calibrate/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,10 @@ def update_pointing(smap, *, pointing_table=None):
# NOTE: For SDO data, T_OBS is preferred to DATE-OBS in the case of the
# MPT, using DATE-OBS from near the slot boundary might result in selecting
# an incorrect MPT record.
# FIXME: Beginning in sunpy v6.0.0, AIA maps use T_OBS as the reference date
# As such, once that is the min version supported, the following lines should
# be adjusted to just use smap.reference_date
t_obs = smap.meta.get("T_OBS")
if t_obs is None:
warnings.warn(
"T_OBS key is missing from metadata. Falling back to Map.date. "
"This may result in selecting in incorrect record from the "
"master pointing table.",
AiapyUserWarning,
stacklevel=3,
)
t_obs = smap.date
t_obs = astropy.time.Time(t_obs)
t_obs_in_interval = np.logical_and(t_obs >= pointing_table["T_START"], t_obs < pointing_table["T_STOP"])
if not t_obs_in_interval.any():
Expand Down
9 changes: 0 additions & 9 deletions aiapy/calibrate/tests/test_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,6 @@ def test_update_pointing_accuracy(aia_171_map, pointing_table, t_delt_factor, ex
assert aia_map_updated.reference_pixel.y == pointing_table[expected_entry]["A_171_Y0"]


@pytest.mark.skip() # Because sunpy pulls reference_date from T_OBS, this test will always fail. Maybe remove?
@pytest.mark.remote_data()
def test_update_pointing_missing_tobs_raises_warning(aia_171_map, pointing_table):
# Tests that a warning is raised if T_OBS is not present.
aia_171_map.meta.pop("T_OBS")
with pytest.warns(AiapyUserWarning, match="T_OBS key is missing from metadata."):
update_pointing(aia_171_map, pointing_table=pointing_table)


@pytest.mark.remote_data()
def test_update_pointing_submap_raises_exception(aia_171_map, pointing_table):
m = aia_171_map.submap(
Expand Down

0 comments on commit 90412d9

Please sign in to comment.