Maps#
- class gammapy.maps.Maps(**kwargs)[source]#
Bases:
collections.abc.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
Map geometry as a
Geom
object.Methods Summary
clear
()from_geom
(geom, names[, kwargs_list])Create map dictionary from a geometry.
from_hdulist
(hdulist[, hdu_bands])Create map dictionary from a HDU list.
get
(k[,d])items
()keys
()pop
(k[,d])If key is not found, d is returned if given, otherwise KeyError is raised.
popitem
()as a 2-tuple; but raise KeyError if D is empty.
read
(filename[, checksum])Read map dictionary from file.
setdefault
(k[,d])to_hdulist
([hdu_bands])Convert map dictionary to list of HDUs.
update
([E, ]**F)If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v
values
()write
(filename[, overwrite, checksum])Write map dictionary to file.
Attributes Documentation
Methods Documentation
- clear() None. Remove all items from D. #
- classmethod from_geom(geom, names, kwargs_list=None)[source]#
Create map dictionary from a geometry.
- Parameters
- geom
Geom
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()
.
- geom
- Returns
- maps
Maps
Maps object.
- maps
- 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.
- get(k[, d]) D[k] if k in D, else d. d defaults to None. #
- items() a set-like object providing a view on D's items #
- keys() a set-like object providing a view on D's keys #
- pop(k[, d]) v, remove specified key and return the corresponding value. #
If key is not found, d is returned if given, otherwise KeyError is raised.
- popitem() (k, v), remove and return some (key, value) pair #
as a 2-tuple; but raise KeyError if D is empty.
- 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
- maps
Maps
Maps object.
- maps
- setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in D #
- 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
- hdulist
HDUList
Map dataset list of HDUs.
- hdulist
- update([E, ]**F) None. Update D from mapping/iterable E and F. #
If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v
- values() an object providing a view on D's values #
- 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.