EventListDataset

class gammapy.data.EventListDataset(event_list, gti=None)[source]

Bases: object

Event list dataset (event list plus some extra info).

TODO: I’m not sure if IRFs should be included in this class or if an extra container class should be added.

Parameters:

event_list : EventList

Event list table

gti : GTI

Good time interval table

Methods Summary

check([checks]) Check if format and content is ok.
from_hdu_list(hdu_list) Create EventList from a HDUList.
read(filename) Read event list from FITS file.
to_fits() Convert to FITS HDU list format.
vstack_from_files(filenames[, logger]) Stack event lists vertically (combine events and GTIs).
write(*args, **kwargs) Write to FITS file.

Methods Documentation

check(checks='all')[source]

Check if format and content is ok.

This is a convenience method that instantiates and runs a EventListDatasetChecker ... if you want more options use this way to use it:

>>> from gammapy.data import EventListDatasetChecker
>>> checker = EventListDatasetChecker(event_list, ...)
>>> checker.run(which, ...)  #
Parameters:

checks : list of str or ‘all’

Which checks to run (see list in run docstring).

Returns:

ok : bool

Everything ok?

classmethod from_hdu_list(hdu_list)[source]

Create EventList from a HDUList.

classmethod read(filename)[source]

Read event list from FITS file.

to_fits()[source]

Convert to FITS HDU list format.

Returns:

hdu_list : HDUList

HDU list with EVENTS and GTI extension.

classmethod vstack_from_files(filenames, logger=None)[source]

Stack event lists vertically (combine events and GTIs).

This function stacks (a.k.a. concatenates) event lists. E.g. if you have one event list with 100 events (i.e. 100 rows) and another with 42 events, the output event list will have 142 events.

It also stacks the GTIs so that exposure computations are still possible using the stacked event list.

At the moment this can require a lot of memory. All event lists are loaded into memory at the same time.

TODO: implement and benchmark different a more efficient method: Get number of rows from headers, pre-allocate a large table, open files one by one and fill correct rows.

TODO: handle header keywords “correctly”. At the moment the output event list header keywords are copies of the values from the first observation, i.e. meaningless. Here’s a (probably incomplete) list of values we should handle (usually by computing the min, max or mean or removing it): - OBS_ID - DATE_OBS, DATE_END - TIME_OBS, TIME_END - TSTART, TSTOP - LIVETIME, DEADC - RA_PNT, DEC_PNT - ALT_PNT, AZ_PNT

Parameters:

filenames : list of str

List of event list filenames

Returns:

event_list_dataset : EventListDataset

write(*args, **kwargs)[source]

Write to FITS file.

Calls writeto, forwarding all arguments.