The table structure follows the approach proposed in the gamma-ray-astro-formats webpage.
The following example shows how to read a table that contains a lightcurve and then create a
The latter gives access to a number of utilities such as plots and access to times as
>>> from astropy.table import Table >>> url = 'https://github.com/gammapy/gamma-cat/raw/master/input/data/2006/2006A%2526A...460..743A/tev-000119-lc.ecsv' >>> table = Table.read(url, format='ascii.ecsv') >>> from gammapy.estimators import LightCurve >>> lc = LightCurve(table) >>> lc.time[:2].iso ['2004-05-23 01:47:08.160' '2004-05-23 02:17:31.200'] >>> lc.plot()
Light Curve Extraction¶
The extraction of a light curve from gamma-ray data follows the general approach of
data reduction and modeling/fitting. Observations are first reduced to dataset objects
SpectrumDatasetOnOff). Then, after
setting the appropriate model the flux is extracted in each time bin with the
To extract the light curve of a source, the
fits a scale factor on the model component representing the source in each time bin
and returns a
LightCurve. It can work with spectral (1D) datasets as well
as with map (3D) datasets.
Datasets object is build with a model set, one can call the estimator
to compute the light curve in the datasets time intervals:
>>> lc_estimator = LightCurveEstimator(datasets, source="source") >>> lc = lc_estimator.run(e_min=1*u.TeV, emax=10*u.TeV, e_ref=1*u.TeV)
source is the model component describing the source of interest and
object produced by data reduction.
The light curve notebook shows an example of observation based light curve
LightCurveEstimator can be used to extract the light curve in user defined time intervals.
This can be useful to combine datasets to produce light curve by night, week or month:
>>> lc_estimator = LightCurveEstimator(datasets, source="source", time_intervals=time_intervals) >>> lc = lc_estimator.run(e_min=1*u.TeV, emax=10*u.TeV, e_ref=1*u.TeV)