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

<p>Chapter 2 of the <a href="https://archive.stsci.edu/kepler/manuals/archive_manual.pdf" rel="nofollow noreferrer">Kepler Archive Manual</a> is essential reading.</p>

<p>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).</p>

<p>Alternatively, <a href="https://docs.astropy.org/en/stable/io/fits/" rel="nofollow noreferrer">astropy</a> has fits input/output functions that can be used in python.</p>

CC BY-SA 4.0
2020-03-22T06:16:04.650Z
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.
https://archive.stsci.edu/pub/kepler/ffi/
Mr Learner
CC BY-SA 4.0
2020-03-22T06:54:26.123Z
@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.
ProfRob
CC BY-SA 4.0
2020-03-22T08:45:20.317Z
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?
Mr Learner
CC BY-SA 4.0
2020-03-22T09:53:21.360Z
@MrLearner yes, if you download the lightcurve file. Topcat will read that also.
ProfRob
CC BY-SA 4.0
2020-03-22T13:38:22.390Z
No topcat doesn't do that. I have added Topcat error screenshot in the original question. Does it mean that the files in https://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.
Mr Learner
CC BY-SA 4.0
2020-03-17T17:20:43.567Z
2020-03-24T16:09:28.633Z
2020-03-24T16:09:28.633Z
ProfRob
<p>This is a continuation of my earlier question <a href="https://astronomy.stackexchange.com/questions/35505/how-to-find-kepler-tess-data">here</a>. 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.
<a href="https://i.sstatic.net/kz6Ux.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/kz6Ux.jpg" alt="enter image description here"></a></p>

<p>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.</p>

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

<p>Thanks in advance.</p>

CC BY-SA 4.0
2020-03-17T17:41:31.360Z
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
astrosnapper
CC BY-SA 4.0
2020-03-22T14:47:49.280Z
I am taking the first file from tis URL https://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.
Mr Learner
CC BY-SA 4.0
2020-03-22T17:48:34.063Z
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](https://wp.me/a9RyFg-3J)
astrosnapper
CC BY-SA 4.0
2020-03-24T04:28:24.277Z
I tested the file https://archive.stsci.edu/pub/kepler/lightcurves/0007/000757076/kplr000757076-2009131105131_llc.fits 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.
Mr Learner
CC BY-SA 4.0
2020-03-24T05:27:04.260Z
Are you giving it a full Windows pathname for the filename as in this [question](https://stackoverflow.com/questions/1347791/unicode-error-unicodeescape-codec-cant-decode-bytes-cannot-open-text-file) ? 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
astrosnapper
CC BY-SA 4.0
2020-03-24T05:39:45.377Z
For testing, I have downloaded on file in my local system and using the full path in fits.open.
Mr Learner
CC BY-SA 4.0
2020-03-25T01:23:51.640Z
So as I say above, you will need to make it a `raw` string to stop Python thinking you mean a Unicode character: `fits.open(r"C:\Users\Tim\kplr000757076-2009131105131_llc.fits")` (note the `r` before the double quote). Illustration of the alternatives in this [screenshot](https://adventuresinprecision.space/wp-content/uploads/2020/03/Screenshot-2020-03-24-18.17.13.png)
astrosnapper
<exoplanet><python><fits-header><tess>
Cannot plot Kepler FITS files with topcat in Windows
Mr Learner
# Cannot plot Kepler FITS files with topcat in Windows

(Asked by: username_0 on 2020-03-17)

This is a continuation of my earlier question [here](https://astronomy.stackexchange.com/questions/35505/how-to-find-kepler-tess-data). 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](https://i.sstatic.net/kz6Ux.jpg)](https://i.sstatic.net/kz6Ux.jpg)

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.

**Tags:** exoplanet, python, fits-header, tess
> **Comments:**
> **username_1**: 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  
> **username_0**: I am taking the first file from tis URL https://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.  
> **username_1**: 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](https://wp.me/a9RyFg-3J)  
> **username_0**: I tested the file https://archive.stsci.edu/pub/kepler/lightcurves/0007/000757076/kplr000757076-2009131105131_llc.fits 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.  
> **username_1**: Are you giving it a full Windows pathname for the filename as in this [question](https://stackoverflow.com/questions/1347791/unicode-error-unicodeescape-codec-cant-decode-bytes-cannot-open-text-file) ? 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  
> **username_0**: For testing, I have downloaded on file in my local system and using the full path in fits.open.  
> **username_1**: So as I say above, you will need to make it a `raw` string to stop Python thinking you mean a Unicode character: `fits.open(r"C:\Users\Tim\kplr000757076-2009131105131_llc.fits")` (note the `r` before the double quote). Illustration of the alternatives in this [screenshot](https://adventuresinprecision.space/wp-content/uploads/2020/03/Screenshot-2020-03-24-18.17.13.png)  

---

## 1 answers

### Answer by username_2 on 2020-03-17. Score: 2

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](https://archive.stsci.edu/kepler/manuals/archive_manual.pdf) 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](https://docs.astropy.org/en/stable/io/fits/) has fits input/output functions that can be used in python.

> **Comments:**
> **username_0**: 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. https://archive.stsci.edu/pub/kepler/ffi/  
> **username_2**: @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.  
> **username_0**: 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?  
> **username_2**: @MrLearner yes, if you download the lightcurve file. Topcat will read that also.  
> **username_0**: No topcat doesn't do that. I have added Topcat error screenshot in the original question. Does it mean that the files in https://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.  

---

