lightkurve.KeplerTargetPixelFile#

class lightkurve.KeplerTargetPixelFile(path, quality_bitmask='default', **kwargs)[source]#

Class to read and interact with the pixel data products (“Target Pixel Files”) created by NASA’s Kepler pipeline.

This class offers a user-friendly way to open a Kepler Target Pixel File (TPF), access its meta data, visualize its contents, extract light curves with custom aperture masks, estimate centroid positions, and more.

Please consult the TargetPixelFile tutorial in the online documentation for examples on using this class.

Parameters
pathstr or HDUList

Path to a Kepler Target Pixel file. Alternatively, you can pass a HDUList object, which is the AstroPy object returned by the astropy.io.fits.open function.

quality_bitmask“none”, “default”, “hard”, “hardest”, or int

Bitmask that should be used to ignore bad-quality cadences. If a string is passed, it has the following meaning:

  • “none”: no cadences will be ignored (equivalent to quality_bitmask=0).

  • “default”: cadences with severe quality issues will be ignored (equivalent to quality_bitmask=1130799).

  • “hard”: more conservative choice of flags to ignore (equivalent to quality_bitmask=1664431). This is known to remove good data.

  • “hardest”: remove all cadences that have one or more flags raised (equivalent to quality_bitmask=2096639). This mask is not recommended because some quality flags can safely be ignored.

If an integer is passed, it will be used as a bitmask, i.e. it will have the effect of removing cadences where (tpf.hdu[1].data['QUALITY'] & quality_bitmask) > 0. See the KeplerQualityFlags class for details on the bitmasks.

**kwargsdict

Optional keyword arguments passed on to astropy.io.fits.open.

References

1

Kepler: A Search for Terrestrial Planets. Kepler Archive Manual. http://archive.stsci.edu/kepler/manuals/archive_manual.pdf

__init__(path, quality_bitmask='default', **kwargs)[source]#

Methods

__init__(path[, quality_bitmask])

animate([step, interval])

Displays an interactive HTML matplotlib animation.

create_threshold_mask([threshold, ...])

Returns an aperture mask creating using the thresholding method.

cutout([center, size])

Cut a rectangle out of the Target Pixel File.

estimate_background([aperture_mask])

Returns an estimate of the median background level in the FLUX column.

estimate_centroids([aperture_mask, method])

Returns the flux center of an object inside aperture_mask.

extract_aperture_photometry([aperture_mask, ...])

Returns a LightCurve obtained using aperture photometry.

extract_prf_photometry([cadences, parallel])

Returns the results of PRF photometry applied to the pixel file.

from_fits_images(images_flux, position[, ...])

Creates a new Target Pixel File from a set of images.

get_bkg_lightcurve([aperture_mask])

get_coordinates([cadence])

Returns two 3D arrays of RA and Dec values in decimal degrees.

get_header([ext])

Returns the metadata embedded in the file.

get_keyword(keyword[, hdu, default])

Returns a header keyword value.

get_model([star_priors])

Returns a default TPFModel object for PRF fitting.

get_prf_model()

Returns an object of KeplerPRF initialized using the necessary metadata in the tpf object.

interact([notebook_url, max_cadences, ...])

Display an interactive Jupyter Notebook widget to inspect the pixel data.

interact_sky([notebook_url, aperture_mask, ...])

Display a Jupyter Notebook widget showing Gaia DR2 positions on top of the pixels.

plot([ax, frame, cadenceno, bkg, column, ...])

Plot the pixel data for a single frame (i.e.

plot_pixels([ax, periodogram, ...])

Show the light curve of each pixel in a single plot.

prf_lightcurve(**kwargs)

query_solar_system_objects([cadence_mask, ...])

Returns a list of asteroids or comets which affected the target pixel files.

show_properties()

Prints a description of all non-callable attributes.

to_corrector([method])

Returns a Corrector instance to remove systematics.

to_fits([output_fn, overwrite])

Writes the TPF to a FITS file on disk.

to_lightcurve([method, corrector])

Performs photometry on the pixel data and returns a LightCurve object.

Attributes

astropy_time

Deprecated since version 2.0.

cadenceno

Return the cadence number for all good-quality cadences.

campaign

K2 Campaign number.

channel

Kepler CCD channel number.

column

CCD pixel column number ('1CRV5P' header keyword).

dec

Declination of target ('DEC_OBJ' header keyword).

flux

Returns the flux for all good-quality cadences.

flux_bkg

Returns the background flux for all good-quality cadences.

flux_bkg_err

flux_err

Returns the flux uncertainty for all good-quality cadences.

hdu

header

Deprecated since version 2.0.

mission

'Kepler' or 'K2'.

module

Kepler CCD module number.

nan_time_mask

Returns a boolean mask flagging cadences whose time is nan.

obsmode

'short cadence' or 'long cadence'.

output

Kepler CCD module output number.

pipeline_mask

Returns the optimal aperture mask used by the pipeline.

pos_corr1

Returns the column position correction.

pos_corr2

Returns the row position correction.

quality

Returns the quality flag integer of every good cadence.

quarter

Kepler quarter number.

ra

Right Ascension of target ('RA_OBJ' header keyword).

row

CCD pixel row number ('2CRV5P' header keyword).

shape

Return the cube dimension shape.

time

Returns the time for all good-quality cadences.

wcs

Returns an astropy.wcs.WCS object with the World Coordinate System solution for the target pixel file.