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

Prioritize date_start when defining WCS and coordinate frame #98

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions eispac/core/eismap.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,20 @@ def date_average(self):
return self._get_date('date_avg') or super().date_average

@property
def date(self):
# NOTE: we override this property to prioritize date_average
# over DATE-OBS (or DATE_OBS). In GenericMap, this is reversed.
# We do this because we want to make sure we are constructing our
# coordinate frames from DATE_AVG (the midpoint of the raster) and
# not DATE-OBS which is the beginning of the raster.
return self.date_average or super().date
def reference_date(self):
"""
The reference date for the coordinate system

According to Section 2.4 of
`EIS Software Note 9 <https://solarb.mssl.ucl.ac.uk/SolarB/eis_docs/eis_notes/09_POINTING/eis_swnote_09.pdf>`_,
the pointing keywords are defined at the start of the raster. As such, this property returns the
time at the beginning of the raster.

.. note:: This property is overridden because `sunpy.map.GenericMap` sets
this to be the ``.date_average`` which in this case is the midpoint
of the raster.
Comment on lines +138 to +140
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this the syntax for this?

Suggested change
.. note:: This property is overridden because `sunpy.map.GenericMap` sets
this to be the ``.date_average`` which in this case is the midpoint
of the raster.
.. note::
This property is overridden because `sunpy.map.GenericMap` sets
this to be the ``.date_average`` which in this case is the midpoint
of the raster.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe either works

"""
return self.date_start

@classmethod
def is_datasource_for(cls, data, header, **kwargs):
Expand Down
38 changes: 13 additions & 25 deletions eispac/tests/test_eismap.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
Tests for `eispac.EISMap`
"""
import copy
from textwrap import dedent

import numpy as np
Expand Down Expand Up @@ -104,30 +103,19 @@ def test_date_props(test_eis_map, attr, key):
assert getattr(test_eis_map, attr).isot == test_eis_map.meta[key]


def test_date(test_eis_map, test_header):
# Case 1: date-average exists
assert test_eis_map.date.isot == test_eis_map.meta['date_avg']
# Case 2: date-average is None so default to date_obs
header = copy.deepcopy(test_header)
del header['date_beg']
del header['date_end']
del header['date_avg']
new_map = sunpy.map.Map(test_eis_map.data, header)
assert new_map.date.isot == new_map.meta['date_obs']
# Case 3: date_avg is None so default to date_start
header = copy.deepcopy(test_header)
del header['date_avg']
del header['date_end']
del header['date_obs']
new_map = sunpy.map.Map(test_eis_map.data, header)
assert new_map.date.isot == new_map.meta['date_beg']
# Case 4: date_end and date_avg do not exist
header = copy.deepcopy(test_header)
del header['date_avg']
del header['date_beg']
del header['date_obs']
new_map = sunpy.map.Map(test_eis_map.data, header)
assert new_map.date.isot == new_map.meta['date_end']
def test_date_is_dateobs(test_eis_map):
"Test that .date returns DATE_OBS"
assert test_eis_map.date.isot == test_eis_map.meta['date_obs']


def test_date_is_date_start(test_eis_map):
"Test that .date returns the same date as .date_start"
assert test_eis_map.date == test_eis_map.date_start


def test_reference_date_is_date_start(test_eis_map):
"Test that the reference date is the time at the beginning of the raster"
assert test_eis_map.reference_date == test_eis_map.date_start
wtbarnes marked this conversation as resolved.
Show resolved Hide resolved


def test_plot_settings(test_eis_map):
Expand Down
Loading