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

Ignore extra dimensions in WCS #935

Merged
merged 2 commits into from
Apr 16, 2016
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
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ v0.7.3 (unreleased)
* Add missing find_spec for import hook, to avoid issues when trying to set
colormap. [#930]

* Ignore extra dimensions in WCS (for instance, if the data is 3D and the
header is 4D, ignore the 4th dimension in the WCS).

v0.7.2 (2016-04-05)
-------------------

Expand Down
14 changes: 12 additions & 2 deletions glue/core/coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,13 @@ def __init__(self, header, wcs=None):
from astropy.wcs import WCS

self._header = header
wcs = wcs or WCS(header)

try:
naxis = header['NAXIS']
except (KeyError, TypeError):
naxis = None

wcs = wcs or WCS(header, naxis=naxis)

# update WCS interface if using old API
mapping = {'wcs_pix2world': 'wcs_pix2sky',
Expand Down Expand Up @@ -116,7 +122,11 @@ def __setstate__(self, state):
self.__dict__ = state
# wcs object doesn't seem to unpickle properly. reconstruct it
from astropy.wcs import WCS
self._wcs = WCS(self._header)
try:
naxis = self._header['NAXIS']
except (KeyError, TypeError):
naxis = None
self._wcs = WCS(self._header, naxis=naxis)

def pixel2world(self, *pixel):
'''
Expand Down