Skip to content

First map

This small Python calculation creates a 10 GeV pion-decay gamma-ray map from DRAGON2 cosmic-ray protons, atomic-gas rings, and the Kamae et al. interaction model.

Save as first_map.py:

import pyhermes as hermes

units = hermes.units
nside = 8
energy = 10.0 * units.GeV

cosmic_rays = hermes.cosmicrays.Dragon2D(hermes.Proton)
gas = hermes.neutralgas.RingModel(hermes.neutralgas.GasType.HI)
cross_section = hermes.interactions.Kamae06Gamma()

integrator = hermes.PiZeroIntegrator(cosmic_rays, gas, cross_section)
integrator.setObsPosition(
    hermes.Vector3QLength(8.0 * units.kpc, 0.0 * units.kpc, 0.0 * units.kpc)
)
integrator.setupCacheTable(20, 20, 8)

skymap = hermes.GammaSkymap(nside, energy)
skymap.setIntegrator(integrator)
skymap.compute()
skymap.save(hermes.outputs.HEALPixFormat("first-map.fits.gz"))

print("pixels:", len(skymap))
print("mean intensity:", float(skymap.getMean()))
print("units:", skymap.getOutputUnitsAsString())

Run it inside the HERMES environment:

python first_map.py

At NSIDE=8, the map has 12 × NSIDE² = 768 RING-ordered HEALPix pixels. The low resolution is suitable for learning and smoke checks, not a scientific production result.

What each object does

  1. Dragon2D supplies the position- and energy-dependent cosmic-ray density.
  2. RingModel supplies the target gas distribution.
  3. Kamae06Gamma supplies the differential production cross section.
  4. PiZeroIntegrator combines the ingredients along each line of sight.
  5. GammaSkymap selects the HEALPix resolution and secondary energy.
  6. HEALPixFormat writes the product and scientific metadata to FITS.

The maintained examples add command-line controls, safe overwrite handling, plotting, masks, spectra, and metadata validation. Continue with Examples.