ObservationFilter

class gammapy.data.ObservationFilter(time_filter=None, event_filters=None)[source]

Bases: object

Holds and applies filters to observation data.

Parameters
time_filterastropy.time.Time

Start and stop time of the selected time interval. For now we only support a single time interval.

event_filterslist of dict

An event filter dictionary needs two keys:

  • type : str, one of the keys in EVENT_FILTER_TYPES

  • opts : dict, it is passed on to the method of the EventListBase class that corresponds to the filter type (see EVENT_FILTER_TYPES)

The filtered event list will be an intersection of all filters. A union of filters is not supported yet.

Examples

>>> from gammapy.data import ObservationFilter, DataStore, Observation
>>> from astropy.time import Time
>>> from astropy.coordinates import Angle
>>>
>>> time_filter = Time(['2021-03-27T20:10:00', '2021-03-27T20:20:00'])
>>> phase_filter = {'type': 'custom', 'opts': dict(parameter='PHASE', band=(0.2, 0.8))}
>>>
>>> my_obs_filter = ObservationFilter(time_filter=time_filter, event_filters=[phase_filter])
>>>
>>> ds = DataStore.from_dir("$GAMMAPY_DATA/cta-1dc/index/gps")
>>> my_obs = ds.obs(obs_id=111630)
>>> my_obs.obs_filter = my_obs_filter

Attributes Summary

EVENT_FILTER_TYPES

Methods Summary

copy()

Copy the ObservationFilter object.

filter_events(events)

Apply filters to an event list.

filter_gti(gti)

Apply filters to a GTI table.

Attributes Documentation

EVENT_FILTER_TYPES = {'custom': 'select_parameter', 'sky_region': 'select_region'}

Methods Documentation

copy()[source]

Copy the ObservationFilter object.

filter_events(events)[source]

Apply filters to an event list.

Parameters
eventsEventListBase

Event list to which the filters will be applied

Returns
filtered_eventsEventListBase

The filtered event list

filter_gti(gti)[source]

Apply filters to a GTI table.

Parameters
gtiGTI

GTI table to which the filters will be applied

Returns
filtered_gtiGTI

The filtered GTI table