Skip to content

Documentation for KeplerFFI

Class that works with Kepler's EXBA data, to identify observed sources using Gaia

catalogs, and create light curves from simple aperture photometry.

__init__(self, channel=53, quarter=5, magnitude_limit=20, gaia_dr=3) special

Parameters:

Name Type Description Default
channel int

Channel number of the EXBA image.

53
quarter int

Quarter number of the EXBA image.

5
magnitude_limit float

Limiting magnitude in g band used when querying Gaia catalogs, default is 20 mag.

20
gaia_dr int

Gaia data release, dafult is EDR3.

3

Attributes:

Name Type Description
quarter int

Channel number of the EXBA image.

channel int

Quarter number of the EXBA image.

gaia_dr int

Gaia data release, dafult is EDR3.

tpfs lightkurve.TargetPixelFileCollection

Collection of 4 TPFs that form the full EXBA mask.

time numpy.ndarray

Data array containing the time values.

cadences numpy.ndarray

Data array containing the cadence numbers.

row numpy.ndarray

Data array containing the valid pixel row numbers. Has shape of [n_pixels].

column numpy.ndarray

Data array containing the valid pixel columns numbers. Has shape of [n_pixels].

flux numpy.ndarray

Data array containing the valid image fluxes. Has shape of [n_times, n_pixels].

flux_err numpy.ndarray

Data array containing the valid image flux errors. Has shape of [n_times, n_pixels].

ra numpy.ndarray

Data array containing the valid RA pixel values. Has shape of [n_pixels].

dec numpy.ndarray

Data array containing the valid Dec pixel values. Has shape of [n_pixels].

dx numpy.ndarray

Distance between pixel and source coordinates, units of pixels. Has shape of [n_sources, n_pixels]

dy numpy.ndarray

Distance between pixel and source coordinates, units of pixels. Has shape of [n_sources, n_pixels]

r numpy.ndarray

Radial distance between pixel and source coordinates (polar coordinates), in units of pixels.

phi numpy.ndarray

Angle between pixel and source coordinates (polar coordinates), in units of radians

n_sources int

Number of sources in Gaia catalog observed in the EXBA mask.

n_rows int

Number rows in the EXBA image.

n_columns int

Number columns in the EXBA image.

aperture_mask numpy.ndarray

Data array with the source aperture masks. Has shape of [n_sources, n_pixels]

FLFRCSAP numpy.array

Data array with the completeness metric for every source computed from the photometric aperture.

CROWDSAP numpy.array

Data array with the contamination metric for every source computed from the photometric aperture.

_clean_source_list(self, sources, ra, dec) private

Function to clean surces from the catalog removing sources outside the image

coverage (allowing for sources up to 4" outside the mask), and to remove blended sources (within 2").

Parameters:

Name Type Description Default
sources pandas.DataFrame

Catalog with sources to be removed

required
ra numpy.ndarray

Data array with values of RA for every pixel in the image.

required
dec numpy.ndarray

Data array with values of Dec for every pixel in the image.

required

Returns:

Type Description
pandas.DataFrame

Clean catalog

_convert_to_wcs(self, tpfs, row, col) private

Function to convert pixel number to RA and Dec values using the WCS solution

embedded in the TPFs.

Parameters:

Name Type Description Default
tpfs list of TPFs or TargetPixelFileCollection

A list of TPFs that contain the EXBA tiles.

required
row numpy.ndarray

Data aray with the row pixel values to be converted to RA & Dec.

required
col numpy.ndarray

Data aray with the column pixel values to be converted to RA & Dec.

required

Returns:

Type Description
numpy.ndarray

Right Ascension coordinate obtained from the WCS solution.

_do_query(self, ra, dec, epoch=2020, magnitude_limit=20, load=True) private

Calculate ra, dec coordinates and search radius to query Gaia catalog.

Parameters:

Name Type Description Default
ra numpy.ndarray

Right ascension coordinate of pixels to do Gaia search

required
dec numpy.ndarray

Declination coordinate of pixels to do Gaia search

required
epoch float

Epoch of obervation in Julian Days of ra, dec coordinates, will be used to propagate proper motions in Gaia.

2020
magnitude_limit int

Limiting magnitued for query

20
load boolean

Load or not the saved query. Set to False if want to force to run new queries.

True

Returns:

Type Description
pandas.DataFrame

