ObservationTable#
- class gammapy.data.ObservationTable[source]#
Bases:
Table
Observation table.
Data format specification: Observation index table.
Attributes Summary
Pointing positions in Galactic coordinates as a
SkyCoord
object.Pointing positions in ICRS as a
SkyCoord
object.Time reference as a
Time
object.Observation start time as a
Time
object.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 onlyobs_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
Methods Documentation
- classmethod read(filename, **kwargs)[source]#
Read an observation table from file.
- Parameters:
- filename
pathlib.Path
or str Filename.
- **kwargsdict, optional
Keyword arguments passed to
read
.
- filename
- select_obs_id(obs_id)[source]#
Get
ObservationTable
containing onlyobs_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 coordinatemarked 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; usesselect_time_range
par_box
is a 1D selection criterion acting on any parameter defined in the observation table that can be casted into anQuantity
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; usesselect_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_table
ObservationTable
Observation table after selection.
- obs_table
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_range
Quantity
-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_table
ObservationTable
Observation table after selection.
- obs_table
- 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:
- Returns:
- obs_table
ObservationTable
Observation table after selection.
- obs_table
- 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_range
Time
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.
- time_range
- Returns:
- obs_table
ObservationTable
Observation table after selection.
- obs_table
- __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)#