HpxMap#

class gammapy.maps.HpxMap[source]#

Bases: Map

Base class for HEALPIX map classes.

Parameters:
geomHpxGeom

HEALPix geometry object.

datandarray

Data array.

metadict, optional

Dictionary to store metadata. Default is None.

unitUnit

The map unit.

Notes

Methods Summary

create([nside, binsz, nest, map_type, ...])

Factory method to create an empty HEALPix map.

from_hdulist(hdu_list[, hdu, hdu_bands, ...])

Make a HpxMap object from a FITS HDUList.

to_hdu([hdu, hdu_bands, sparse, format])

Make a FITS HDU with input data.

to_hdulist([hdu, hdu_bands, sparse, format])

Convert to HDUList.

to_swapped()

Return a new map with the opposite scheme (ring or nested).

to_wcs([sum_bands, normalize, proj, ...])

Make a WCS object and convert HEALPix data into WCS projection.

Methods Documentation

classmethod create(nside=None, binsz=None, nest=True, map_type='hpx', frame='icrs', data=None, skydir=None, width=None, dtype='float32', region=None, axes=None, meta=None, unit='')[source]#

Factory method to create an empty HEALPix map.

Parameters:
nsideint or ndarray, optional

HEALPix NSIDE parameter. This parameter sets the size of the spatial pixels in the map. Default is None.

binszfloat or ndarray, optional

Approximate pixel size in degrees. An NSIDE will be chosen that corresponds to a pixel size closest to this value. This option is superseded by nside. Default is None.

nestbool, optional

Indexing scheme. If True, “NESTED” scheme. If False, “RING” scheme. Default is True.

map_type{‘hpx’, ‘hpx-sparse’}, optional

Map type. Selects the class that will be used to instantiate the map. Default is “hpx”.

frame{“icrs”, “galactic”}

Coordinate system, either Galactic (“galactic”) or Equatorial (“icrs”). Default is “icrs”.

datandarray, optional

Data array. Default is None.

skydirtuple or SkyCoord, optional

Sky position of map center. Can be either a SkyCoord object or a tuple of longitude and latitude in deg in the coordinate system of the map. Default is None.

widthfloat, optional

Diameter of the map in degrees. If None then an all-sky geometry will be created. Default is None.

dtypestr, optional

Data type. Default is “float32”.

regionstr, optional

HEALPix region string. Default is None.

axeslist, optional

List of MapAxis objects for each non-spatial dimension. Default is None.

metadict, optional

Dictionary to store the metadata. Default is None.

unitstr or Unit, optional

The map unit. Default is “”.

Returns:
mapHpxMap

A HEALPix map object.

classmethod from_hdulist(hdu_list, hdu=None, hdu_bands=None, format=None, colname=None)[source]#

Make a HpxMap object from a FITS HDUList.

Parameters:
hdu_listHDUList

HDU list containing HDUs for map data and bands.

hdustr, optional

Name or index of the HDU with the map data. If None then the method will try to load map data from the first BinTableHDU in the file. Default is None.

hdu_bandsstr, optional

Name or index of the HDU with the BANDS table. Default is None.

formatstr, optional

FITS format convention. By default, files will be written to the gamma-astro-data-formats (GADF) format. This option can be used to write files that are compliant with format conventions required by specific software (e.g. the Fermi Science Tools). The following formats are supported:

  • “gadf” (default)

  • “fgst-ccube”

  • “fgst-ltcube”

  • “fgst-bexpcube”

  • “fgst-srcmap”

  • “fgst-template”

  • “fgst-srcmap-sparse”

  • “galprop”

  • “galprop2”

Returns:
hpx_mapHpxMap

Map object.

to_hdu(hdu=None, hdu_bands=None, sparse=False, format=None)[source]#

Make a FITS HDU with input data.

Parameters:
hdustr, optional

The HDU extension name. Default is None.

hdu_bandsstr, optional

The HDU extension name for BANDS table. Default is None.

sparsebool, optional

Set INDXSCHM to SPARSE and sparsify the map by only writing pixels with non-zero amplitude. Default is False.

format{None, ‘fgst-ccube’, ‘fgst-template’, ‘gadf’}

FITS format convention. If None this will be set to the default convention of the map. Default is None.

Returns:
hdu_outBinTableHDU or ImageHDU

Output HDU containing map data.

to_hdulist(hdu='SKYMAP', hdu_bands=None, sparse=False, format='gadf')[source]#

Convert to HDUList.

Parameters:
hdustr, optional

The HDU extension name. Default is “SKYMAP”.

hdu_bandsstr, optional

The HDU extension name for BANDS table. Default is None.

sparsebool, optional

Set INDXSCHM to SPARSE and sparsify the map by only writing pixels with non-zero amplitude. Default is False.

formatstr, optional

FITS format convention. By default, files will be written to the gamma-astro-data-formats (GADF) format. This option can be used to write files that are compliant with format conventions required by specific software (e.g. the Fermi Science Tools). The following formats are supported:

  • “gadf” (default)

  • “fgst-ccube”

  • “fgst-ltcube”

  • “fgst-bexpcube”

  • “fgst-srcmap”

  • “fgst-template”

  • “fgst-srcmap-sparse”

  • “galprop”

  • “galprop2”

Returns:
hdu_listHDUList

The FITS HDUList.

abstractmethod to_swapped()[source]#

Return a new map with the opposite scheme (ring or nested).

Returns:
mapHpxMap

Map object.

abstractmethod to_wcs(sum_bands=False, normalize=True, proj='AIT', oversample=2, width_pix=None, hpx2wcs=None)[source]#

Make a WCS object and convert HEALPix data into WCS projection.

Parameters:
sum_bandsbool, optional

Sum over non-spatial axes before reprojecting. If False then the WCS map will have the same dimensionality as the HEALPix one. Default is False.

normalizebool, optional

Preserve integral by splitting HEALPix values between bins. Default is True.

projstr, optional

WCS-projection. Default is “AIT”.

oversamplefloat, optional

Oversampling factor for WCS map. This will be the approximate ratio of the width of a HEALPix pixel to a WCS pixel. If this parameter is None then the width will be set from width_pix. Default is 2.

width_pixint, optional

Width of the WCS geometry in pixels. The pixel size will be set to the number of pixels satisfying oversample or width_pix whichever is smaller. If this parameter is None then the width will be set from oversample. Default is None.

hpx2wcsHpxToWcsMapping, optional

Set the HEALPix to WCS mapping object that will be used to generate the WCS map. If None then a new mapping will be generated based on proj and oversample arguments. Default is None.

Returns:
map_outWcsMap

WCS map object.

__init__(geom, data, meta=None, unit='')#
classmethod __new__(*args, **kwargs)#