Plotting a Catalog over a Kepler Full Frame Image File


This tutorial demonstrates how to access the WCS (World Coordinate System) from a full frame image file and use this data to plot a catalog of objects over the FFI.
ffi_tic_plot

Table of Contents


[Introduction](#intro_ID)
[Imports](#imports_ID)
[Getting the Data](#data_ID)
[File Information](#fileinfo_ID)
[Displaying Image Data](#image_ID)
[Overplotting Objects](#overplot_ID)
[Additional Resources](#resources_ID)
[About this Notebook](#about_ID)

Introduction

Full Frame Image file background: A Full Frame Image (FFI) contains values for every pixel in each of the 84 channels. Standard calibrations, such as flat fields, blacks, and smears have been applied to the calibrated FFIs. These files also contain a World Coordinate System (WCS) that attaches RA and Dec coordinates to pixel x and y values.

Some notes about the file: kplr2009170043915_ffi-cal.fits
The filename contains phrases for identification, where

  • kplr = Kepler
  • 2009170043915 = year 2009, day 170, time 04:39:15
  • ffi-cal = calibrated FFI image

Defining some terms:

  • HDU: Header Data Unit; a FITS file is made up of Header or Data units that contain information, data, and metadata relating to the file. The first HDU is called the primary, and anything that follows is considered an extension.
  • TIC: TESS Input Catalog; a catalog of luminous sources on the sky to be used by the TESS mission. We will use the TIC in this notebook to query a catalog of objects that we will then plot over an image from Kepler.
  • WCS: World Coordinate System; coordinates attached to each pixel of an N-dimensional image of a FITS file. For example, a specified celestial RA and Dec associated with pixel location in the image.

For more information about the Kepler mission and collected data, visit the Kepler archive page. To read more details about light curves and important data terms, look in the Kepler archive manual.


Imports

Let's start by importing some libraries to the environment:

  • numpy to handle array functions
  • astropy.io fits for accessing fits files
  • astropy.wcs WCS to project the World Coordinate System on the plot
  • astropy.table Table for creating tidy tables of the data
  • matplotlib.pyplot for plotting data
In [1]:
%matplotlib inline
import numpy as np
from astropy.io import fits
from astropy.wcs import WCS
from astropy.table import Table
import matplotlib.pyplot as plt

Getting the Data

Start by importing libraries from Astroquery. For a longer, more detailed description using of Astroquery, please visit this tutorial or read the Astroquery documentation.

In [2]:
from astroquery.mast import Mast
from astroquery.mast import Observations


Next, we need to find the data file. This is similar to searching for the data using the MAST Portal in that we will be using certain keywords to find the file. The object we are looking for is kplr2009170043915, collected by the Kepler spacecraft. We are searching for an FFI file of this object:

In [3]:
kplrObs = Observations.query_criteria(obs_id="kplr2009170043915_84", obs_collection="KeplerFFI")
kplrProds = Observations.get_product_list(kplrObs[0])
yourProd = Observations.filter_products(kplrProds, extension='kplr2009170043915_ffi-cal.fits', 
                                        mrp_only=False)
yourProd
Out[3]:
Table masked=True length=1
obsIDobs_collectiondataproduct_typeobs_iddescriptiontypedataURIproductTypeproductGroupDescriptionproductSubGroupDescriptionproductDocumentationURLprojectprvversionproposal_idproductFilenamesizeparent_obsiddataRights
str10str9str5str20str22str1str106str7str28str1str1str6str1str1str37int64str10str6
4000002693KeplerFFIimagekplr2009170043915_84Full Frame Image (FFI)Cmast:KeplerFFI/url/missions/kepler/ffi/kplr2009170043915_ffi-cal.fitsSCIENCEMinimum Recommended Products----Kepler----kplr2009170043915_ffi-cal.fits4078828804000002693PUBLIC


Now that we've found the data file, we can download it using the reults shown in the table above:

In [4]:
Observations.download_products(yourProd, mrp_only=False, cache=False)
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:KeplerFFI/url/missions/kepler/ffi/kplr2009170043915_ffi-cal.fits to ./mastDownload/KeplerFFI/kplr2009170043915_84/kplr2009170043915_ffi-cal.fits ... [Done]
Out[4]:
Table length=1
Local PathStatusMessageURL
str76str8objectobject
./mastDownload/KeplerFFI/kplr2009170043915_84/kplr2009170043915_ffi-cal.fitsCOMPLETENoneNone

Reading FITS Extensions


Now that we have the file, we can start working with the data. We will begin by assigning a shorter name to the file to make it easier to use. Then, using the info function from astropy.io.fits, we can see some information about the FITS Header Data Units:

In [5]:
filename = "./mastDownload/KeplerFFI/kplr2009170043915_84/kplr2009170043915_ffi-cal.fits"
fits.info(filename)
Filename: ./mastDownload/KeplerFFI/kplr2009170043915_84/kplr2009170043915_ffi-cal.fits
No.    Name      Ver    Type      Cards   Dimensions   Format
  0  PRIMARY       1 PrimaryHDU      57   ()      
  1  MOD.OUT 2.1    1 ImageHDU       100   (1132, 1070)   float32   
  2  MOD.OUT 2.2    1 ImageHDU       100   (1132, 1070)   float32   
  3  MOD.OUT 2.3    1 ImageHDU       100   (1132, 1070)   float32   
  4  MOD.OUT 2.4    1 ImageHDU       100   (1132, 1070)   float32   
  5  MOD.OUT 3.1    1 ImageHDU       100   (1132, 1070)   float32   
  6  MOD.OUT 3.2    1 ImageHDU       100   (1132, 1070)   float32   
  7  MOD.OUT 3.3    1 ImageHDU       100   (1132, 1070)   float32   
  8  MOD.OUT 3.4    1 ImageHDU       100   (1132, 1070)   float32   
  9  MOD.OUT 4.1    1 ImageHDU       100   (1132, 1070)   float32   
 10  MOD.OUT 4.2    1 ImageHDU       100   (1132, 1070)   float32   
 11  MOD.OUT 4.3    1 ImageHDU       100   (1132, 1070)   float32   
 12  MOD.OUT 4.4    1 ImageHDU       100   (1132, 1070)   float32   
 13  MOD.OUT 6.1    1 ImageHDU       100   (1132, 1070)   float32   
 14  MOD.OUT 6.2    1 ImageHDU       100   (1132, 1070)   float32   
 15  MOD.OUT 6.3    1 ImageHDU       100   (1132, 1070)   float32   
 16  MOD.OUT 6.4    1 ImageHDU       100   (1132, 1070)   float32   
 17  MOD.OUT 7.1    1 ImageHDU       100   (1132, 1070)   float32   
 18  MOD.OUT 7.2    1 ImageHDU       100   (1132, 1070)   float32   
 19  MOD.OUT 7.3    1 ImageHDU       100   (1132, 1070)   float32   
 20  MOD.OUT 7.4    1 ImageHDU       100   (1132, 1070)   float32   
 21  MOD.OUT 8.1    1 ImageHDU       100   (1132, 1070)   float32   
 22  MOD.OUT 8.2    1 ImageHDU       100   (1132, 1070)   float32   
 23  MOD.OUT 8.3    1 ImageHDU       100   (1132, 1070)   float32   
 24  MOD.OUT 8.4    1 ImageHDU       100   (1132, 1070)   float32   
 25  MOD.OUT 9.1    1 ImageHDU       100   (1132, 1070)   float32   
 26  MOD.OUT 9.2    1 ImageHDU       100   (1132, 1070)   float32   
 27  MOD.OUT 9.3    1 ImageHDU       100   (1132, 1070)   float32   
 28  MOD.OUT 9.4    1 ImageHDU       100   (1132, 1070)   float32   
 29  MOD.OUT 10.1    1 ImageHDU       100   (1132, 1070)   float32   
 30  MOD.OUT 10.2    1 ImageHDU       100   (1132, 1070)   float32   
 31  MOD.OUT 10.3    1 ImageHDU       100   (1132, 1070)   float32   
 32  MOD.OUT 10.4    1 ImageHDU       100   (1132, 1070)   float32   
 33  MOD.OUT 11.1    1 ImageHDU       100   (1132, 1070)   float32   
 34  MOD.OUT 11.2    1 ImageHDU       100   (1132, 1070)   float32   
 35  MOD.OUT 11.3    1 ImageHDU       100   (1132, 1070)   float32   
 36  MOD.OUT 11.4    1 ImageHDU       100   (1132, 1070)   float32   
 37  MOD.OUT 12.1    1 ImageHDU       100   (1132, 1070)   float32   
 38  MOD.OUT 12.2    1 ImageHDU       100   (1132, 1070)   float32   
 39  MOD.OUT 12.3    1 ImageHDU       100   (1132, 1070)   float32   
 40  MOD.OUT 12.4    1 ImageHDU       100   (1132, 1070)   float32   
 41  MOD.OUT 13.1    1 ImageHDU       100   (1132, 1070)   float32   
 42  MOD.OUT 13.2    1 ImageHDU       100   (1132, 1070)   float32   
 43  MOD.OUT 13.3    1 ImageHDU       100   (1132, 1070)   float32   
 44  MOD.OUT 13.4    1 ImageHDU       100   (1132, 1070)   float32   
 45  MOD.OUT 14.1    1 ImageHDU       100   (1132, 1070)   float32   
 46  MOD.OUT 14.2    1 ImageHDU       100   (1132, 1070)   float32   
 47  MOD.OUT 14.3    1 ImageHDU       100   (1132, 1070)   float32   
 48  MOD.OUT 14.4    1 ImageHDU       100   (1132, 1070)   float32   
 49  MOD.OUT 15.1    1 ImageHDU       100   (1132, 1070)   float32   
 50  MOD.OUT 15.2    1 ImageHDU       100   (1132, 1070)   float32   
 51  MOD.OUT 15.3    1 ImageHDU       100   (1132, 1070)   float32   
 52  MOD.OUT 15.4    1 ImageHDU       100   (1132, 1070)   float32   
 53  MOD.OUT 16.1    1 ImageHDU       100   (1132, 1070)   float32   
 54  MOD.OUT 16.2    1 ImageHDU       100   (1132, 1070)   float32   
 55  MOD.OUT 16.3    1 ImageHDU       100   (1132, 1070)   float32   
 56  MOD.OUT 16.4    1 ImageHDU       100   (1132, 1070)   float32   
 57  MOD.OUT 17.1    1 ImageHDU       100   (1132, 1070)   float32   
 58  MOD.OUT 17.2    1 ImageHDU       100   (1132, 1070)   float32   
 59  MOD.OUT 17.3    1 ImageHDU       100   (1132, 1070)   float32   
 60  MOD.OUT 17.4    1 ImageHDU       100   (1132, 1070)   float32   
 61  MOD.OUT 18.1    1 ImageHDU       100   (1132, 1070)   float32   
 62  MOD.OUT 18.2    1 ImageHDU       100   (1132, 1070)   float32   
 63  MOD.OUT 18.3    1 ImageHDU       100   (1132, 1070)   float32   
 64  MOD.OUT 18.4    1 ImageHDU       100   (1132, 1070)   float32   
 65  MOD.OUT 19.1    1 ImageHDU       100   (1132, 1070)   float32   
 66  MOD.OUT 19.2    1 ImageHDU       100   (1132, 1070)   float32   
 67  MOD.OUT 19.3    1 ImageHDU       100   (1132, 1070)   float32   
 68  MOD.OUT 19.4    1 ImageHDU       100   (1132, 1070)   float32   
 69  MOD.OUT 20.1    1 ImageHDU       100   (1132, 1070)   float32   
 70  MOD.OUT 20.2    1 ImageHDU       100   (1132, 1070)   float32   
 71  MOD.OUT 20.3    1 ImageHDU       100   (1132, 1070)   float32   
 72  MOD.OUT 20.4    1 ImageHDU       100   (1132, 1070)   float32   
 73  MOD.OUT 22.1    1 ImageHDU       100   (1132, 1070)   float32   
 74  MOD.OUT 22.2    1 ImageHDU       100   (1132, 1070)   float32   
 75  MOD.OUT 22.3    1 ImageHDU       100   (1132, 1070)   float32   
 76  MOD.OUT 22.4    1 ImageHDU       100   (1132, 1070)   float32   
 77  MOD.OUT 23.1    1 ImageHDU       100   (1132, 1070)   float32   
 78  MOD.OUT 23.2    1 ImageHDU       100   (1132, 1070)   float32   
 79  MOD.OUT 23.3    1 ImageHDU       100   (1132, 1070)   float32   
 80  MOD.OUT 23.4    1 ImageHDU       100   (1132, 1070)   float32   
 81  MOD.OUT 24.1    1 ImageHDU       100   (1132, 1070)   float32   
 82  MOD.OUT 24.2    1 ImageHDU       100   (1132, 1070)   float32   
 83  MOD.OUT 24.3    1 ImageHDU       100   (1132, 1070)   float32   
 84  MOD.OUT 24.4    1 ImageHDU       100   (1132, 1070)   float32   
  • No. 0 (Primary):
    This HDU contains meta-data related to the entire file.
  • No. 1-84 (Image):
    Each of the 84 image extensions contains an array that can be plotted as an image. We will plot one in this tutorial along with catalog data.


Let's say we wanted to see more information about the header and extensions than what the fits.info command gave us. For example, we can access information stored in the header of any of the Image extensions (No.1 - 84, MOD.OUT). The following line opens the FITS file, writes the first HDU extension into header1, and then closes the file. Only 24 rows of data are displayed here but you can view them all by adjusting the range:

In [6]:
with fits.open(filename) as hdulist: 
    header1 = hdulist[1].header
  
print(repr(header1[1:25]))
BITPIX  =                  -32 / array data type                                
NAXIS   =                    2 / NAXIS                                          
NAXIS1  =                 1132 / length of first array dimension                
NAXIS2  =                 1070 / length of second array dimension               
PCOUNT  =                    0 / group parameter count (not used)               
GCOUNT  =                    1 / group count (not used)                         
INHERIT =                    T / inherit the primary header                     
EXTNAME = 'MOD.OUT 2.1'        / name of extension                              
EXTVER  =                    1 / extension version number (not format version)  
TELESCOP= 'Kepler  '           / telescope                                      
INSTRUME= 'Kepler Photometer'  / detector type                                  
CHANNEL =                    1 / CCD channel                                    
SKYGROUP=                   81 / roll-independent location of channel           
MODULE  =                    2 / CCD module                                     
OUTPUT  =                    1 / CCD output                                     
TIMEREF = 'SOLARSYSTEM'        / barycentric correction applied to times        
TASSIGN = 'SPACECRAFT'         / where time is assigned                         
TIMESYS = 'TDB     '           / time system is barycentric JD                  
MJDSTART=       55001.17349214 / [d] start of observation in spacecraft MJD     
MJDEND  =        55001.1939257 / [d] end of observation in spacecraft MJD       
BJDREFI =              2454833 / integer part of BJD reference date             
BJDREFF =           0.00000000 / fraction of the day in BJD reference date      
TIMEUNIT= 'd       '           / time unit for TIME, TSTART and TSTOP           
TSTART  =         168.67667104 / observation start time in BJD-BJDREF           

Displaying Image Data


First, let's find the WCS information associated with the FITS file we are using. One way to do this is to access the header and print the rows containing the relevant data (54 - 65). This gives us the reference coordinates (CRVAL1, CRVAL2) that correspond to the reference pixels:

In [7]:
with fits.open(filename) as hdulist: 
    header1 = hdulist[1].header
  
print(repr(header1[54:61]))
WCSAXES =                    2 / number of WCS axes                             
CTYPE1  = 'RA---TAN-SIP'       / Gnomonic projection + SIP distortions          
CTYPE2  = 'DEC--TAN-SIP'       / Gnomonic projection + SIP distortions          
CRVAL1  =    290.4620065226813 / RA at CRPIX1, CRPIX2                           
CRVAL2  =    38.32946356799192 / DEC at CRPIX1, CRPIX2                          
CRPIX1  =                533.0 / X reference pixel                              
CRPIX2  =                521.0 / Y reference pixel                              


Let's pick an image HDU and display its array. We can also choose to print the length of the array to get an idea of the dimensions of the image:

In [8]:
with fits.open(filename) as hdulist:
    imgdata = hdulist[1].data
    
print(len(imgdata))
print(imgdata)
1070
[[ 2.8926212e+01  5.7084761e+00  2.8518679e+00 ...  2.3335369e-02
   3.8872162e-01  2.4866710e+00]
 [ 2.5392172e+01  4.9826989e+00  2.3192320e+00 ... -3.5835370e-01
   9.4126135e-01  1.4343496e-01]
 [ 2.7359493e+01  5.5186005e+00  1.1480473e+00 ...  5.8914202e-01
  -2.0753877e+00  2.3046710e-01]
 ...
 [-3.8266034e+02 -9.6860485e+00  1.7396482e+01 ...  1.3947951e+00
  -8.3887035e-01  9.5944041e-01]
 [-3.8286859e+02 -5.6933088e+00  2.0129442e+01 ... -7.7534288e-01
   1.5140564e+00  1.3752979e+00]
 [-3.8489960e+02 -3.4747849e+00  1.5189555e+00 ...  1.0207459e+00
   6.7454106e-01 -2.0665376e-02]]

We can now plot this array as an image:

In [9]:
fig = plt.figure(figsize=(16,8))
plt.imshow(imgdata, cmap=plt.cm.gray)
plt.colorbar()
plt.clim(0,20000)

Now that we've seen the image and the WCS information, we can plot FFI with a WCS projection. To do this, first we will access the file header and assign a WCS object. Then we will plot the image with the projection, and add labels and a grid for usability:

In [10]:
hdu = fits.open(filename)[1]
wcs = WCS(hdu.header)

fig = plt.figure(figsize=(16,8))
ax = plt.subplot(projection=wcs) 
im = ax.imshow(hdu.data, cmap=plt.cm.gray, origin='lower', clim=(0,20000))
fig.colorbar(im)

plt.title('FFI with WCS Projection')
ax.set_xlabel('RA [deg]')
ax.set_ylabel('Dec [deg]')
ax.grid(color='white', ls='solid')

Getting the Catalog Data

Now that we have an image, we can use astroquery to retrieve a catalog of objects and overlay it onto the image. First, we will start with importing catalog data from astroquery:

In [11]:
from astroquery.mast import Catalogs

We will query a catalog of objects from TIC (TESS Input Catalog). For more information about TIC, follow this link. Our search will be centered on the same RA and Declination listed in the header of the FFI image and will list objects within a 1 degree radius of that location. It might take a couple seconds longer than usual for this cell to run:

why tic??? explain...

In [12]:
catalogData = Catalogs.query_region("290.4620065226813  38.32946356799192", radius="0.7 deg", catalog="TIC")
dattab = Table(catalogData)
dattab
WARNING: InputWarning: Coordinate string is being interpreted as an ICRS coordinate provided in degrees. [astroquery.utils.commons]
Out[12]:
Table masked=True length=104286
IDradecpmRApmDECTmagobjTypetypeSrcversionHIPTYCUCACTWOMASSSDSSALLWISEGAIAAPASSKICPOSflage_pmRAe_pmDECPMflagplxe_plxPARflaggallonggallateclongeclatBmage_BmagVmage_Vmagumage_umaggmage_gmagrmage_rmagimage_imagzmage_zmagJmage_JmagHmage_HmagKmage_KmagTWOMflagproxw1mage_w1magw2mage_w2magw3mage_w3magw4mage_w4magGAIAmage_GAIAmage_TmagTESSflagSPFlagTeffe_Tefflogge_loggMHe_MHrade_radmasse_massrhoe_rholumclasslume_lumde_debve_ebvnumcontcontratiodispositionduplicate_idpriorityeneg_EBVepos_EBVEBVflageneg_Massepos_Masseneg_Radepos_Radeneg_rhoepos_rhoeneg_loggepos_loggeneg_lumepos_lumeneg_distepos_distdistflageneg_Teffepos_TeffTeffFlaggaiabpe_gaiabpgaiarpe_gaiarpgaiaqflagstarchareFlagVmagFlagBmagFlagsplistse_RAe_DecRA_origDec_orige_RA_orige_Dec_origraddflagwdflagdstArcSec
str11float64float64float64float64float64str8str7str8str5str12str10str17str19str19str19str8str7str8float64float64str6float64float64str5float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64str19float64float64float64float64float64float64float64float64float64float64float64float64str5str5float64float64float64float64float64float64float64float64float64float64float64float64str5float64float64float64float64float64float64int64float64str5str9float64float64float64str9float64float64float64float64float64float64float64float64float64float64float64float64str6float64float64str6float64float64float64float64int64str1str8str8str13float64float64float64float64float64float64int64int64float64
1877313283290.46066428261238.3304513142701-5.59848-4.2389419.8414STARgaia220190415--------1237668681001865025--2052812123437410304----gaia21.443521.32282gaia21.039850.761685gaia270.554345558281510.9790727152229302.67088260494659.4705457723064nannan20.87870.082330.050.021.79640.064697920.51540.031357420.01530.033953919.66380.0813132nannannannannannan--nannannannannannannannannan20.5250.0089830.0199gbprpgaia2nannannannannannannannannannannannan--nannan1841.431612.40.1006190.0172583--nan----nan0.02274740.0117692panstarrsnannannannannannannannannannan1032.032192.77bj2018nannan--21.00820.11712819.63490.0773340--gaia2----23.69689038189320.5150830759397290.46063355450538.33043306328230.6632919840107970.683015262352577105.1973452543848815
122451116290.4584967152338.33068497829718.65012-24.038418.0347STARtmgaia220190415------19215005+38195051237668681001865024J192150.05+381950.12052812123437282560--3231494tmgaia23.033213.033hsoynannan--70.553799551826910.9807031882853302.66778906256659.4712359243081nannan20.23610.099130.050.021.17590.040733919.5010.015428218.31250.010429917.59370.016828516.240.10115.5020.12415.50.211ABC-222-111-000-0-0nan15.3090.03415.8260.10812.987nan9.346nan19.11340.0042960.0246gbprp--nannannannannannannannannannannannanDWARFnannannannannannan--nan----nannannan--nannannannannannannannannannannannan--nannan--20.35820.09887217.8520.0166580--gaia2----49.776823995442647.0131691137537290.45854419287938.33058147963920.3586182864002110.3961538443636931010.843322241046469
1877313284290.46345086818838.333894607665nannan20.1338STARgaia220190415--------1237668681001862738--2052812123443670144----gaia2nannan--nannan--70.558468728712810.9786191998283302.67688930071359.473258555749nannan21.57380.392925.3883.5087322.69530.2931721.21430.080494420.37580.06297720.54790.175296nannannannannannan--nannannannannannannannannan20.98360.0227960.1572gbprp--nannannannannannannannannannannannan--nannannannannannan--nan----nannannan--nannannannannannannannannannannannan--nannan--21.99990.5951420.20140.1680951--gaia2----1.799155363085681.98266655600732290.46345086818838.3338946076651.799155363085681.98266655600732-1-116.46494779932391
1877313237290.46577963043638.333369456095-5.74985-0.8327719.7778STARgaia220190415--------1237668681001862736--2052811921572733440----gaia21.538131.47151gaia20.02702280.849165gaia270.558810085682510.9767472865578302.68005292214359.4722538983176nannan20.82060.096230.050.023.53580.28885921.95360.10212720.41760.048509519.62740.0786104nannannannannannan--nannannannannannannannannan20.46950.0087170.0122reredgaia24745.0353.0nannannannannannannannannannanDWARFnannan2649.231783.950.1054960.0105728749--nan----nan0.01258590.00855985panstarrsnannannannannannannannannannan1320.972246.94bj2018nannandered21.04760.14030119.67970.1044861--gaia2----25.250389030526722.8191964347898290.46574807024138.33336587056170.7104659041113460.7017031320277081017.642262557602834
1877313233290.46005929664138.3239464856420.69567-6.7209319.2073STARgaia220190415--------1237668681001862442--2052811917278847104----gaia20.9305960.898581gaia20.5483710.511675gaia270.548179173142710.9766452416167302.66647960211659.4644192265324nannan20.21360.068826.03616.4666420.99670.035280719.79630.018759319.39350.02141930.050.0nannannannannannan--nannannannannannannannannan19.88070.0058770.0099reredgaia24779.0246.0nannannannannannannannannannanDWARFnannan2186.931596.620.08964770.008969205--nan----nan0.008778620.00915979panstarrsnannannannannannannannannannan1053.722139.53bj2018nannandered20.36770.09758919.03820.0485181--gaia2----15.275612989810813.9359218112201290.46006311458938.32391754830430.4008416587128680.4696589405201991020.608759910082256
1877313288290.46481255539638.3350609165607-2.07606-4.3313719.6691STARgaia220190415--------1237668681001862733--2052812127731164032----gaia21.21.11597gaia20.008328570.642526gaia270.560019318926710.9781711049033302.67952834747259.4740884238905nannan20.44480.053622.79960.50248923.83370.37838822.66540.19030622.19760.22128219.61880.0868425nannannannannannan--nannannannannannannannannan20.22050.0085810.0108gbprpgaia2nannannannannannannannannannannannan--nannan2784.961765.610.105660.0101418449--nan----nan0.01161670.00866699panstarrsnannannannannannannannannannan1305.112226.11bj2018nannan--20.47380.05216419.40110.0460160--gaia2----19.69963662205617.3070866361833290.46480115990138.33504226760740.5568048888861730.5749180429688031021.65251951894165
122451103290.46025640249538.3354503381626-7.71635-14.463517.8999STARtmgaia220190415------19215044+38200771237668681001862726--2052812123437286656--3231500tmgaia20.4591840.395206gaia20.2674640.239827gaia270.558778562882210.9815534458876302.67297088693759.475441429227nannan19.21780.051922.79660.34466720.16620.019729818.79870.01006718.24310.0099530317.86030.019737316.5590.12515.631nan15.55nanBUU-200-100-c00-0-0nannannannannannannannannan18.71290.0030060.0085reredgaia24299.0137.04.19359nannannan1.08461nan0.67nan0.525108nanDWARF0.3620055nan2848.511511.220.1057350.00982053--nan----nan0.01092630.00871476panstarrsnannannannannannannannannannan1049.761972.69bj2018nannandered19.49270.03793617.83510.0165821--gaia2----7.538565570503626.12930469396434290.46021404722738.33538806478390.228885184424530.2103836999492291022.111767965456053
1877313234290.47075295151738.3284015295922-3.25061-5.8587219.1856STARgaia220190415--------1237668681001865671--2052811917285285376----gaia21.020750.944207gaia20.7241410.555167gaia270.556006618200510.9710617190306302.68476136958559.4664076030791nannan20.61490.093130.050.021.56860.053509420.10430.022906919.36440.020372518.99340.0463009nannannannannannan--nannannannannannannannannan20.04090.0074750.0107reredgaia24096.0193.04.91751nannannan0.460646nan0.64nan6.54752nanDWARF0.05381086nan1955.321571.550.08859770.00949764--nan----nan0.008981280.010014panstarrsnannannannannannannannannannan982.842160.26bj2018nannandered20.80530.12597619.03270.0320351--gaia2----16.756701743761514.6437721287164290.47073511055638.32837630454890.4758964950760730.500733780865161024.99466042108615
1877313132290.45675055942538.3231172512084nannan20.8515STARgaia220190415------------2052811539328075136----gaia2nannan--nannan--70.546254407029910.9786140404958302.66113108037759.4643314025219nannannannannannannannannannannannannannannannannannannannan--nannannannannannannannannan21.28150.0306030.6goffs--nannannannannannannannannannannannan--nannannannannannan--nan----nannannan--nannannannannannannannannannannannan--nannan--nan0.0nan0.0-1--------3.044321837961344.611955940743290.45675055942538.32311725120843.044321837961344.611955940743-1-127.24536859073852
1877313289290.46286223431238.3374460384942nannan20.4224STARgaia220190415------------2052812127731164800----gaia2nannan--nannan--70.561513238105910.9805922788005302.67792942436659.4768006951368nannannannannannannannannannannannannannannannannannannannan--nannannannannannannannannan20.85240.0157070.6goffs--nannannannannannannannannannannannan--nannannannannannan--nan----nannannan--nannannannannannannannannannannannan--nannan--nan0.0nan0.0-1--------2.244882728769491.51835089648088290.46286223431238.33744603849422.244882728769491.51835089648088-1-128.838311899235126
.......................................................................................................................................................................................................................................................................................................................................................................................
122225751290.03764225415538.9459910728260.962869-5.2732714.2375STARtmgaia220190415----645-06867319200903+38564561237668681538473186J192009.03+385645.52052900844582577408--3845501tmgaia20.05058240.0552166gaia22.22820.0273207gaia270.972260065932411.5448256683107302.37402919674960.153031748204917.2630.16715.5560.0819.00340.024520216.37810.0037277715.07240.0033151814.51190.0034895114.19990.0039521113.0340.01912.3560.02212.2050.024AAA-222-111-000-0-0nan12.1270.02412.1780.02312.3840.349.030.43215.07160.000580.0071reredgaia24115.0122.04.25801nannannan0.984277nan0.64nan0.671164nanDWARF0.2502698nan443.135.40650.06506080.007466585--nan----nan0.008007320.00692585panstarrsnannannannannannannannannannan5.3415.472bj2018nannandered15.88990.00414214.16290.001751--ucac4bpbj--0.8319042118193110.85632405295852290.0376475845938.9459683684690.02266195162827950.0282695191330974102519.9447802784866
1877259433291.34946174878138.2597240157344-1.23279-9.6443219.5916STARgaia220190415------------2052632391943821184----gaia20.8836791.38213gaia2-0.2990160.582096gaia270.804027832481810.3222853354602303.94614187992559.2084644398379nannannannannannannannannannannannannannannannannannannannan--nannannannannannannannannan20.02160.0073680.6goffsgaia2nannannannannannannannannannannannan--nannan3421.282046.650.07893590.0112265646--nan----nan0.0129670.00948613panstarrsnannannannannannannannannannan1544.32548.99bj2018nannan--nan0.0nan0.0-1--------14.504200003965821.4360268351584291.34945498901938.25968249158440.433078160526760.746776263284849-1-12519.948620492277
1877332343290.03863168689338.9464111380468-3.42043-5.471419.4788STARgaia220190415------------2052900878937566976----gaia21.132151.28796gaia2-1.08140.577845gaia270.972986790043711.5443141632723302.37574743356760.1532250122438nannan20.77710.1695nannannannannannannannannannannannannannannannan--nannannannannannannannannan20.27450.0080670.0358gbprpgaia2nannannannannannannannannannannannan--nannan3527.681780.560.09156990.00576449--nan----nan0.005031880.0064971panstarrsnannannannannannannannannannan1395.362165.76bj2018nannan--20.14910.23855718.49540.1486610--gaia2----18.61987518062119.9721235110198290.03861275130938.94638758063150.4991682646092650.590911596627446102519.959550830649
122377612290.40750850233539.028158898732-2.69771-10.275417.958STARtmgaia220190415------19213779+39014121237672005833656901--2052911049425191680--3950604tmgaia20.3384950.404132gaia20.3319580.207957gaia271.175289517833611.3216616314651302.97481578939960.152574415703119.2760.16719.07140.050621.97550.2796919.57240.014395118.57780.0092957118.14610.0091952217.86940.020442716.7990.15216.1910.20616.077nanCDU-220-110-000-0-0nannannannannannannannannan18.68350.0024180.0074reredgaia24649.0142.04.4875nannannan0.81264nan0.74nan1.37892nanDWARF0.277925849nan2594.071306.960.1222110.006243345--nan----nan0.006645280.00584141panstarrsnannannannannannannannannannan887.531726.4bj2018nannandered19.25590.04005917.81340.0119981--gaia2bpbj--5.568652663077266.26770820833369290.4074935504939.0281146574270.1578908272189290.214228603826527102519.9617753331113
1714805900289.78318841777838.7857726441314-0.679935-3.1182219.8288STARgaia220190415--------1237672005296654543--2052893006264843008----gaia21.061291.15511gaia20.583310.620753gaia270.737325519471711.65418481211301.90415001045960.0526880178316nannan20.2970.057721.83250.2047920.58680.02924520.20520.025369320.00120.034186920.10840.112925nannannannannannan--nannannannannannannannannan20.19160.0081630.0124reredgaia2nannannannannannannannannannannannanDWARFnannan2035.861470.170.08835170.0102391448--nan----nan0.0153750.00510329panstarrsnannannannannannannannannannan998.211942.12bj2018nannan--20.47570.09860819.78330.0968391--gaia2----17.445841932747617.9128345213475289.78318466213738.7857592184620.4685007884279520.555953151941086112519.9635117469365
137094375291.23638553964938.6798358231592-2.56177-16.611112.5507STARtmgaia220190415----644-06869219245673+38404741237672005833982749J192456.73+384047.22052749386858274176--3543899tmgaia20.02923320.0312145gaia21.041970.0176103gaia271.146358996735110.5887447049081304.01377958588159.636422173443513.770.06613.1320.10314.91480.0040896213.61390.0027489911.03950.00077595414.84510.01076712.89390.0036750911.9110.02211.5920.01911.5470.021AAA-222-111-000-0-0nan11.4910.02311.510.02111.4870.1449.12nan13.00570.0003980.0067reredgaia25810.0125.0433.807670.0750822nannan2.107240.1081131.040.1296620.1111460.0232654DWARF4.558538440.194777934.0615.4850.04518020.0044744056870.336097628----0.0001918135090.004750630.00419818panstarrs0.1200990.1392240.1167030.09952360.01959260.02693820.05825130.09191320.1669830.22257115.23315.737bj2018122.354127.732dered13.36130.00108212.49240.0006431--ucac4bpbj--0.4804342893992150.484135429914603291.23637141060638.67976430314780.01459046649255690.0173414470571344102519.96565266354
122507569290.44279991249537.62963290493272.10909-1.516816.889STARtmgaia220190415------19214627+37374671237672004223307562--2051100016337336448--2298622tmgaia20.1905620.183468gaia20.2746110.101768gaia269.907157157002310.6836337472224302.27430781508458.799756756955217.8740.10217.75530.046520.11150.053158918.12320.0064690417.37490.0051642917.10620.0053531416.98150.011768515.9920.07915.6280.12115.3780.188ABC-222-222-ccc-0-0nannannannannannannannannan17.49110.001420.0073reredgaia25068.0130.04.15756nannannan1.27339nan0.85nan0.411657nanDWARF0.9637475nan3135.261060.720.07266190.00641808--nan----nan0.00524050.00759566panstarrsnannannannannannannannannannan781.341340.11bj2018nannandered17.98790.01737916.81420.0066371--gaia2bpbj--3.121596103041872.84526690751231290.44281137853437.62962637426650.08458753638256410.0927737164753479102519.9798022255786
506885627291.3272683687838.1614950652001nannan19.2345STARtmgaia220190415------------2052583498035814272----tmgaia2nannan--nannan--70.706777956568510.2940120149486303.85940537204759.1191565745171nannannannannannannannannannannannannannannannannannannannan--nannannannannannannannannan19.66450.0075520.6goffs--nannannannannannannannannannannannan--nannannannannannan--nan--137150139nannannan--nannannannannannannannannannannannan--nannan--nan0.0nan0.0-1--------1.718647511235730.928479528941628291.3272683687838.16149506520011.718647511235730.928479528941628-1-12519.982741185736
1877246899290.8348578314637.6940903043638-2.7012-1.3425518.492STARgaia220190415--------1237668680465255734--2052588510259380480----gaia20.4193980.485564gaia2-0.1319150.22366gaia270.10553383729910.4337354418025302.88456075888558.7778350221698nannan19.29420.048821.35320.12503519.65720.013188519.05970.011523718.77320.012589118.65260.0429256nannannannannannan--nannannannannannannannannan19.05990.0029660.0074reredgaia25296.0165.04.56983nannannan0.819673nan0.91nan1.65242nanDWARF0.476176023nan4546.822029.160.08631620.00501824--nan----nan0.004561490.00547499panstarrsnannannannannannannannannannan1581.962476.35bj2018nannandered19.55010.03240718.45120.0276731--gaia2----6.87123127309387.52979617497824290.83484313366737.69408452394110.1766746004363790.231326164004422102519.983661940871
1876760640290.62270367601237.641019138721-4.50014-6.2383518.8257STARgaia220190415------------2051089119998305152----gaia20.6750750.783666gaia21.019080.349332gaia269.981509757492210.5608072029176302.54498355075858.7723678132332nannan20.09710.0599nannannannannannannannannannannannannannannannan--nannannannannannannannannan19.61670.0042660.0102reredgaia24292.0158.0nannannannannannannannannannanDWARFnannan1120.15842.0910.06936570.0136331255--nan----nan0.01990410.00736215panstarrsnannannannannannannannannannan409.5311274.65bj2018nannandered20.31270.0603818.69770.0305791--gaia2----11.058503709983112.1511310001117290.62267920731437.64099227916110.2883072912025370.323536069929587102519.992459584963


Let's isolate the RA and Dec columns into a separate table for creating a plot. We will can also filter our results to include only sources brigther than 15 magnitudes in B, which will give us a more managable amount of sources for plotting:

In [13]:
radec = (catalogData['ra','dec','Bmag'])
mask = radec['Bmag'] < 15.0
mag_radec = radec[mask]
print(mag_radec)
       ra              dec         Bmag 
---------------- ---------------- ------
290.458960889796 38.3207432262466 14.795
      290.460477        38.341217  12.29
290.461502454307 38.3419735004403 12.282
290.432230727723 38.3148097580226 10.681
290.494195116716 38.2920041448032 13.699
290.496059793679 38.2919210910981 14.087
290.443098867166 38.2822568081951 14.969
290.521274498376 38.3494190597979 14.955
290.504480006636  38.285889095025 14.606
290.532642166954 38.3355127573579 14.949
             ...              ...    ...
289.590911103748 38.1881022930383 11.335
290.306587556824 39.0173981951521  13.86
290.184665659664 37.6659519634293 13.844
289.936400777672 37.7666504310144 11.746
291.204885466546 37.9462411035449 14.959
289.649785584226 38.6194462641562 14.181
290.971812833805 38.9040904333617 11.895
290.715859496994 39.0001067594711  14.99
291.335931393104 38.4717438108292 13.556
 290.29450911539 39.0171022462603 13.295
291.236385539649 38.6798358231592  13.77
Length = 1330 rows
/opt/conda/envs/notebooks_env/lib/python3.6/site-packages/astropy/table/column.py:991: RuntimeWarning: invalid value encountered in less
  result = getattr(super(), op)(other)


We can plot this table to get an idea of what the catalog looks like visually:

In [14]:
fig = plt.figure(figsize=(8,8))
ax = fig.add_subplot(111)
plt.scatter(mag_radec['ra'], mag_radec['dec'], facecolors='none', edgecolors='c', linewidths=0.5)
Out[14]:
<matplotlib.collections.PathCollection at 0x7f9715557940>

Overplotting Objects

Now that we have a way to display an FFI file and a catalog of objects, we can put the two pieces of data on the same plot. To do this, we will project the World Coordinate System (WCS) as a grid in units of degrees, minutes, and seconds onto the image. Then, we will create a scatter plot of the catalog, similar to the one above, although here we will transform its coordinate values into ICRS (International Celestial Reference System) to be compatible with the WCS projection:

In [15]:
hdu = fits.open(filename)[1]
wcs = WCS(hdu.header)

fig = plt.figure(figsize=(20,10))
ax = plt.subplot(projection=wcs) 
im = ax.imshow(hdu.data, cmap=plt.cm.gray, origin='lower', clim=(0,20000))
fig.colorbar(im)

plt.title('FFI with TIC Catalog Objects')
ax.set_xlabel('RA [deg]')
ax.set_ylabel('Dec [deg]')
ax.grid(color='white', ls='solid')
ax.autoscale(False)

ax.scatter(mag_radec['ra'], mag_radec['dec'],
           facecolors='none', edgecolors='c', linewidths=0.5,
           transform=ax.get_transform('icrs')) # This is needed when projecting onto axes with WCS info
Out[15]:
<matplotlib.collections.PathCollection at 0x7f97154756a0>