Python Interface

Python Interface

class kplr.API(data_root=None)

Interface with MAST and Exoplanet Archive APIs.

Parameters:data_root – (optional) The local base directory where any data should be downloaded to. This can also be set using the KPLR_ROOT environment variable. The default value is ~/.kplr.
ea_request(table, sort=None, **params)

Submit a request to the Exoplanet Archive API and return a dictionary.

Parameters:
  • table – The table that you want to search.
  • **params

    Any other search parameters.

koi(koi_number)

Find a single KOI given a KOI number (e.g. 145.01).

Parameters:koi_number – The number identifying the KOI. This should be a float with the .0N for some value of N.
kois(**params)

Get a list of KOIs from The Exoplanet Archive.

Parameters:**params

The search parameters for the Exoplanet Archive API.

light_curves(kepler_id, short_cadence=True, fetch=False, clobber=False)

Find the set of light curves associated with a KIC target.

Parameters:
  • kepler_id – The KIC ID of the target star.
  • short_cadence – A boolean flag that determines whether or not the short cadence data should be included. (default: True)
  • fetch – A boolean flag that determines whether or not the data file should be downloaded.
  • clobber – A boolean flag that determines whether or not the data file should be overwritten even if it already exists.
mast_request(category, adapter=None, sort=None, **params)

Submit a request to the MAST API and return a dictionary of parameters.

Parameters:
  • category – The table that you want to search.
  • **params

    Any other search parameters.

planet(name)

Get a planet by the Kepler name (e.g. “6b” or “Kepler-62b”).

Parameters:name – The name of the planet.
planets(**params)

Get a list of confirmed (Kepler) planets from MAST.

Parameters:**params

The search parameters for the MAST API.

star(kepid)

Get a KIC target by id from MAST.

Parameters:kepid – The integer ID of the star in the KIC.
stars(**params)

Get a list of KIC targets from MAST. Only return up to 100 results by default.

Parameters:**params

The query parameters for the MAST API.

target_pixel_files(kepler_id, short_cadence=True, fetch=False, clobber=False)

Find the set of target pixel files associated with a KIC target.

Parameters:
  • kepler_id – The KIC ID of the target star.
  • short_cadence – A boolean flag that determines whether or not the short cadence data should be included. (default: True)
  • fetch – A boolean flag that determines whether or not the data file should be downloaded.
  • clobber – A boolean flag that determines whether or not the data file should be overwritten even if it already exists.

Kepler Objects of Interest

class kplr.KOI(*args, **params)

A model specifying a Kepler Object of Interest (KOI).

get_light_curves(short_cadence=True, fetch=False, clobber=False)

Get a list of light curve datasets for the model and optionally download the FITS files.

Parameters:
  • short_cadence – A boolean flag that determines whether or not the short cadence data should be included. (default: True)
  • fetch – A boolean flag that determines whether or not the data file should be downloaded.
  • clobber – A boolean flag that determines whether or not the data file should be overwritten even if it already exists.
get_target_pixel_files(short_cadence=True, fetch=False, clobber=False)

Get a list of target pixel datasets for the model and optionally download the FITS files.

Parameters:
  • short_cadence – A boolean flag that determines whether or not the short cadence data should be included. (default: True)
  • fetch – A boolean flag that determines whether or not the data file should be downloaded.
  • clobber – A boolean flag that determines whether or not the data file should be overwritten even if it already exists.
star

The Star entry from the Kepler Input Catalog associated with this object.

Confirmed Planets

class kplr.Planet(*args, **params)

A confirmed planet from the MAST confirmed_planets table. This table has far less—and far less accurate—information than the KOI table so it’s generally a good idea to use the koi property to access the catalog values.

get_light_curves(short_cadence=True, fetch=False, clobber=False)

Get a list of light curve datasets for the model and optionally download the FITS files.

Parameters:
  • short_cadence – A boolean flag that determines whether or not the short cadence data should be included. (default: True)
  • fetch – A boolean flag that determines whether or not the data file should be downloaded.
  • clobber – A boolean flag that determines whether or not the data file should be overwritten even if it already exists.
get_target_pixel_files(short_cadence=True, fetch=False, clobber=False)

Get a list of target pixel datasets for the model and optionally download the FITS files.

Parameters:
  • short_cadence – A boolean flag that determines whether or not the short cadence data should be included. (default: True)
  • fetch – A boolean flag that determines whether or not the data file should be downloaded.
  • clobber – A boolean flag that determines whether or not the data file should be overwritten even if it already exists.
koi

