Skip to content

Commit

Permalink
Use obstime from observer if obstime not otherwise provided
Browse files Browse the repository at this point in the history
  • Loading branch information
ayshih committed Sep 8, 2023
1 parent 4343e44 commit b97e894
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sunpy/coordinates/frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ def __init__(self, *args, **kwargs):
if not kwargs.pop('wrap_longitude', True):
self._wrap_angle = None

# If obstime is not provided but observer has an obstime, use that as the obstime
if 'obstime' not in kwargs and 'observer' in kwargs and kwargs['observer'].obstime is not None:
kwargs['obstime'] = kwargs['observer'].obstime

Check warning on line 138 in sunpy/coordinates/frames.py

View check run for this annotation

Codecov / codecov/patch

sunpy/coordinates/frames.py#L138

Added line #L138 was not covered by tests

super().__init__(*args, **kwargs)

# If obstime is specified, treat the default observer (None) as explicitly set
Expand Down
8 changes: 8 additions & 0 deletions sunpy/coordinates/tests/test_frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,14 @@ def test_hpc_low_precision_float_warning():
hpc.make_3d()


def test_hpc_obstime_from_observer():
# Test that observer.obstime is used for obstime if obstime is not provided
observer = HeliographicStonyhurst(obstime='2023-09-08')
hpc = Helioprojective(observer=observer)

assert hpc.obstime == observer.obstime


# ==============================================================================
# ## Heliographic Tests
# ==============================================================================
Expand Down

0 comments on commit b97e894

Please sign in to comment.