Mr Learner
Mr Learner

Reputation: 63

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.

Upvotes: 0

Views: 448

Answers (2)

RKhan
RKhan

Reputation: 21

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

#My required file has been downloaded in the following path of my HD, "~/projects/eclipsing_binary/A/mastDownload/HLSP/hlsp_qlp_tess_ffi_s0018-0000000346784049_tess_v01_llc/hlsp_qlp_tess_ffi_s0018-000000346784049_tess_v01_llc.fits". Using linux command open and see the list of the files in the directory.

%cd ~/projects/eclipsing_binary/A/mastDownload/HLSP/
hlsp_qlp_tess_ffi_s0018-0000000346784049_tess_v01_llc/
%ls

#Now plot the required file in simple way,

import lightkurve as lk
file_r = 'hlsp_qlp_tess_ffi_s0018-0000000346784049_tess_v01_llc.fits'
lr = lk.read(file_r)
lr.plot()

Upvotes: 0

keflavich
keflavich

Reputation: 19205

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

Upvotes: 1

Related Questions