lightkurve.LightCurve#

class lightkurve.LightCurve(data=None, *args, time=None, flux=None, flux_err=None, **kwargs)[source]#

Subclass of AstroPy Table guaranteed to have time, flux, and flux_err columns.

Compared to the generic TimeSeries class, LightCurve ensures that each object has time, flux, and flux_err columns. These three columns are special for two reasons: 1. they are the key columns upon which all light curve operations operate; 2. they are always present (though they may be populated with NaN values).

LightCurve objects also provide user-friendly attribute access to columns and meta data.

Parameters
datanumpy ndarray, dict, list, Table, or table-like object, optional

Data to initialize time series. This does not need to contain the times or fluxes, which can be provided separately, but if it does contain the times and fluxes they should be in columns called 'time', 'flux', and 'flux_err' to be automatically recognized.

timeTime or iterable

Time values. They can either be given directly as a Time array or as any iterable that initializes the Time class.

fluxQuantity or iterable

Flux values for every time point.

flux_errQuantity or iterable

Uncertainty on each flux data point.

**kwargsdict

Additional keyword arguments are passed to QTable.

Notes

Attribute access: You can access a column or a meta value directly as an attribute.

>>> lc.flux    # shortcut for lc['flux']   
>>> lc.sector  # shortcut for lc.meta['SECTOR']   
>>> lc.flux = lc.flux * 1.05  # update the values of a column.   

In case the given name is both a column name and a key in meta, the column will be returned.

Note that you cannot create a new column using the attribute interface. If you do so, a new attribute is created instead, and a warning is raised.

If you do create such attributes on purpose, please note that the attributes are not carried over when the lightcurve object is copied, or a new lightcurve object is derived based on a copy, e.g., normalize().

Examples

>>> import lightkurve as lk
>>> lc = lk.LightCurve(time=[1, 2, 3, 4], flux=[0.98, 1.02, 1.03, 0.97])
>>> lc.time
<Time object: scale='tdb' format='jd' value=[1. 2. 3. 4.]>
>>> lc.flux
<Quantity [0.98, 1.02, 1.03, 0.97]>
>>> lc.bin(time_bin_size=2, time_bin_start=0.5).flux
<Quantity [1., 1.]>
Attributes
metadict

meta data associated with the lightcurve. The header of the underlying FITS file (if applicable) is store in this dictionary. By convention, keys in this dictionary are usually in uppercase.

__init__(data=None, *args, time=None, flux=None, flux_err=None, **kwargs)[source]#

Methods

__init__([data, time, flux, flux_err])

add_column(*args, **kwargs)

See add_column().

add_columns(*args, **kwargs)

See add_columns().

add_index(colnames[, engine, unique])

Insert a new index among one or more columns.

add_row([vals, mask])

Add a new row to the end of the table.

append(others[, inplace])

Append one or more other LightCurve object(s) to this one.

argsort([keys, kind, reverse])

Return the indices which would sort the table according to one or more key columns.

as_array([keep_byteorder, names])

Return a new copy of the table in the form of a structured np.ndarray or np.ma.MaskedArray object (as appropriate).

bin([time_bin_size, time_bin_start, ...])

Bins a lightcurve in equally-spaced bins in time.

convert_bytestring_to_unicode()

Convert bytestring columns (dtype.kind='S') to unicode (dtype.kind='U') using UTF-8 encoding.

convert_unicode_to_bytestring()

Convert unicode columns (dtype.kind='U') to bytestring (dtype.kind='S') using UTF-8 encoding.

copy([copy_data])

Return a copy of the table.

create_transit_mask(period, transit_time, ...)

Returns a boolean array that is True during transits and False elsewhere.

errorbar([linestyle])

Plots the light curve using Matplotlib's errorbar method.

estimate_cdpp([transit_duration, ...])

Estimate the CDPP noise metric using the Savitzky-Golay (SG) method.

field(item)

Return column[item] for recarray compatibility.

fill_gaps([method])

Fill in gaps in time.

filled([fill_value])

Return copy of self, with masked values filled.

flatten([window_length, polyorder, ...])

Removes the low frequency trend using scipy's Savitzky-Golay filter.

fold([period, epoch_time, epoch_phase, ...])

Returns a FoldedLightCurve object folded on a period and epoch.

from_pandas(df[, time_scale])

Convert a DataFrame to a astropy.timeseries.TimeSeries.

from_stingray(lc)

Create a new LightCurve from a stingray.Lightcurve.

from_timeseries(ts)

Creates a new LightCurve from an AstroPy TimeSeries object.

group_by(keys)

Group this table by the specified keys

head([n])

Return the first n rows.

index_column(name)

Return the positional index of column name.

index_mode(mode)

Return a context manager for an indexing mode.

insert_row(index[, vals, mask])

Add a new row before the given index position in the table.

interact_bls([notebook_url, minimum_period, ...])

