This is a fixed-text formatted version of a Jupyter notebook.

Computation of the CTA sensitivity

Introduction

This notebook explains how to derive the CTA sensitivity for a point-like IRF at a fixed zenith angle and fixed offset. The significativity is computed for the 1D analysis (On-OFF regions) and the LiMa formula.

We will be using the following Gammapy classes:

Setup

As usual, we’ll start with some setup …

In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
In [2]:
from gammapy.irf import CTAPerf
from gammapy.spectrum import SensitivityEstimator

Load IRFs

First load the CTA IRFs.

In [3]:
filename = "$GAMMAPY_EXTRA/datasets/cta/perf_prod2/point_like_non_smoothed/South_5h.fits.gz"
irf = CTAPerf.read(filename)

Compute sensitivity

Choose a few parameters, then run the sentitivity computation.

In [4]:
sensitivity_estimator = SensitivityEstimator(irf=irf, livetime="5h")
sensitivity_estimator.run()

Results

The results are given as an Astropy table.

In [5]:
# Show the results table
sensitivity_estimator.results_table
Out[5]:
Table length=21
energye2dndeexcessbackgroundcriterion
TeVerg / (cm2 s)
float32float64float64float32str12
0.01584891.26569e-10339.1433703.48significance
0.02511892.41235e-11311.1063106.66significance
0.03981071.5914e-11459.2136852.06significance
0.06309574.26714e-12163.204825.794significance
0.13.04454e-12169.361891.645significance
0.1584891.55368e-1290.0926236.905significance
0.2511891.0771e-1251.534969.8381significance
0.3981077.83236e-1335.690529.8996significance
0.6309575.93807e-1326.400514.2506significance
14.28759e-1318.10725.11857significance
1.584893.62852e-1315.68713.31032significance
2.511893.21257e-1311.70161.17059significance
3.981073.39152e-1312.09621.33607significance
6.309573.9511e-13100.424068gamma
105.65043e-1310.8980.865076significance
15.84898.36566e-13100.216136gamma
25.11891.26771e-12100.00979249gamma
39.81072.00893e-12100.0053102gamma
63.09573.24246e-12100.00170479gamma
1005.10213e-12100.00101395gamma
158.4899.04831e-12100.00566093gamma
In [6]:
# Save it to file (could use e.g. format of CSV or ECSV or FITS)
# sensitivity_estimator.results_table.write('sensitivity.ecsv', format='ascii.ecsv')
In [7]:
# Plot the sensitivity curve
t = sensitivity_estimator.results_table

is_s = t["criterion"] == "significance"
plt.plot(
    t["energy"][is_s],
    t["e2dnde"][is_s],
    "s-",
    color="red",
    label="significance",
)

is_g = t["criterion"] == "gamma"
plt.plot(
    t["energy"][is_g], t["e2dnde"][is_g], "*-", color="blue", label="gamma"
)

plt.loglog()
plt.xlabel("Energy ({})".format(t["energy"].unit))
plt.ylabel("Sensitivity ({})".format(t["e2dnde"].unit))
plt.legend();
../_images/notebooks_cta_sensitivity_13_0.png

Exercises

  • Also compute the sensitivity for a 20 hour observation
  • Compare how the sensitivity differs between 5 and 20 hours by plotting the ratio as a function of energy.