pythonastropyfits

Error reading Kepler FITS file using astropy


I was trying to read fits files from Kepler FITS files (Received from this URL https://archive.stsci.edu/pub/kepler/lightcurves/0007/000757076/) using astropy. Below are the set of commands I was trying to read the file:

from astropy.io import fits
fits_image_filename = fits.util.get_testdata_filepath(r'O:\MyWorks\keplar-test\kplr100000925-2009166043257_llc.fits')

But the above command produced this error:

enter image description here

I am not sure how to solve this error. My target is to read keplar data then plot this and/or convert this to CSV.


Solution

  • This: fits.util.get_testdata_filepath(r'O:\MyWorks\keplar-test\kplr100000925-2009166043257_llc.fits') is not the correct function for opening a file.

    You should use fits.open('file.fits'), or if this is table data, as you imply, Table.read('file.fits')

    See the note at the top of the FITS documentation