Skip to content

Commit

Permalink
Fix the way we set date on WCS
Browse files Browse the repository at this point in the history
  • Loading branch information
Cadair committed Apr 26, 2024
1 parent 5b27fef commit 52587ab
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions sunpy/map/mapbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,13 +608,21 @@ def wcs(self):
w2.wcs.crval = u.Quantity([self._reference_longitude, self._reference_latitude])
w2.wcs.ctype = self.coordinate_system
w2.wcs.pc = self.rotation_matrix
w2.wcs.set_pv(self._pv_values)
# FITS standard doesn't allow both PC_ij *and* CROTA keywords
w2.wcs.crota = (0, 0)
w2.wcs.cunit = self.spatial_units
w2.wcs.dateobs = self.date.isot
w2.wcs.aux.rsun_ref = self.rsun_meters.to_value(u.m)
w2.wcs.set_pv(self._pv_values)

# If date average exists we should use it. If it doesn't then we
# fallback to dateobs because it can come from many places
if self.date_average is not None:
w2.wcs.dateavg = self.date_average
else:
w2.wcs.dateobs = self.date.isot
w2.wcs.datebeg = self.date_start
w2.wcs.dateend = self.date_end

Check warning on line 623 in sunpy/map/mapbase.py

View check run for this annotation

Codecov / codecov/patch

sunpy/map/mapbase.py#L623

Added line #L623 was not covered by tests

w2.wcs.aux.rsun_ref = self.rsun_meters.to_value(u.m)

Check warning on line 625 in sunpy/map/mapbase.py

View check run for this annotation

Codecov / codecov/patch

sunpy/map/mapbase.py#L625

Added line #L625 was not covered by tests
# Set observer coordinate information except when we know it is not appropriate (e.g., HGS)
sunpy_frame = sunpy.coordinates.wcs_utils._sunpy_frame_class_from_ctypes(w2.wcs.ctype)
if sunpy_frame is None or hasattr(sunpy_frame, 'observer'):
Expand Down

0 comments on commit 52587ab

Please sign in to comment.