lightkurve.LightCurve#
- class lightkurve.LightCurve(data=None, *args, time=None, flux=None, flux_err=None, **kwargs)[source]#
Subclass of AstroPy
Tableguaranteed to have time, flux, and flux_err columns.Compared to the generic
TimeSeriesclass,LightCurveensures that each object hastime,flux, andflux_errcolumns. 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 withNaNvalues).LightCurveobjects 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.- time
Timeor iterable Time values. They can either be given directly as a
Timearray or as any iterable that initializes theTimeclass.- flux
Quantityor iterable Flux values for every time point.
- flux_err
Quantityor iterable Uncertainty on each flux data point.
- **kwargsdict
Additional keyword arguments are passed to
QTable.
- datanumpy ndarray, dict, list,
Notes
Attribute access: You can access a column or a
metavalue 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
- meta
dict 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.
- meta
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
LightCurveobject(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
Trueduring transits andFalseelsewhere.errorbar([linestyle])Plots the light curve using Matplotlib's
errorbarmethod.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
FoldedLightCurveobject folded on a period and epoch.from_pandas(df[, time_scale])Convert a
DataFrameto aastropy.timeseries.TimeSeries.from_stingray(lc)Create a new
LightCurvefrom astingray.Lightcurve.from_timeseries(ts)Creates a new
LightCurvefrom an AstroPyTimeSeriesobject.group_by(keys)Group this table by the specified
keyshead([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
indexposition 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
plotmethod.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
columnis 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
namewith the newcolobject.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
scattermethod.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
DataFrameobject.to_periodogram([method])Converts the light curve to a
Periodogrampower spectrum object.to_seismology(**kwargs)Returns a
Seismologyobject for estimating quick-look asteroseismic quantities.to_stingray()Returns a
stingray.Lightcurveobject.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
ColumnClassPDCSAP_FLUXDeprecated since version 2.0.
SAP_FLUXDeprecated since version 2.0.
astropy_timeDeprecated since version 2.0.
colnamesdtypeBrightness values stored as an AstroPy
Quantityobject.Brightness uncertainties stored as an AstroPy
Quantityobject.flux_quantityDeprecated since version 2.0.
flux_unitDeprecated since version 2.0.
groupshas_masked_columnsTrue if table has any
MaskedColumncolumns.has_masked_valuesTrue if column in the table has values which are masked.
has_mixin_columnsTrue if table has any mixin columns (defined as columns that are not Column subclasses).
hduDeprecated since version 2.0.
ilocReturn a TableILoc object that can be used for retrieving indexed rows in the order they appear in the index.
indicesReturn the indices associated with columns of the table as a TableIndices object.
infolocReturn a TableLoc object that can be used for retrieving rows by index in a given data range.
loc_indicesReturn a TableLocIndices object that can be used for retrieving the row indices corresponding to given table index key value or values.
maskmaskedpprint_exclude_namesMaintain tuple that controls table column visibility for print output.
pprint_include_namesMaintain tuple that controls table column visibility for print output.
Time values stored as an AstroPy
Timeobject.time_formatDeprecated since version 2.0.
time_scaleDeprecated since version 2.0.