Catalog with query result

_parse_TPFs_channel(self, tpfs) private

Function to parse the TPFs containing the EXBA masks (4 per channel) and

tile them.

Parameters:

Name Type Description Default
tpfs list of TPFs or TargetPixelFileCollection

A list of TPFs that contain the 4 EXBA mask per channel.

required

Returns:

Type Description
numpy.ndarray

Data array containing the time values.

_preprocess(self, times, cadences, flux, flux_err) private

Function to clean pixels with nan values and bad cadences. It Returns the same

input arrays but cleaned.

Parameters:

Name Type Description Default
times numpy.ndarray

Data array with the time values.

required
cadences numpy.ndarray

Data array with the cadence numbers.

required
flux numpy.ndarray

Data array with the image flux.

required
flux_err numpy.ndarray

Data array with the image flux errors.

required

Returns:

Type Description
numpy.ndarray

Data array with the time values.

apply_CBV(self, do_under=False, plot=True)

Applies CBV corrections to all the light curves in self.lcs. It optimizes

the alpha parameter for each correction, if optimization fails, uses the alpha value calculated for previous light curve. It creates class attributes to access the CBV-corrected light curves, and under/over fitting metrics.

Parameters:

Name Type Description Default
do_under boolean

Compute or not the under-fitting metric for the CBV correction.

False
plot boolean

Plot or not CBVcorrector diagnostic figures.

True

create_lcs(self, aperture_mask)

Funciton to create lightkurve.LightCurve with the light curves using aperture

photometry. It creates a class attribute self.lcs that is a lk.LightCurveCollection with the light curves of all input sources.

Parameters:

Name Type Description Default
aperture_mask numpy.ndarray

Boolean mask of shape [n_sources, n_pixels] that has the aperture mask to be used to compute photometry for a set of sources.

required

do_photometry(self, aperture_mask)

Function to do aperture photometry on a set of sources. It creates/update class

attributes that contains the SAP flux, errors, and aperture masks.

Parameters:

Name Type Description Default
aperture_mask numpy.ndarray

Boolean mask of shape [n_sources, n_pixels] that has the aperture mask to be used to compute photometry for a set of sources.

required

download_exba(channel=1, quarter=5) staticmethod

Download EXBA fits file to a dedicated quarter/channel directory

It uses a exba_tpfs_info.csv to map the quarter/channel to the corresponding file names in MAST archive.

Parameters:

Name Type Description Default
channel int

Number of channel to be download, valid numbers are bwtween 1 and 84.

1
quarter int

Number of quarter to be download, valid numbers are bwtween 1 and 17.

5

image_to_fits(self, path=None, overwrite=False)

Creates a FITS file that contains the time-average imagege of the EXBA mask

in a ImageHDU, and the source catalog in a BinTableHDU.

Parameters:

Name Type Description Default
path string

Directory path where to save the FITS file.

None
overwrite bool

Overwrite the output file.

False

Returns:

Type Description
ImageHDU

An Image header unit containing the EXBA flux.

plot_image(self, frame=0, sources=True, ax=None)

Function to plot the full EXBA image and the Gaia Sources.

Parameters:

Name Type Description Default
frame int

Frame number. The default is 0, i.e. the first frame.

0
sources boolean

Whether to overplot or not the source catalog

True
ax matplotlib.axes

Matlotlib axis can be provided, if not one will be created and returned

None

Returns:

Type Description
matplotlib.axes

Matlotlib axis with the figure

plot_lightcurve(self, source_idx=0, ax=None)

Creates a figure with the light curve of a given source.

mask.

Parameters:

Name Type Description Default
source_idx int

Index of the source in self.sources catalog to be plotted.

0
ax matplotlib.axes

Matlotlib axis can be provided, if not one will be created and returned.

None

Returns:

Type Description
matplotlib.axes

Matlotlib axis with the figure

plot_stamp(self, source_idx=0, aperture_mask=False, ax=None)

Creates a figure with the "stamp" image of a given source and its aperture

mask.

Parameters:

Name Type Description Default
source_idx int

Index of the source in self.sources catalog to be plotted.

0
aperture_mask boolean

Plot or not the aperutre mask.

False
ax matplotlib.axes

Matlotlib axis can be provided, if not one will be created and returned.

None

Returns:

Type Description
matplotlib.axes

Matlotlib axis with the figure