leejjoon / pywcsgrid2

astromonical fits image for python matplotlib
http://leejjoon.github.com/pywcsgrid2/
MIT License
25 stars 13 forks source link

'Header' object has no attribute 'wcs' #19

Open mcclearyj opened 7 years ago

mcclearyj commented 7 years ago

Hello,

First, thank you so much for publishing this module, it's a great service to the community. I am getting errors in the very first step of creating the initial pywcsgrid2.Axes class.

f=fits.open("r_coadd_lensing2.fits") h, d = f[0].header, f[0].data pywcsgrid2.subplot(111, header=h)

returns the following error: `/Users/jmcclear/anaconda/lib/python2.7/site-packages/pywcsgrid2/wcs_helper.pyc in _get_naxis(self) 262 263 def _get_naxis(self): --> 264 return self._pywcs.wcs.naxis 265 266 naxis = property(_get_naxis)

AttributeError: 'Header' object has no attribute 'wcs' `

I have tried this with several different fits files to no avail. I'm not sure what could be going on, because DS9 has no trouble opening the files' WCS systems. Here is an example of what the headers look like. signal_header.txt

Thank you!

leejjoon commented 7 years ago

My gut feeling is that somehow the header instance you provide is not the type that pywcsgrid2 expects. It could be that you have both pyfits and astropy installed and it confuses pywcsgrid2 (which I though I fiexed). Anyhow, can you try something like below and see if it works?

from astropy.wcs import WCS
wcs = WCS(h)
pywcsgrid2.subplot(111, header=wcs)

Also, it would be helpful if you can provide following information

print fits
print type(h)
print type(wcs)

And the version of astropy you are using.