ObservationTable#

class gammapy.data.ObservationTable[source]#

Bases: Table

Observation table.

Data format specification: Observation index table.

Attributes Summary

pointing_galactic

Pointing positions in Galactic coordinates as a SkyCoord object.

pointing_radec

Pointing positions in ICRS as a SkyCoord object.

time_ref

Time reference as a Time object.

time_start

Observation start time as a Time object.

time_stop

Observation stop time as a Time object.

Methods Summary

read(filename, **kwargs)

Read an observation table from file.

select_obs_id(obs_id)

Get ObservationTable containing only obs_id.

select_observations([selections])

Select subset of observations from a list of selection criteria.

select_range(selection_variable, value_range)

Make an observation table, applying some selection.

select_sky_circle(center, radius[, inverted])

Make an observation table, applying a cone selection.

select_time_range(time_range[, ...])

Make an observation table, applying a time selection.

summary()

Summary information string.

Attributes Documentation

pointing_galactic#

Pointing positions in Galactic coordinates as a SkyCoord object.

pointing_radec#

Pointing positions in ICRS as a SkyCoord object.

time_ref#

Time reference as a Time object.

time_start#

Observation start time as a Time object.

time_stop#

Observation stop time as a Time object.

Methods Documentation

classmethod read(filename, **kwargs)[source]#

Read an observation table from file.

Parameters:
filenamepathlib.Path or str

Filename.

**kwargsdict, optional

Keyword arguments passed to read.

select_obs_id(obs_id)[source]#

Get ObservationTable containing only obs_id.

Raises KeyError if observation is not available.

Parameters:
obs_idint or list of int

Observation ids.

select_observations(selections=None)[source]#

Select subset of observations from a list of selection criteria.

Returns a new observation table representing the subset.

There are 3 main kinds of selection criteria, according to the value of the type keyword in the selection dictionary:

  • circular region

  • time intervals (min, max)

  • intervals (min, max) on any other parameter present in the observation table, that can be cast into an Quantity object

Allowed selection criteria are interpreted using the following keywords in the selection dictionary under the type key.

  • sky_circle is a circular region centered in the coordinate

    marked by the lon and lat keywords, and radius radius

  • time_box is a 1D selection criterion acting on the observation start time (TSTART); the interval is set via the time_range keyword; uses select_time_range

  • par_box is a 1D selection criterion acting on any parameter defined in the observation table that can be casted into an Quantity object; the parameter name and interval can be specified using the keywords variable and value_range respectively; min = max selects exact values of the parameter; uses select_range

In all cases, the selection can be inverted by activating the inverted flag, in which case, the selection is applied to keep all elements outside the selected range.

A few examples of selection criteria are given below.

Parameters:
selectionslist of dict, optional

Dictionary of selection criteria. Default is None.

Returns:
obs_tableObservationTable

Observation table after selection.

Examples

>>> from gammapy.data import ObservationTable
>>> obs_table = ObservationTable.read('$GAMMAPY_DATA/hess-dl3-dr1/obs-index.fits.gz')
>>> from astropy.coordinates import Angle
>>> selection = dict(type='sky_circle', frame='galactic',
...                  lon=Angle(0, 'deg'),
...                  lat=Angle(0, 'deg'),
...                  radius=Angle(5, 'deg'),
...                  border=Angle(2, 'deg'))
>>> selected_obs_table = obs_table.select_observations(selection)
>>> from astropy.time import Time
>>> time_range = Time(['2012-01-01T01:00:00', '2012-01-01T02:00:00'])
>>> selection = dict(type='time_box', time_range=time_range)
>>> selected_obs_table = obs_table.select_observations(selection)
>>> value_range = Angle([60., 70.], 'deg')
>>> selection = dict(type='par_box', variable='ALT_PNT', value_range=value_range)
>>> selected_obs_table = obs_table.select_observations(selection)
>>> selection = dict(type='par_box', variable='OBS_ID', value_range=[2, 5])
>>> selected_obs_table = obs_table.select_observations(selection)
>>> selection = dict(type='par_box', variable='N_TELS', value_range=[4, 4])
>>> selected_obs_table = obs_table.select_observations(selection)
select_range(selection_variable, value_range, inverted=False)[source]#

Make an observation table, applying some selection.

Generic function to apply a 1D box selection (min, max) to a table on any variable that is in the observation table and can be cast into a Quantity object.

If the range length is 0 (min = max), the selection is applied to the exact value indicated by the min value. This is useful for selection of exact values, for instance in discrete variables like the number of telescopes.

If the inverted flag is activated, the selection is applied to keep all elements outside the selected range.

Parameters:
selection_variablestr

Name of variable to apply a cut (it should exist on the table).

value_rangeQuantity-like

Allowed range of values (min, max). The type should be consistent with the selection_variable.

invertedbool, optional

Invert selection: keep all entries outside the (min, max) range. Default is False.

Returns:
obs_tableObservationTable

Observation table after selection.

select_sky_circle(center, radius, inverted=False)[source]#

Make an observation table, applying a cone selection.

Apply a selection based on the separation between the cone center and the observation pointing stored in the table.

If the inverted flag is activated, the selection is applied to keep all elements outside the selected range.

Parameters:
centerSkyCoord

Cone center coordinate.

radiusAngle

Cone opening angle. The maximal separation allowed between the center and the observation pointing direction.

invertedbool, optional

Invert selection: keep all entries outside the cone. Default is False.

Returns:
obs_tableObservationTable

Observation table after selection.

select_time_range(time_range, partial_overlap=False, inverted=False)[source]#

Make an observation table, applying a time selection.

Apply a 1D box selection (min, max) to a table on any time variable that is in the observation table. It supports absolute times in Time format.

If the inverted flag is activated, the selection is applied to keep all elements outside the selected range.

Parameters:
time_rangeTime

Allowed time range (min, max).

partial_overlapbool, optional

Include partially overlapping observations. Default is False.

invertedbool, optional

Invert selection: keep all entries outside the (min, max) range. Default is False.

Returns:
obs_tableObservationTable

Observation table after selection.

summary()[source]#

Summary information string.

__init__(data=None, masked=False, names=None, dtype=None, meta=None, copy=True, rows=None, copy_indices=True, units=None, descriptions=None, **kwargs)#
classmethod __new__(*args, **kwargs)#