Maps#

class gammapy.maps.Maps[source]#

Bases: MutableMapping

A Dictionary containing Map objects sharing the same geometry.

This class simplifies handling and I/O of maps collections.

For maps with different geometries, use a regular dict.

Attributes Summary

geom

Map geometry as a Geom object.

Methods Summary

from_geom(geom, names[, kwargs_list])

Create map dictionary from a geometry.

from_hdulist(hdulist[, hdu_bands])

Create map dictionary from a HDU list.

read(filename[, checksum])

Read map dictionary from file.

to_hdulist([hdu_bands])

Convert map dictionary to list of HDUs.

write(filename[, overwrite, checksum])

Write map dictionary to file.

Attributes Documentation

geom#

Map geometry as a Geom object.

Methods Documentation

classmethod from_geom(geom, names, kwargs_list=None)[source]#

Create map dictionary from a geometry.

Parameters:
geomGeom

The input geometry that will be used by all maps.

nameslist of str

The list of all map names.

kwargs_listlist of dict

the list of arguments to be passed to from_geom().

Returns:
mapsMaps

Maps object.

classmethod from_hdulist(hdulist, hdu_bands='BANDS')[source]#

Create map dictionary from a HDU list.

Because FITS keywords are case-insensitive, all key names will return as lower-case.

Parameters:
hdulistHDUList

List of HDUs.

hdu_bandsstr, optional

Name of the HDU with the BANDS table. If set to None, each map should have its own hdu_band. Default is ‘BANDS’.

Returns:
mapsMaps

Maps object.

classmethod read(filename, checksum=False)[source]#

Read map dictionary from file.

Because FITS keywords are case-insensitive, all key names will return as lower-case.

Parameters:
filenamestr

Filename to read from.

Returns:
mapsMaps

Maps object.

to_hdulist(hdu_bands='BANDS')[source]#

Convert map dictionary to list of HDUs.

Parameters:
hdu_bandsstr, optional

Name of the HDU with the BANDS table. If set to None, each map will have its own hdu_band. Default is ‘BANDS’.

Returns:
hdulistHDUList

Map dataset list of HDUs.

write(filename, overwrite=False, checksum=False)[source]#

Write map dictionary to file.

Parameters:
filenamestr

Filename to write to.

overwritebool, optional

Overwrite existing file. Default is False.

checksumbool, optional

When True adds both DATASUM and CHECKSUM cards to the headers written to the file. Default is False.

__init__(**kwargs)[source]#
classmethod __new__(*args, **kwargs)#