LightCurveTableModel¶
-
class
gammapy.time.models.LightCurveTableModel(table)[source]¶ Bases:
gammapy.utils.fitting.ModelTemporal light curve model.
The lightcurve is given as a table with columns
timeandnorm.The
normis 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 degreek=1to get linear interpolation. This class also contains anintegralmethod, 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
normat a given time:>>> light_curve.evaluate_norm_at_time(46300) 0.49059393580053845
Compute mean
normin a given time interval:>>> light_curve.mean_norm_in_time_interval(46300, 46301)
Attributes Summary
parametersParameters ( Parameters)Methods Summary
copy(self)A deep copy. evaluate_norm_at_time(self, time[, ext_mode])Evaluate for a given time. mean_norm_in_time_interval(self, time_min, …)Compute mean normin a given time interval.read(path)Read lightcurve model table from FITS file. to_dict(self[, selection])Attributes Documentation
-
parameters¶ Parameters (
Parameters)
Methods Documentation
-
copy(self)¶ A deep copy.
-
evaluate_norm_at_time(self, time, ext_mode=3)[source]¶ Evaluate for a given time.
Parameters: - time : array_like
Time since the
referencetime.- ext_mode : int or str, optional
Controls the extrapolation mode for elements not in the interval defined by the knot sequence. if ext=0 or ‘extrapolate’, return the extrapolated value. if ext=1 or ‘zeros’, return 0 if ext=2 or ‘raise’, raise a ValueError if ext=3 of ‘const’, return the boundary value. The default value is 0.
Returns: - norm : array_like
-
mean_norm_in_time_interval(self, time_min, time_max)[source]¶ Compute mean
normin 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.
-
to_dict(self, selection='all')¶
- table :