Skip to content

Commit f06cdf5

Browse files
committed
Merge pull request #935 from astrofrog/fix-wcs-naxis
Ignore extra dimensions in WCS
1 parent 0467d75 commit f06cdf5

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ v0.7.3 (unreleased)
77
* Add missing find_spec for import hook, to avoid issues when trying to set
88
colormap. [#930]
99

10+
* Ignore extra dimensions in WCS (for instance, if the data is 3D and the
11+
header is 4D, ignore the 4th dimension in the WCS).
12+
1013
v0.7.2 (2016-04-05)
1114
-------------------
1215

glue/core/coordinates.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,13 @@ def __init__(self, header, wcs=None):
6363
from astropy.wcs import WCS
6464

6565
self._header = header
66-
wcs = wcs or WCS(header)
66+
67+
try:
68+
naxis = header['NAXIS']
69+
except (KeyError, TypeError):
70+
naxis = None
71+
72+
wcs = wcs or WCS(header, naxis=naxis)
6773

6874
# update WCS interface if using old API
6975
mapping = {'wcs_pix2world': 'wcs_pix2sky',
@@ -116,7 +122,11 @@ def __setstate__(self, state):
116122
self.__dict__ = state
117123
# wcs object doesn't seem to unpickle properly. reconstruct it
118124
from astropy.wcs import WCS
119-
self._wcs = WCS(self._header)
125+
try:
126+
naxis = self._header['NAXIS']
127+
except (KeyError, TypeError):
128+
naxis = None
129+
self._wcs = WCS(self._header, naxis=naxis)
120130

121131
def pixel2world(self, *pixel):
122132
'''

0 commit comments

Comments
 (0)