Make a theta-square plot#

This tutorial explains how to make such a plot, that is the distribution of event counts as a function of the squared angular distance, to a test position.

Setup#

# %matplotlib inline
import matplotlib.pyplot as plt
from astropy.coordinates import SkyCoord
from astropy import units as u
from gammapy.data import DataStore
from gammapy.maps import MapAxis
from gammapy.makers.utils import ThetaSquaredTable
from gammapy.visualization import plot_theta_squared_table

Get some data#

Some data taken on the Crab by H.E.S.S. are used.

data_store = DataStore.from_dir("$GAMMAPY_DATA/hess-dl3-dr1")
observations = data_store.get_observations([23523, 23526])

Define a test position#

Here we define the position of Crab

position = SkyCoord(83.6324, 22.0174, unit="deg")
print(position)
<SkyCoord (ICRS): (ra, dec) in deg
    (83.6324, 22.0174)>

Creation of the theta2 plot#

By default, the distribution of the OFF counts in squared angular distance is calculated from the mirror reflected coordinates of the test position, assuming therefore a single OFF position. However, one can set manually both the coordinates of the off_position. It is worth to note that overlapping regions are always forbidden to avoid correlated OFF counts, therefore the user should take care in the choice of the off_position.

<SkyCoord (ICRS): (ra, dec) in deg
    (83.6324, 21.0114874)>
theta square plot

Alternatively, it can be requested a number of reflected OFF positions that will be calculated through the WobbleRegionsFinder. As mentioned before, the user should be cautious that the regions (ON and OFF) do not overlap, otherwise only the mirror reflected region will be adopted as OFF.

theta square plot

Making a theta2 plot for a given energy range#

With the function ThetaSquaredTable, one can also select a fixed energy range.

theta square plot

Statistical significance of a detection#

To get the significance of a signal, the usual method consists of using the reflected background method (see the maker tutorial: Reflected regions background) to compute the WStat statistics (see WStat : Poisson data with background measurement, Fit statistics). This is the well-known method of [LiMa1983] using ON and OFF regions.

The following tutorials show how to get an excess significance:

Gallery generated by Sphinx-Gallery