Time handling and analysis (gammapy.time)

Introduction

gammapy.time contains methods for timing analysis.

There is also gammapy.utils.time, which contains low-level helper functions for time conversions e.g. following the

At the moment there isn’t a lot of functionality yet … contributions welcome!

Getting Started

Lightcurve

This section introduces the LightCurve class.

Read a table that contains a lightcurve:

>>> 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')

Create a LightCurve object:

>>> from gammapy.time import LightCurve
>>> lc = LightCurve(table)

LightCurve is a simple container that stores the LC table, and provices a few conveniences, like creating time objects and a quick-look plot:

>>> lc.time[:2].iso
['2004-05-23 01:47:08.160' '2004-05-23 02:17:31.200']
>>> lc.plot()

Variability test

The exptest function can be used to compute the significance of variability (compared to the null hypothesis of constant rate) for a list of event time differences.

Here’s an example how to use the random_times helper function to simulate a TimeDelta array for a given constant rate and use exptest to assess the level of variability (0.11 sigma in this case, not variable):

>>> from astropy.units import Quantity
>>> from gammapy.time import random_times, exptest
>>> rate = Quantity(10, 'Hz')
>>> time_delta = random_times(size=100, rate=rate, return_diff=True, random_state=0)
>>> mr = exptest(time_delta)
>>> print(mr)
0.11395763079

See examples/example_exptest.py for a longer example.

TODO: apply this to the 2FHL events and check which sources are variable as a nice example.

from gammapy.data import EventList
from gammapy.time import exptest
events = EventList.read('$GAMMAPY_EXTRA/datasets/fermi_2fhl/2fhl_events.fits.gz ', hdu='EVENTS')
# TODO: cone select events for 2FHL catalog sources, compute mr for each and print 10 most variable sources

Reference/API

gammapy.time Package

Time-based analysis.

Functions

exptest(time_delta) Compute the level of variability for a certain period of time.
lomb_scargle(time, flux, flux_err, dt[, …]) Compute period and its false alarm probability of a light curve using Lomb-Scargle PSD.
plot_periodogram(time, flux, flux_err, …) Plot a light curve, its periodogram and spectral window function.
random_times(size, rate[, dead_time, …]) Make random times assuming a Poisson process.

Classes

LightCurve(table) Lightcurve container.
LightCurveEstimator(spec_extract) Light curve estimator.

gammapy.time.models Module

Classes

PhaseCurve(table, time_0, phase_0, f0, f1, f2) Temporal phase curve model.