An overview of the package and analysis methods implemented in Gammapy, that I gave at the technical meeting of the Astroparticle Group Dortmund in January 2021.
am a PostDoc at MPIK Heidelberg • During my PhD I worked on the H.E.S.S. Galactic Plane Survey catalog. Out of this work the Gammapy package evolved. Now I am one of the lead-developers of Gammapy • Apologies if there is a bias to H.E.S.S jargon and data… • My Github profile: https://github.com/adonath • General interest in Python based astronomical software: co-organised Python in Gamma-Ray astronomy (e.g. PyGamma 2019), some contributions to the Astropy package • Thanks a lot for the invitation to present Gammapy to your group! 2
www.cta-observatory.org • Instrument is pointed for a given period of time to a position one the sky and measures events. • This is called an “observation” or “run”. • The instrument characteristics (“response”) is assumed to be stable during the whole observation run • For H.E.S.S. it’s typically ~30 min. • This is the fundamental “chunk” of data, from which the data is combined (“stacked”) or split, depending on the analysis case. • For data bookkeeping each observation is assigned a unique identifier Basic definition
www.cta-observatory.org • Instrument is pointed for a given period of time to a position one the sky and measures events. • This is called an “observation” or “run”. • The instrument characteristics (“response”) is assumed to be stable during the whole observation run • For H.E.S.S. it’s typically ~30 min. • This is the fundamental “chunk” of data, from which the data is combined (“stacked”) or split, depending on the analysis case. • For data bookkeeping each observation is assigned a unique identifier Basic definition
of View (“FoV") + Source FoV - Lon FoV - Lat IACT OBSERVATION “FoV coordinates” and conventions Aligned with horizontal (“Alt-Az”) system, centered on pointing position Pointing position
Telescope II Camera • Goal: estimate properties of the event: energy, arrival time, arrival direction, possibly reconstruction quality (“event class”) • Separation between Gamma-like and Hadron-like events • Only “Gamma-like” events are kept in the list
Telescope II Camera • Goal: estimate properties of the event: energy, arrival time, arrival direction, possibly reconstruction quality (“event class”) • Separation between Gamma-like and Hadron-like events • Only “Gamma-like” events are kept in the list • However it is still >90% background, i.e. hadronic (or electron) events “mis-classified” as Gamma events (requires additional background estimation, comes later… ) • Reconstruction of events using various methods: template fitting, “Hillas Parameters”, experts are in this group…
Telescope II Camera • Goal: estimate properties of the event: energy, arrival time, arrival direction, possibly reconstruction quality (“event class”) • Separation between Gamma-like and Hadron-like events • Only “Gamma-like” events are kept in the list • However it is still >90% background, i.e. hadronic (or electron) events “mis-classified” as Gamma events (requires additional background estimation, comes later… ) • Reconstruction of events using various methods: template fitting, “Hillas Parameters”, experts are in this group…
gamma-like events per area • Varies with offset from pointing position and true energy • Estimated from “Monte Carlo” simulations (again experts are in the group…) • Required to measure flux / brightness of Gamma-Rays sources Effective Area DL3 DR1
angular resolution of the instrument, precision to reconstruct the arrival direction of an event • Estimated from “Monte Carlo” simulations and by binning events into offset and true energy • Typically stored as “radial profile” and varies with offset from pointing position and true energy • There are parametric models of the shape as well e.g. triple Gaussian or King profile, obtained by fitting the shape to the event distributions • Required to measure extension of Galactics sources & precise flux of point sources DL3 DR1
to reconstruct the energy of an event • Varies with offset from pointing position and true energy • Often “migration” I used: ratio defined as ETrue / E • Required to measure precise spectra of source, especially at low energies (for IACTS) DL3 DR1
“OFF” observations • Instrument is pointed to an “empty” (without known gamma-ray sources..) region in the sky • Done many times observations are grouped with similar observation conditions, mostly number of telescopes and bands of zenith angle • Taken from: L.Mohrmann et al. https://ui.adsabs.harvard.edu/abs/2019arXiv191008088M 16 Residual Hadronic Background FoV-Lon (deg) FoV-Lat (deg) FoV-Lon (deg) FoV-Lat (deg) DL3 DR1
observation” in a dedicated FITS format “GADF” • Openly developed and documented data formats for Gamma-Ray astronomy • Initiative after the PyGamma15 conference • Based on the “Fermi-LAT” formats used for data distribution • https://gamma-astro-data-formats.readthedocs.io • https://github.com/open-gamma-ray-astro/gamma-astro-data-formats 17 A standardised FITS data format
time selection Bin events into ND sky maps Bin selection: WCS & Energy • Selection of observation “ids” and / or time ranges • Most general case: selection of spatial & energy binning WcsGeom / MapAxis Observation / Observations
Lon Lat Observation and / or time selection Bin selection: WCS & Energy Bin events into ND sky maps • Selection of observation “ids” and / or time ranges • Most general case: selection of spatial & energy binning WcsNDMap WcsGeom / MapAxis Observation / Observations Skymap / “Cube”
time selection Bin selection: WCS & 1 Energy Bin Lon Lat Counts (NObs ) Bin events into ND sky maps • Image analysis is handled as a “cube” with one energy bin WcsNDMap WcsGeom / MapAxis Observation / Observations Skymap
selection: Region & Energy icrs;circle(0, 0, 0.1) Energy Counts Energy Lon Lat Bin events into ND sky maps Counts (NObs ) • Spectral analysis is handled as a “cube” with one spatial bin RegionNDMap RegionGeom / MapAxis Observation / Observations Spectrum
x lifetime ) Reproject IRFs to ND sky maps True Energy Lon Lat Pointing position + Offset • Interpolate effective area on the chosen spatial and true energy binning • Multiply with the (dead time corrected) observation time, to get an exposure map EffectiveAreaTable2D WcsNDMap / RegionNDMap Bin selection: WCS & Energy WcsGeom / MapAxis
Lat 4th Dimension: Energy True Energy Energy dispersion Pointing position + Offset • Energy dispersion varies with offset: if multiple sources are fitted during the analysis a “map” of RMF matrices is required • Typically computed on a WCS with coarser bins (~0.2 deg) • During fitting / model evaluation the corresponding matrix for a given model component is extracted from the map and applied using matrix multiplication EDispKernelMap EDispKernel EnergyDispersion2D Bin selection: Coarse WCS & True Energy / Energy
Rad PSF PSF Model Point spread function Pointing position + Offset • PSF varies with offset: if multiple sources are fitted during the analysis a “map” of PSFs is required • Typically computed on a WCS with coarser bins (~0.2 deg) • During fitting / model evaluation the corresponding PSF the current position of a model component is extracted from the map • From the radial profile a 3D “kernel” is computed and applied using convolution True Energy Lon Lat PSF Kernel PSFMap PSFKernel PSF3D Bin selection: Coarse WCS, True Energy & Rad
(deg) FoV-Lat (deg) FoV-Lon FoV-Lat Bkg Template Energy Lon Lat • Background rate (events / s / sr / TeV) is reprojected on the sky and multiplied with solid angle, observation time and integrated in energy • For the later analysis the “template” is combined with a parametric correction such as norm and spectral ”tilt” WcsNDMap / RegionNDMap Bin selection: WCS & Energy WcsGeom / MapAxis Background3D / Background2D
“off regions” reflected from the pointing position, ignore exclusion regions • “Ring background”: mostly for image analysis, derive “off counts” per pixel from ring convolved counts, ignore exclusion regions. There is a variant called “adaptive ring”, while enlarges the ring to achieve better statistics. • See e.g. Berge et.al. https://ui.adsabs.harvard.edu/abs/2007A%26A...466.1219B/abstract 28 Measure “Off” counts from data ReflectedRegionsBackgroundMaker RingBackgroundMaker
(ℰSrc ⋅ fSrc )) True Energy Lon Lat Source Model True Energy Lon Lat PSF Kernel True Energy Lon Lat Exposure (eff. area x lifetime ) Energy Dispersion Matrix True Energy Energy Sometimes called “foward folding” as well… fSrc = fSpectral (E) ⋅ fSpatial (E, l, b) ⋅ fTemporal (t)
Ni Obs ⋅ log Ni Pred “Cash” statistics: summed over all “bins” NPred = NBkg + ∑ Src NPred,Src “Fermi” style analysis Energy Lon Lat Counts NObs = Bkg Template Energy Lon Lat NBkg = ⋅ n0 ⋅ ( E E0 ) −Γ FoVBackgroundModel • Predicted counts (as defined on the previous slide) are computed per model component (“source”) and summed • A “global” background model with “correction parameters” (like Fermi-LAT analysis) is added • Summed per bin fit statistics= - 2 log(L) computed and optimised
(Ni Sig + (1 + 1/α)Ni Bkg − Ni On log(Ni Sig + Ni Bkg ) − Ni Off log(Ni Bkg /α)) “WStat” statistics: summed over all “bins” Background is “marginalised” NSig = ∑ i NPred,Src ∂𝒲 ∂NBkg = 0 Energy Lon Lat Counts NOn = Energy Lon Lat Counts Off NOff = !
Best fit value UL Parameter value Best fit value Neg. Error Pos. Error Asymmetric errors Delta TS = 1 { Upper limits Likelihood profile Delta TS = 4 • “Significance” based on model comparison: and (valid if the difference in degrees of freedom between the models is 1, Wilk’s theorem) • Errors and upper limits based on likelihood profiles, with or without “marginalisation” i.e. re- optimisation of other parameters, which are not of interested (often background norms, norms of other sources in the FoV,…) Significance, errors and upper limits Δ𝖳𝖲 = 𝒞0 − 𝒞1 σ = Δ𝖳𝖲
Method based on the Fermi-LAT catalogs, no “unfolding” but rescaling a reference model (usually the best fit model) in a selected energy range FluxPointsEstimator
TeV 0.3 TeV 1 TeV 3TeV • Method based on the Fermi-LAT catalogs, no “unfolding” but rescaling a reference model (usually the best fit model) in a selected energy range FluxPointsEstimator
TeV 0.3 TeV 1 TeV 3TeV • Method based on the Fermi-LAT catalogs, no “unfolding” but rescaling a reference model (usually the best fit model) in a selected energy range FluxPointsEstimator
TeV 0.3 TeV 3TeV 1 TeV • Method based on the Fermi-LAT catalogs, no “unfolding” but rescaling a reference model (usually the best fit model) in a selected energy range FluxPointsEstimator
the Fermi-LAT catalogs, no “unfolding” but rescaling a reference model (usually the best fit model) in a selected energy range • The fitting is done using a “norm” parameter , which scales the flux with respect to the reference model. Reference values for dnde (“differential flux”), flux (“integral flux”) and eflux (“energy flux”) are stored along with norm, wich allows to convert the flux points to a different SED type later Energy (TeV) Counts 10 TeV 0.3 TeV 3TeV 1 TeV FluxPointsEstimator
FFT convolution, etc. Command line tools pyyaml YAML I/O click Required dependencies ND-data structures and computations pydantic Configuration Required dependencies: make developer live a bit simpler
CI SETUP 44 Hosted and openly developed on Github: https://github.com/gammapy/gammapy Travis-CI and Azure Pipelines used for continuous integration Docs are build and deployed manually: https://docs.gammapy.org/
CI SETUP 45 Hosted and openly developed on Github: https://github.com/gammapy/gammapy Travis-CI and Azure Pipelines used for continuous integration Black code formatting used for a consistent code format. Sphinx used to build the documentation Pytest used for testing Docs are build and deployed manually: https://docs.gammapy.org/
source catalog for VHE gamma-ray astronomy” gammasky.net “A portal to the gamma-ray sky” PyGamma 15 / 19 “Python and open data for Gamma-Ray Astronomy Workshop”, March 18th - 22nd Gamma-astro-data-formats “A place to propose and share data format descriptions for gamma-ray astronomy.” FITS https://github.com/open-gamma-ray-astro https://indico.cern.ch/event/783425/ https://github.com/gammapy/gamma-cat
index.html • HESS data access: https://docs.gammapy.org/0.18.2/notebooks/cta.html • Spectral analysis: https://docs.gammapy.org/0.18.2/tutorials/spectrum_analysis.html • Lightcurve computation: https://docs.gammapy.org/0.18.2/tutorials/light_curve_flare.html • And many, many others… • Tutorials can be executed online as well (using Binder): 49 Click here!
the @tu-dortmund.de domain can join without invitation…) • Github issues: https://github.com/gammapy/gammapy/issues (feature requests & bug reports) • Gammapy mailing list (not used much…): • [email protected] • Archive: https://groups.google.com/forum/#!forum/gammapy • Gammapy dev meetings (technical meetings in case you’d like to contribute): • Every Friday 10am on Zoom (direct link in the Slack #dev channel) • Friday is Gammapy co-working day • Regular Gammapy CTA and non CTA user calls, will be announced on the CTA mailing list and Gammapy Slack 51