Simplify cta sensitivity tutorial
"metadata": {},
"outputs": [],
"source": [
- "import numpy as np\n",
"import astropy.units as u\n",
"from astropy.coordinates import Angle, SkyCoord\n",
"from gammapy.irf import load_cta_irfs\n",
- "from gammapy.spectrum import SensitivityEstimator, CountsSpectrum, SpectrumDatasetMaker, SpectrumDataset\n",
+ "from gammapy.spectrum import SensitivityEstimator, SpectrumDatasetMaker, SpectrumDataset\n",
"from gammapy.data import Observation\n",
- "from regions import CircleSkyRegion"
+ "from regions import CircleSkyRegion\n",
+ "from gammapy.maps import MapAxis"
]
},
{
"center = SkyCoord(\"0 deg\", \"0.5 deg\")\n",
"region = CircleSkyRegion(center=center, radius=0.1 * u.deg)\n",
"\n",
- "e_reco = np.logspace(-1.8, 1.5, 20) * u.TeV\n",
- "e_true = np.logspace(-2, 2, 100) * u.TeV\n",
+ "e_reco = MapAxis.from_energy_bounds(\"0.03 TeV\", \"30 TeV\", nbin=20)\n",
+ "e_true = MapAxis.from_energy_bounds(\"0.01 TeV\", \"100 TeV\", nbin=100)\n",
"\n",
- "empty_dataset = SpectrumDataset.create(e_reco=e_reco, e_true=e_true, region=region)"
+ "empty_dataset = SpectrumDataset.create(e_reco=e_reco.edges, e_true=e_true.edges, region=region)"
]
},
{
"\n",
"ax1.loglog()\n",
"ax1.set_xlabel(f\"Energy ({t['energy'].unit})\")\n",
- "ax1.set_ylabel(\"Expected number of bkg counts\")\n",
- "\n",
- "ax2 = ax1.twinx()\n",
- "ax2.set_ylabel(f\"ON region radius ({on_radii.unit})\", color=\"red\")\n",
- "ax2.semilogy(t[\"energy\"], on_radii, color=\"red\", label=\"PSF68\")\n",
- "ax2.tick_params(axis=\"y\", labelcolor=\"red\")\n",
- "ax2.set_ylim(0.01, 0.5)"
+ "ax1.set_ylabel(\"Expected number of bkg counts\")"
]
},
{
