astropy.wcs issue with 2MASS image headers

238 views
Skip to first unread message

David Rosario

unread,
Mar 30, 2016, 5:53:19 PM3/30/16
to astropy-dev
Hi everyone,


  I’m trying to use the WCS module within Astropy to do some simple object location work on Extended Source image cubes from the 2MASS survey, downloaded from IRSA. I keep running into an error that I can’t seem to understand or overcome, which seems to relate to the interaction with the external wcslib C library. FYI, I’m using Astropy 1.1.2 on Python 3.4.4 through iPython 3.2.0.

I’ve attached an example image (2.2 MB) for your reference, which I use for the code snippets below. The data in the primary extension of the fits file is 3-dimensional (a cube), which is a stack of images in various bands. This is the way that these Extended Source cubes are distributed by IRSA.

  I can use Astropy io.fits utilities to open the fits file and read in the header.

---------
from astropy.io import fits
hdulist = fits.open('2MASXJ22091625-4709599.fits’)
header = hdulist[0].header  # astropy header instance
---------

 Then I can use the astropy.wcs.WCS constructor to extract the WCS from this header

---------
from astropy import was
astr = wcs.WCS(header)

At this point, the code fails with the following traceback:

WARNING: FITSFixedWarning: 'celfix' made the change 'Unrecognized projection code (-SI in CTYPE2)'. [astropy.wcs.wcs]
---------------------------------------------------------------------------
InconsistentAxisTypesError                Traceback (most recent call last)
<ipython-input-22-cc051d3537d1> in <module>()
----> 1 astr = wcs.WCS(header)

/Users/davidrosario/anaconda/lib/python3.4/site-packages/astropy/wcs/wcs.py in __init__(self, header, fobj, key, minerr, relax, naxis, keysel, colsel, fix, translate_units, _do_set)
   498
   499         if _do_set:
--> 500             self.wcs.set()
   501
   502         for fd in close_fds:

InconsistentAxisTypesError: ERROR 4 in wcs_types() at line 2432 of file cextern/wcslib/C/wcs.c:
Unrecognized projection code (-SI in CTYPE2).


  I can’t seem to find anything particularly strange in the header - it’s actually quite simple, with no distortion corrections needed. The value of the keyword CTYPE3 is possibly non-standard. However, even if I delete that keyword from the FITS header, I get the same problem. Given that the 2MASS images are widely used in the community, I was puzzled by this issue. Could you please let me know if I’ve done something incorrectly or suggest a fix?

  Thanks very much for any help you could send me.

   -- David Rosario

2MASXJ22091625-4709599.fits

Adam Ginsburg

unread,
Mar 30, 2016, 6:13:22 PM3/30/16
to astropy-dev
Hi David,
    This one's straightforward, though perhaps surprising - did you get the data direct from IRSA?   The CTYPE keywords are required to have 8 characters, and yours looks like this:
CTYPE1  = 'RA---SIN'           / Orthographic Projection
CTYPE2  = 'DEC---SIN'          / Orthographic Projection

it should be DEC--SIN.  If you got this off of their archive, you should report it as an issue.

--
You received this message because you are subscribed to the Google Groups "astropy-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to astropy-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Adam Ginsburg
Fellow, European Southern Observatory
http://www.adamgginsburg.com/

David Rosario

unread,
Mar 30, 2016, 7:37:44 PM3/30/16
to astropy-dev, adam.g....@gmail.com
Thanks Adam! Repairing the header  seems to have done the trick.

Yes, these images were downloaded directly from IRSA, so it's a bit surprising about the malformed header. I'll get in touch with the folks there.

   Cheers and best wishes,

      -- David
Reply all
Reply to author
Forward
0 new messages