# time - Time analysis¶

## Introduction¶

gammapy.time contains classes and methods for time-based analysis, e.g. for AGN, binaries or pulsars studies. The main classes are LightCurve, which is a container for light curves, and LightCurveEstimator, which extracts a light curve from a list of datasets. A number of functions to test for variability and periodicity are available in variability and periodicity. Finally, gammapy.utils.time contains low-level helper functions for time conversions.

## Variability and periodicity tests¶

A few utility functions to perform timing tests are available in time.

compute_chisq performs a chisquare test for variable source flux:

>>> from gammapy.time import chisquare
>>> print(compute_chisq(lc['FLUX']))


compute_fvar calculates the fractional variance excess:

>>> from gammapy.time import fvar
>>> print(compute_fvar(lc['FLUX'], lc['FLUX_ERR']))


time also provides methods for period detection in time series, i.e. light curves of $$\gamma$$-ray sources. robust_periodogram performs a periodogram analysis where the unevenly sampled time series is contaminated by outliers, i.e. due to the source’s high states. This is demonstrated on the Period detection and plotting page.

## Tutorials¶

The main tutorial demonstrates how to extract light curves from 1D and 3D datasets:

Light curve extraction on small time bins (i.e. smaller than the observation scale) for flares is demonstrated in the following tutorial:

## Reference/API¶

### gammapy.time Package¶

Time analysis.

#### Functions¶

 compute_chisq(flux) Calculate the chi-square test for LightCurve. compute_fvar(flux, flux_err) Calculate the fractional excess variance. plot_periodogram(time, flux, periods, power) Plot a light curve and its periodogram. robust_periodogram(time, flux[, flux_err, …]) Compute a light curve’s period.