Skip to content

FITS output and plotting

outputs.HEALPixFormat writes a primary HDU followed by one or more binary table HDUs. The important metadata are:

Keyword Meaning
SOFTWARE, VERSION HERMES and its Git description
PIXTYPE HEALPIX
ORDERING RING
COORDSYS Galactic coordinates (G)
NSIDE, FIRSTPIX, LASTPIX map geometry
BAD_DATA sentinel for masked or unavailable pixels
OBJECT FULLSKY or PARTIAL
PROCESS integrator description
ENERGY or FREQ map parameter in SI base units
TUNIT1 physical unit of the value column

Safe overwriting

CFITSIO uses a leading ! to replace a file:

output = hermes.outputs.HEALPixFormat("!map.fits.gz")
skymap.save(output)

Use it only after an explicit overwrite decision. The example suite refuses to replace products unless --overwrite is passed.

Inspect a file with Astropy

from astropy.io import fits

with fits.open("map.fits.gz", memmap=False) as hdus:
    print(hdus[0].header["VERSION"])
    table = hdus[1]
    print(table.header["NSIDE"], table.header["ORDERING"])
    print(table.header["ENERGY"], table.header["TUNIT1"])
    values = table.data.field(0)

Validate headers before interpreting numbers. In particular, do not assume the energy unit, coordinate system, or pixel ordering from the filename.

Unit conversion for plots

HERMES quantities are stored in the units declared by TUNIT1. The maintained gamma-ray plotting examples convert the default differential intensity from per square metre to per square centimetre before displaying E² I(E); the FITS data themselves are not changed.

Avoid hard-coded plot labels. Derive them from the validated product metadata or perform and document an explicit conversion.