The KOI entry that led to this planet. The KOI table is much more complete so the use of this object tends to be preferred over the built in Planet property values.

star

The Star entry from the Kepler Input Catalog associated with this object.

Kepler Input Catalog Targets

class kplr.Star(*args, **params)

A star from the Kepler Input Catalog (KIC).

get_light_curves(short_cadence=True, fetch=False, clobber=False)

Get a list of light curve datasets for the model and optionally download the FITS files.

Parameters:
  • short_cadence – A boolean flag that determines whether or not the short cadence data should be included. (default: True)
  • fetch – A boolean flag that determines whether or not the data file should be downloaded.
  • clobber – A boolean flag that determines whether or not the data file should be overwritten even if it already exists.
get_target_pixel_files(short_cadence=True, fetch=False, clobber=False)

Get a list of target pixel datasets for the model and optionally download the FITS files.

Parameters:
  • short_cadence – A boolean flag that determines whether or not the short cadence data should be included. (default: True)
  • fetch – A boolean flag that determines whether or not the data file should be downloaded.
  • clobber – A boolean flag that determines whether or not the data file should be overwritten even if it already exists.
kois

The list of KOI entries found in this star’s light curve.

Datasets

class kplr.LightCurve(*args, **params)

A reference to a light curve dataset on the MAST severs. This object handles local caching of the file in a strict directory structure.

fetch(clobber=False)

Download the data file from the server and save it locally. The local file will be saved in the directory specified by the data_root property of the API.

Parameters:clobber – Should an existing local file be overwritten? (default: False)
filename

The local filename of the data file. This file is only guaranteed to exist after fetch() has been called.

get_light_curves(short_cadence=True, fetch=False, clobber=False)

Get a list of light curve datasets for the model and optionally download the FITS files.

Parameters:
  • short_cadence – A boolean flag that determines whether or not the short cadence data should be included. (default: True)
  • fetch – A boolean flag that determines whether or not the data file should be downloaded.
  • clobber – A boolean flag that determines whether or not the data file should be overwritten even if it already exists.
get_target_pixel_files(short_cadence=True, fetch=False, clobber=False)

Get a list of target pixel datasets for the model and optionally download the FITS files.

Parameters:
  • short_cadence – A boolean flag that determines whether or not the short cadence data should be included. (default: True)
  • fetch – A boolean flag that determines whether or not the data file should be downloaded.
  • clobber – A boolean flag that determines whether or not the data file should be overwritten even if it already exists.
open(clobber=False, **kwargs)

Open the FITS data file and return the pyfits.HDUList. This will download the file if it isn’t already saved locally.

Parameters:
  • clobber – Overwrite the local file even if it exists? This can be helpful if the file gets corrupted somehow.
  • **kwargs

    Any keyword arguments that you would like to pass to the pyfits.open() function.

url

The remote URL for the data file on the MAST servers.

class kplr.TargetPixelFile(*args, **params)

A reference to a target pixel dataset on the MAST severs. Like the LightCurve object, this object handles local caching of the file in a strict directory structure.

fetch(clobber=False)

Download the data file from the server and save it locally. The local file will be saved in the directory specified by the data_root property of the API.

Parameters:clobber – Should an existing local file be overwritten? (default: False)
filename

The local filename of the data file. This file is only guaranteed to exist after fetch() has been called.

get_light_curves(short_cadence=True, fetch=False, clobber=False)

Get a list of light curve datasets for the model and optionally download the FITS files.

Parameters:
  • short_cadence – A boolean flag that determines whether or not the short cadence data should be included. (default: True)
  • fetch – A boolean flag that determines whether or not the data file should be downloaded.
  • clobber – A boolean flag that determines whether or not the data file should be overwritten even if it already exists.
get_target_pixel_files(short_cadence=True, fetch=False, clobber=False)

Get a list of target pixel datasets for the model and optionally download the FITS files.

Parameters:
  • short_cadence – A boolean flag that determines whether or not the short cadence data should be included. (default: True)
  • fetch – A boolean flag that determines whether or not the data file should be downloaded.
  • clobber – A boolean flag that determines whether or not the data file should be overwritten even if it already exists.
open(clobber=False, **kwargs)

Open the FITS data file and return the pyfits.HDUList. This will download the file if it isn’t already saved locally.

Parameters:
  • clobber – Overwrite the local file even if it exists? This can be helpful if the file gets corrupted somehow.
  • **kwargs

    Any keyword arguments that you would like to pass to the pyfits.open() function.

url

The remote URL for the data file on the MAST servers.

Fork me on GitHub