LightCurveTemplateTemporalModel¶
-
class
gammapy.modeling.models.
LightCurveTemplateTemporalModel
(table)[source]¶ Bases:
gammapy.modeling.models.TemporalModel
Temporal light curve model.
The lightcurve is given as a table with columns
time
andnorm
.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 degreek=1
to get linear interpolation. This class also contains anintegral
method, making the computation of mean fluxes for a given time interval a one-liner.- Parameters
- table
Table
A table with ‘TIME’ vs ‘NORM’
- table
Examples
Read an example light curve object:
>>> from gammapy.modeling.models import LightCurveTemplateTemporalModel >>> path = '$GAMMAPY_DATA/tests/models/light_curve/lightcrv_PKSB1222+216.fits' >>> light_curve = LightCurveTemplateTemporalModel.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
)Methods Summary
copy
(self)A deep copy.
create
(tag, \*args, \*\*kwargs)Create a model instance.
evaluate_norm_at_time
(self, time[, ext_mode])Evaluate for a given time.
from_dict
(data)mean_norm_in_time_interval
(self, time_min, …)Compute mean
norm
in a given time interval.read
(path)Read lightcurve model table from FITS file.
sample_time
(self, n_events, t_min, t_max[, …])Sample arrival times of events.
to_dict
(self)Create dict for YAML serialisation
Attributes Documentation
-
default_parameters
= <gammapy.modeling.parameter.Parameters object>¶
-
parameters
¶ Parameters (
Parameters
)
-
tag
= 'LightCurveTemplateTemporalModel'¶
Methods Documentation
-
copy
(self)¶ A deep copy.
-
static
create
(tag, *args, **kwargs)¶ Create a model instance.
Examples
>>> from gammapy.modeling import Model >>> spectral_model = Model.create("PowerLaw2SpectralModel", amplitude="1e-10 cm-2 s-1", index=3) >>> type(spectral_model) gammapy.modeling.models.spectral.PowerLaw2SpectralModel
-
evaluate_norm_at_time
(self, time, ext_mode=3)[source]¶ Evaluate for a given time.
- Parameters
- timearray_like
Time since the
reference
time.- ext_modeint 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
- normarray_like
-
classmethod
from_dict
(data)¶
-
mean_norm_in_time_interval
(self, 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_maxfloat
Time interval
- Returns
- normfloat
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.
-
sample_time
(self, n_events, t_min, t_max, t_delta='1 s', random_state=0)[source]¶ Sample arrival times of events.
- Parameters
- n_eventsint
Number of events to sample.
- t_min
Time
Start time of the sampling.
- t_max
Time
Stop time of the sampling.
- t_delta
Quantity
Time step used for sampling of the temporal model.
- random_state{int, ‘random-seed’, ‘global-rng’,
RandomState
} Defines random number generator initialisation. Passed to
get_random_state
.
- Returns
- time
Quantity
Array with times of the sampled events.
- time
-
to_dict
(self)¶ Create dict for YAML serialisation