LightCurveTableModel

class gammapy.time.models.LightCurveTableModel(table)[source]

Bases: gammapy.utils.fitting.Model

Temporal light curve model.

The lightcurve is given as a table with columns time and norm.

The norm is supposed to be a unite-less multiplicative factor in the model, to be multiplied with a spectral model.

The model does linear interpolation for times between the given (time, norm) values.

The implementation currently uses scipy.interpolate.InterpolatedUnivariateSpline, using degree k=1 to get linear interpolation. This class also contains an integral method, making the computation of mean fluxes for a given time interval a one-liner.

Parameters:
table : Table

A table with ‘TIME’ vs ‘NORM’

Examples

Read an example light curve object:

>>> from gammapy.time.models import LightCurveTableModel
>>> path = '$GAMMAPY_DATA/tests/models/light_curve/lightcrv_PKSB1222+216.fits'
>>> light_curve = LightCurveTableModel.read(path)

Show basic information about the lightcurve:

>>> print(light_curve)
LightCurve model summary:
Start time: 59000.5 MJD
End time: 61862.5 MJD
Norm min: 0.01551196351647377
Norm max: 1.0

Compute norm at a given time:

>>> light_curve.evaluate_norm_at_time(46300)
0.49059393580053845

Compute mean norm in a given time interval:

>>> light_curve.mean_norm_in_time_interval(46300, 46301)

Attributes Summary

parameters Parameters (Parameters)

Methods Summary

copy() A deep copy.
evaluate_norm_at_time(time) Evaluate for a given time.
mean_norm_in_time_interval(time_min, time_max) Compute mean norm in a given time interval.
read(path) Read lightcurve model table from FITS file.

Attributes Documentation

parameters

Parameters (Parameters)

Methods Documentation

copy()

A deep copy.

evaluate_norm_at_time(time)[source]

Evaluate for a given time.

Parameters:
time : array_like

Time since the reference time.

Returns:
norm : array_like
mean_norm_in_time_interval(time_min, time_max)[source]

Compute mean norm in a given time interval.

TODO: vectorise, i.e. allow arrays of time intervals in a single call.

Parameters:
time_min, time_max : float

Time interval

Returns:
norm : float

Mean norm

classmethod read(path)[source]

Read lightcurve model table from FITS file.

TODO: This doesn’t read the XML part of the model yet.