LightCurve

class sunpy.lightcurve.LightCurve(filepath)[source] [edit on github]

Bases: object

A generic light curve object.

meta

str or dict – The comment string or header associated with the data.

data

DataFrame – An pandas DataFrame prepresenting one or more fields as a function of time.

Examples

>>> from sunpy.lightcurve import LightCurve
>>> import datetime
>>> import numpy as np
>>> base = datetime.datetime.today()
>>> dates = [base - datetime.timedelta(minutes=x) for x in range(0, 24 * 60)]
>>> intensity = np.sin(np.arange(0, 12 * np.pi, step=(12 * np.pi) / 24 * 60))
>>> light_curve = LightCurve.create({"param1": intensity}, index=dates)
>>> light_curve.peek()   

References

Attributes Summary

header Return the lightcurves metadata

Methods Summary

concatenate(otherlightcurve) Concatenate another light curve.
create(*args, **kwargs)
extract(column_name) Returns a new lightcurve with the chosen column.
from_data(data[, index, meta]) Called by Conditional Dispatch object to create Light Curve object when corresponding data is passed to create method.
from_dataframe(dataframe[, meta]) Called by Conditional Dispatch object to create Light Curve object when Pandas DataFrame is passed to create method.
from_file(filename) Used to return Light Curve object by reading the given filename.
from_range(start, end, **kwargs) Called by Conditional Dispatch object when start and end time are passed as input to create method.
from_time(time, **kwargs) Called by Conditional Dispatch object when valid time is passed as input to create method.
from_timerange(timerange, **kwargs) Called by Conditional Dispatch object when time range is passed as input to create method.
from_url(url, **kwargs) Called by Conditional Dispatch object to create Light Curve object when given a url.
from_yesterday() Called by Conditional Dispatch object if no input if given
peek(**kwargs) Displays the light curve in a new figure.
plot([axes]) Plot a plot of the light curve
time_range() Returns the start and end times of the LightCurve as a TimeRange object
truncate(a[, b]) Returns a truncated version of the lightcurve object.

Attributes Documentation

header

Return the lightcurves metadata

Deprecated since version 0.4.0: Use .meta instead

Methods Documentation

concatenate(otherlightcurve)[source] [edit on github]

Concatenate another light curve. This function will check and remove any duplicate times. It will keep the column values from the original lightcurve to which the new lightcurve is being added.

Parameters:otherlightcurve (LightCurve) – Another lightcurve of the same type.
Returns:newlc (LightCurve) – A new lightcurve.
classmethod create(*args, **kwargs) [edit on github]
extract(column_name)[source] [edit on github]

Returns a new lightcurve with the chosen column.

Parameters:column_name (str) – A valid column name
Returns:newlc (LightCurve) – A new lightcurve with only the selected column.
classmethod from_data(data, index=None, meta=None)[source] [edit on github]

Called by Conditional Dispatch object to create Light Curve object when corresponding data is passed to create method.

Parameters:
  • data (ndarray) – The data array
  • index (datetime array) – The time values
classmethod from_dataframe(dataframe, meta=None)[source] [edit on github]

Called by Conditional Dispatch object to create Light Curve object when Pandas DataFrame is passed to create method.

Parameters:
classmethod from_file(filename)[source] [edit on github]

Used to return Light Curve object by reading the given filename.

Parameters:filename (str) – Path of the file to be read.
Returns:Lightcurve object.
classmethod from_range(start, end, **kwargs)[source] [edit on github]

Called by Conditional Dispatch object when start and end time are passed as input to create method.

Parameters:
  • start
  • end
  • kwargs
Returns:

classmethod from_time(time, **kwargs)[source] [edit on github]

Called by Conditional Dispatch object when valid time is passed as input to create method.

classmethod from_timerange(timerange, **kwargs)[source] [edit on github]

Called by Conditional Dispatch object when time range is passed as input to create method.

classmethod from_url(url, **kwargs)[source] [edit on github]

Called by Conditional Dispatch object to create Light Curve object when given a url. Downloads a file from the given url, attemps to read it and returns a Light Curve object.

Parameters:url (str) – A url given as a string.
classmethod from_yesterday()[source] [edit on github]

Called by Conditional Dispatch object if no input if given

peek(**kwargs)[source] [edit on github]

Displays the light curve in a new figure.

Parameters:**kwargs (dict) – Any additional plot arguments that should be used when plotting.
plot(axes=None, **plot_args)[source] [edit on github]

Plot a plot of the light curve

Parameters:
  • axes (Axes or None) – If provided the image will be plotted on the given axes. Otherwise the current axes will be used.
  • **plot_args (dict) – Any additional plot arguments that should be used when plotting.
Returns:

axes (Axes) – The plot axes.

time_range()[source] [edit on github]

Returns the start and end times of the LightCurve as a TimeRange object

truncate(a, b=None)[source] [edit on github]

Returns a truncated version of the lightcurve object.

Parameters:a (sunpy.time.TimeRange) – A time range to truncate to.
Returns:newlc (LightCurve) – A new lightcurve with only the selected times.