Skip to content

Python interface

The compiled extension is imported as pyhermes:

import pyhermes as hermes
from pyhermes import units

Top-level map and integrator classes

Map classes:

  • GammaSkymap, GammaSkymapRange;
  • RadioSkymap (RadioSkymapRange is not currently bound to Python);
  • DispersionMeasureSkymap;
  • RotationMeasureSkymap.

Mask classes:

  • RectangularWindow, CircularWindow;
  • InvertMask, MaskList.

Integrator classes:

  • DispersionMeasureIntegrator, RotationMeasureIntegrator;
  • FreeFreeIntegrator, SynchroIntegrator, SynchroAbsorptionIntegrator;
  • PiZeroIntegrator, PiZeroAbsorptionIntegrator, PiZeroNeutronDecayIntegrator;
  • BremsstrahlungIntegrator, InverseComptonIntegrator;
  • DarkMatterIntegrator, DarkMatterNeutronIntegrator.

Submodules

Namespace Contents
cosmicrays analytic, DRAGON, and UHE cosmic-ray densities
ionizedgas free-electron density models
neutralgas H I/H2 ring data and ring models
photonfields CMB and interstellar radiation fields
magneticfields Galactic magnetic-field models
interactions cross sections and yield tables
darkmatter spectra, channels, masses, and Galactic profiles
outputs HEALPix and CTA FITS writers
units physical units and constants

Quantities and units

Construct physical values by multiplying a scalar by a unit:

energy = 10.0 * units.GeV
distance = 8.0 * units.kpc
angle = 5.0 * units.deg

float(quantity) returns the underlying SI value. Many quantity types also provide toAstroPy() when Astropy is installed. Preserve a quantity object through HERMES calculations and convert only at an explicit interface or plot.

Version and paths

print(hermes.__version__)
print(hermes.__file__)
print(hermes.getDataPath("VERSION"))

hermes.__file__ is the definitive answer to which compiled extension Python loaded. A pip show result may be absent because the current extension is installed by CMake rather than as Python package metadata.

Container access

Maps expose Python length, iteration, indexing, and the buffer protocol. A NumPy view or array can therefore be created without a pixel-by-pixel Python loop. Respect hermes.UNSEEN when forming statistics.

The Python layer does not yet provide complete generated docstrings and type stubs. Constructor-level examples in this site are checked against the binding source, while the C++ binding files remain the exact signature reference.