select_sky_box

gammapy.catalog.select_sky_box(table, lon_lim, lat_lim, frame='icrs', inverted=False)[source]

Select sky positions in a box.

This function can be applied e.g. to event lists of source catalogs or observation tables.

Note: if useful we can add a function that returns the mask or indices instead of applying the selection directly

Parameters:
table : Table

Table with sky coordinate columns.

lon_lim, lat_lim : Angle

Box limits (each should be a min, max tuple).

frame : str, optional

Frame in which to apply the box cut. Built-in Astropy coordinate frames are supported, e.g. ‘icrs’, ‘fk5’ or ‘galactic’.

inverted : bool, optional

Invert selection: keep all entries outside the selected region.

Returns:
table : Table

Copy of input table with box cut applied.

Examples

>>> selected_obs_table = select_sky_box(obs_table,
...                                     lon_lim=Angle([150, 300], 'deg'),
...                                     lat_lim=Angle([-50, 0], 'deg'),
...                                     frame='icrs')