This is a continuation of my earlier question here. I was able to find Kepler data. Now I wanted to plot the data using Topcat. But when I tried to plot the data, I received error. Below is the error screenshot. enter image description here

In the screenshot I have given two different errors with different table formats. But actually I tried with all the table formats, and none of them works for me. I was thinking of converting the file with Topcat to csv. As I am unable to open the file, I could not convert it into csv.

Here I need help two sectors.
1. How to open the FITS files.
2. Is there any python code to convert these FITS files into csv and/or any python code to plot these fits files.

Thanks in advance.

  • $\begingroup$ Without knowing exactly what data you have (can you provide a link/details of how we can also get that particular file) it looks like this is a Kepler Full Frame Image, a FITS image (which TOPCAT won't read) rather than a FITS table like a lightcurve. If you have access to Python and astropy, from astropy.io import fits ; hdulist = fits.open(<fill in path to your ffi fits file>); print(hdulist) will show the types of FITS HDUs in the file. You need to see astropy.io.fits.hdu.table.BinTableHDU (not ImageHDU) in the results to confirm it has tables in the FITS file $\endgroup$ – astrosnapper Mar 17 at 17:41
  • $\begingroup$ I am taking the first file from tis URL archive.stsci.edu/pub/kepler/ffi and trying to use the following code to test from astropy.io import fits fits_image_filename = fits.util.get_testdata_filepath('test0.fits') But the above commend shows following error File "<stdin>", line 1 SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape I have tried using Topcat and the above code. None of the approaches work out for me. $\endgroup$ – Mr Learner Mar 22 at 14:47
  • 1
    $\begingroup$ As Rob says below, these are images rather than lightcurves. When I open it with astropy or DS9, I get 85 entries, 1 primary header and 84 1070x1132 pixel images. The example you show should work and load an example test dataset from astropy on disk (it works for me under python3.7 on Windows and Linux). However if you go to a different directory on the STSci site e.g. https://archive.stsci.edu/pub/kepler/lightcurves/1000/100000925/ you should find light curves FITS files. These plot just fine in TOPCAT see this screenshot $\endgroup$ – astrosnapper Mar 22 at 17:48
  • $\begingroup$ I tested the file archive.stsci.edu/pub/kepler/lightcurves/0007/000757076/… using Topocat and was able to plot the file. But when I tried to write code using astropy it showd error. Following code I have written rom astropy.io import fits hdulist = fits.open(<filename>); I received following error :- File "<stdin>", line 1 SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape Please help me on this. $\endgroup$ – Mr Learner Mar 24 at 4:28
  • $\begingroup$ Are you giving it a full Windows pathname for the filename as in this question ? In this case, you will need to convert it to a raw string as shown in the answer or (better) look into using os.path.join to join bits of paths together in a (more) OS-independent way. An example for Windows would be fits_filename = os.path.join(os.getenv('userprofile'), 'kepler', 'kplr_file.fits') assuming the file is in a kepler subdirectory of your home directory $\endgroup$ – astrosnapper Mar 24 at 5:27

FFI means "full frame image". It does not contain any tables, so the unhelpful error message is almost certainly due to that.

Chapter 2 of the Kepler Archive Manual is essential reading.

Light curve files have a file name suffix of .llc or .slc (long and short cadence), as described in that document, and contain binary fits tables that can be opened and plotted in topcat (and saved in csv format if you wish).

Alternatively, astropy has fits input/output functions that can be used in python.

| improve this answer | |
  • $\begingroup$ I have already gone through the above pdf. This pdf describes the format of the files. But I need to find a way to convert the files in csv and plot them. The URL of the file location given below. archive.stsci.edu/pub/kepler/ffi $\endgroup$ – Mr Learner Mar 22 at 6:16
  • 1
    $\begingroup$ @MrLearner the fits file you are trying to open is an image. You can't do anything with images in topcat. astropy contains fits interface functions. $\endgroup$ – Rob Jeffries Mar 22 at 6:54
  • $\begingroup$ Thanks @Rob Jeffries. I have already found astropy using google search. Another question, as you have said this is an image. Can I plot the light curve graph using astropy? $\endgroup$ – Mr Learner Mar 22 at 8:45
  • 1
    $\begingroup$ @MrLearner yes, if you download the lightcurve file. Topcat will read that also. $\endgroup$ – Rob Jeffries Mar 22 at 9:53
  • $\begingroup$ No topcat doesn't do that. I have added Topcat error screenshot in the original question. Does it mean that the files in archive.stsci.edu/pub/kepler/ffi are not lightcurve file? If yes, can you please let me know the URLs of the original lightcurve light curve files. $\endgroup$ – Mr Learner Mar 22 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.