Skip to content

Commit

Permalink
Fix a whole bunch of bugs todo with -TAB in wcsapi/fitswcs
Browse files Browse the repository at this point in the history
  • Loading branch information
Cadair committed Aug 24, 2022
1 parent b6352e1 commit 8c5ff35
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions astropy/wcs/wcsapi/fitswcs.py
Expand Up @@ -401,7 +401,12 @@ def _get_components_and_classes(self):

kwargs = {}
kwargs['frame'] = celestial_frame
kwargs['unit'] = u.deg
# Very occasionally (TAB) wcs does not convert the units
# We call set here to make sure any unit conversion which is
# going to happen has been done.
self.wcs.set()
kwargs['unit'] = (u.Unit(self.wcs.cunit[self.wcs.lng]),
u.Unit(self.wcs.cunit[self.wcs.lat]))

classes['celestial'] = (SkyCoord, (), kwargs)

Expand Down Expand Up @@ -431,7 +436,7 @@ def _get_components_and_classes(self):
earth_location = EarthLocation(*self.wcs.obsgeo[:3], unit=u.m)

# Get the time scale from TIMESYS or fall back to 'utc'
tscale = self.wcs.timesys or 'utc'
tscale = self.wcs.timesys.lower() or 'utc'

if np.isnan(self.wcs.mjdavg):
obstime = Time(self.wcs.mjdobs, format='mjd', scale=tscale,
Expand Down Expand Up @@ -630,8 +635,8 @@ def value_from_spectralcoord(spectralcoord):
# Initialize delta
reference_time_delta = None

# Extract time scale
scale = self.wcs.ctype[i].lower()
# Extract time scale, and remove any algorithm code
scale = self.wcs.ctype[i].split("-")[0].lower()

if scale == 'time':
if self.wcs.timesys:
Expand Down

0 comments on commit 8c5ff35

Please sign in to comment.