Display an interactive Jupyter Notebook widget to find planets.

items()

itercols()

Iterate over the columns of this table.

iterrows(*names)

Iterate over rows of table returning a tuple of values for each row.

keep_columns(names)

Keep only the columns specified (remove the others).

keys()

more([max_lines, max_width, show_name, ...])

Interactively browse table with a paging interface.

normalize([unit])

Returns a normalized version of the light curve.

pformat([max_lines, max_width, show_name, ...])

Return a list of lines for the formatted string representation of

pformat_all([max_lines, max_width, ...])

Return a list of lines for the formatted string representation of

plot(**kwargs)

Plot the light curve using Matplotlib's plot method.

plot_river(period[, epoch_time, ax, ...])

Plot the light curve as a river plot.

pprint([max_lines, max_width, show_name, ...])

Print a formatted string representation of the table.

pprint_all([max_lines, max_width, ...])

Print a formatted string representation of the entire table.

query_solar_system_objects([cadence_mask, ...])

Returns a list of asteroids or comets which affected the light curve.

read(filename[, time_column, time_format, ...])

Read and parse a file and returns a astropy.timeseries.TimeSeries.

remove_column(name)

Remove a column from the table.

remove_columns(names)

Remove several columns from the table.

remove_indices(colname)

Remove all indices involving the given column.

remove_nans([column])

Removes cadences where column is a NaN.

remove_outliers([sigma, sigma_lower, ...])

Removes outlier data points using sigma-clipping.

remove_row(index)

Remove a row from the table.

remove_rows(row_specifier)

Remove rows from the table.

rename_column(name, new_name)

Rename a column.

rename_columns(names, new_names)

Rename multiple columns.

replace_column(name, col[, copy])

Replace column name with the new col object.

reverse()

Reverse the row order of table rows.

round([decimals])

Round numeric columns in-place to the specified number of decimals.

scatter([colorbar_label, show_colorbar])

Plots the light curve using Matplotlib's scatter method.

search_neighbors([limit, radius])

Search the data archive at MAST for the most nearby light curves.

select_flux(flux_column[, flux_err_column])

Assign a different column to be the flux column.

show_in_browser([max_lines, jsviewer, ...])

Render the table in HTML and show it in a web browser.

show_in_notebook([tableid, css, ...])

Render the table in HTML and show it in the IPython notebook.

show_properties()

Prints a description of all non-callable attributes.

sort([keys, kind, reverse])

Sort the table according to one or more keys.

tail([n])

Return the last n rows.

to_corrector([method])

Returns a corrector object to remove instrument systematics.

to_csv([path_or_buf])

Writes the light curve to a CSV file.

to_excel(path_or_buf, **kwargs)

Shorthand for to_pandas().to_excel().

to_fits([path, overwrite, flux_column_name])

Converts the light curve to a FITS file in the Kepler/TESS file format.

to_pandas(**kwargs)

Converts the light curve to a Pandas DataFrame object.

to_periodogram([method])

Converts the light curve to a Periodogram power spectrum object.

to_seismology(**kwargs)

Returns a Seismology object for estimating quick-look asteroseismic quantities.

to_stingray()

Returns a stingray.Lightcurve object.

to_table()

to_timeseries()

Deprecated since version 2.0.

truncate([before, after, column])

Truncates the light curve before and after some time value.

update(other[, copy])

Perform a dictionary-style update and merge metadata.

values()

values_equal(other)

Element-wise comparison of table with another table, list, or scalar.

Attributes

ColumnClass

PDCSAP_FLUX

Deprecated since version 2.0.

SAP_FLUX

Deprecated since version 2.0.

astropy_time

Deprecated since version 2.0.

colnames

dtype

flux

Brightness values stored as an AstroPy Quantity object.

flux_err

Brightness uncertainties stored as an AstroPy Quantity object.

flux_quantity

Deprecated since version 2.0.

flux_unit

Deprecated since version 2.0.

groups

has_masked_columns

True if table has any MaskedColumn columns.

has_masked_values

True if column in the table has values which are masked.

has_mixin_columns

True if table has any mixin columns (defined as columns that are not Column subclasses).

hdu

Deprecated since version 2.0.

iloc

Return a TableILoc object that can be used for retrieving indexed rows in the order they appear in the index.

indices

Return the indices associated with columns of the table as a TableIndices object.

info

loc

Return a TableLoc object that can be used for retrieving rows by index in a given data range.

loc_indices

Return a TableLocIndices object that can be used for retrieving the row indices corresponding to given table index key value or values.

mask

masked

meta

pprint_exclude_names

Maintain tuple that controls table column visibility for print output.

pprint_include_names

Maintain tuple that controls table column visibility for print output.

time

Time values stored as an AstroPy Time object.

time_format

Deprecated since version 2.0.

time_scale

Deprecated since version 2.0.

write