Astropy: fits.getdata returns NaNs

Created on 28 Aug 2017  ·  3Comments  ·  Source: astropy/astropy

Hi,

I am using astropy 2.0.1, Python 2.7. When I try to get FITS data into array (fits file link) by

from astropy.io import fits
image_data = fits.getdata('NGC_628_NA_MOM2_THINGS.FITS')

I get numpy array full of NaNs

array([[[[ nan,  nan,  nan, ...,  nan,  nan,  nan],
         [ nan,  nan,  nan, ...,  nan,  nan,  nan],
         [ nan,  nan,  nan, ...,  nan,  nan,  nan],
         ..., 
         [ nan,  nan,  nan, ...,  nan,  nan,  nan],
         [ nan,  nan,  nan, ...,  nan,  nan,  nan],
         [ nan,  nan,  nan, ...,  nan,  nan,  nan]]]], dtype=float32)

Open as HDU list

hdu_list = fits.open('NGC_628_NA_MOM2_THINGS.FITS')
image_data = hdu_list[0].data

return the same result. But SAOImage ds9 can successfully open and show data.

io.fits

Most helpful comment

That image just has a lot nans at the edges. It looks okay though:

from astropy.io import fits
import matplotlib.pyplot as plt

data = fits.getdata('NGC_628_NA_MOM2_THINGS.FITS')
plt.imshow(np.squeeze(data), origin='lower', cmap='gray')
plt.show()

png image 573 x 429 pixels

All 3 comments

That image just has a lot nans at the edges. It looks okay though:

from astropy.io import fits
import matplotlib.pyplot as plt

data = fits.getdata('NGC_628_NA_MOM2_THINGS.FITS')
plt.imshow(np.squeeze(data), origin='lower', cmap='gray')
plt.show()

png image 573 x 429 pixels

Ooops, my fault.
@MSeifert04 Thanks a lot for this super-fast answer!

No problem. Good luck with the data :)

Was this page helpful?
0 / 5 - 0 ratings