0 background in the lowest energies #4007
-
Gammapy version Bug description I follow the tutorial: The Table returned from the sensitivity_estimator.run() shows weird values in the lowest energies. Expected behavior To Reproduce inputpath="IRFs-fits/prod5-v0.2-IRFs/fits/Prod5-North-60deg-NorthAz-4LSTs.1800s-v0.2.fits.gz"
import matplotlib.pyplot as plt
import numpy as np
import astropy.units as u
from astropy.coordinates import Angle, SkyCoord
from gammapy.irf import load_cta_irfs
from gammapy.makers import SpectrumDatasetMaker
from gammapy.data import Observation
from gammapy.estimators import SensitivityEstimator
from gammapy.datasets import SpectrumDataset, SpectrumDatasetOnOff
from gammapy.maps import MapAxis, RegionGeom
energy_axis = MapAxis.from_energy_bounds("0.03 TeV", "30 TeV", nbin=20)
energy_axis_true = MapAxis.from_energy_bounds(
"0.01 TeV", "100 TeV", nbin=100, name="energy_true"
)
geom = RegionGeom.create("icrs;circle(0, 0.5, 0.1)", axes=[energy_axis])
empty_dataset = SpectrumDataset.create(
geom=geom, energy_axis_true=energy_axis_true
)
irfs = load_cta_irfs(inputpath)
pointing = SkyCoord("0 deg", "0 deg")
obs = Observation.create(pointing=pointing, irfs=irfs, livetime="5 h")
spectrum_maker = SpectrumDatasetMaker(
selection=["exposure", "edisp", "background"]
)
dataset = spectrum_maker.run(empty_dataset, obs)
containment = 0.68
dataset.exposure *= containment
on_radii = obs.psf.containment_radius(
energy_true=energy_axis.center, offset=0.5 * u.deg, fraction=containment
)
factor = (1 - np.cos(on_radii)) / (1 - np.cos(geom.region.radius))
dataset.background *= factor.value.reshape((-1, 1, 1))
dataset_on_off = SpectrumDatasetOnOff.from_spectrum_dataset(
dataset=dataset, acceptance=1, acceptance_off=5
)
sensitivity_estimator = SensitivityEstimator(
gamma_min=10, n_sigma=5, bkg_syst_fraction=0.10
)
sensitivity_table = sensitivity_estimator.run(dataset_on_off)
print(sensitivity_table) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Merci! We will respond to your issue shortly. In the meantime, try |
Beta Was this translation helpful? Give feedback.
-
Thanks @kazumaishio, from what it seems this is just how the CTA IRFs are defined. With a zenith angle of 60 deg, one expects a high energy threshold anyway. Maybe @AtreyeeS or @QRemy can confirm, they might habe worked with the IRF before. |
Beta Was this translation helpful? Give feedback.
-
Yes indeed! As @adonath guessed, the IRF is empty in these bins for the specific case @kazumaishio mentions. Since extrapolations of IRFs are not performed by gammapy anymore, the behaviour that you see is expected. Probably an older version of gammapy were used to make the CTA sensitivity curves |
Beta Was this translation helpful? Give feedback.
Yes indeed! As @adonath guessed, the IRF is empty in these bins for the specific case @kazumaishio mentions. Since extrapolations of IRFs are not performed by gammapy anymore, the behaviour that you see is expected. Probably an older version of gammapy were used to make the CTA sensitivity curves