MapAxes#
- class gammapy.maps.MapAxes(axes, n_spatial_axes=None)[source]#
Bases:
collections.abc.Sequence
MapAxis container class.
- Parameters
- axeslist of
MapAxis
List of map axis objects.
- axeslist of
Attributes Summary
Center coordinates
Whether axes is flat
Whether axes is unidimensional
Iterate by shape
Names of the axes
Primary extra axis, defined as the one longest
Reverse axes order
Shape of the axes
Methods Summary
assert_names
(required_names)Assert required axis names and order
Bin axes volume
coord_to_idx
(coord[, clip])Transform from axis to pixel indices.
coord_to_pix
(coord)Transform from axis to pixel coordinates.
copy
()Init map axes instance by copying each axis.
count
(value)downsample
(factor, axis_name)Downsample axis by a given factor
drop
(axis_name)Drop an axis.
from_default
(axes[, n_spatial_axes])Make a sequence of
MapAxis
objects.from_table
(table[, format])Create MapAxes from table
from_table_hdu
(hdu[, format])Create MapAxes from BinTableHDU
get_coord
([mode, axis_name])Get axes coordinates
index
(axis_name)Get index in list
index_data
(axis_name)Get data index of the axes
is_allclose
(other, **kwargs)Check if other map axes are all close.
pad
(axis_name, pad_width)Pad axes
pix_to_coord
(pix)Convert pixel coordinates to map coordinates.
pix_to_idx
(pix[, clip])Convert pix to idx
rename_axes
(names, new_names)Rename the axes.
replace
(axis)Replace a given axis
resample
(axis)Resample axis binning.
slice_by_idx
(slices)Create a new geometry by slicing the non-spatial axes.
squash
(axis_name)Squash axis.
to_header
([format])Convert axes to FITS header
to_table
([format])Convert axes to table
to_table_hdu
([format, hdu_bands])Make FITS table columns for map axes.
upsample
(factor, axis_name)Upsample axis by a given factor
Attributes Documentation
- center_coord#
Center coordinates
- is_flat#
Whether axes is flat
- is_unidimensional#
Whether axes is unidimensional
- iter_with_reshape#
Iterate by shape
- names#
Names of the axes
- reverse#
Reverse axes order
- shape#
Shape of the axes
Methods Documentation
- assert_names(required_names)[source]#
Assert required axis names and order
- Parameters
- required_nameslist of str
Required
- count(value) integer -- return number of occurrences of value #
- downsample(factor, axis_name)[source]#
Downsample axis by a given factor
- Parameters
- factorint
Upsampling factor.
- axis_namestr
Axis to upsample.
- Returns
- axes
MapAxes
Map axes
- axes
- drop(axis_name)[source]#
Drop an axis.
- Parameters
- axis_namestr
Name of the axis to remove.
- Returns
- axes
MapAxes
Axes with squashed axis.
- axes
- classmethod from_table_hdu(hdu, format='gadf')[source]#
Create MapAxes from BinTableHDU
- Parameters
- hdu
BinTableHDU
Bin table HDU
- hdu
- Returns
- axes
MapAxes
Map axes object
- axes
- get_coord(mode='center', axis_name=None)[source]#
Get axes coordinates
- Parameters
- mode{“center”, “edges”}
Coordinate center or edges
- axis_namestr
Axis name for which mode=’edges’ applies
- Returns
- coordsdict of
Quanity
Map coordinates
- coordsdict of
- index_data(axis_name)[source]#
Get data index of the axes
- Parameters
- axis_namestr
Name of the axis.
- Returns
- idxint
Data index
- is_allclose(other, **kwargs)[source]#
Check if other map axes are all close.
- Parameters
- other
MapAxes
Other map axes
- **kwargsdict
Keyword arguments forwarded to
is_allclose
- other
- Returns
- is_allclosebool
Whether other axes are all close
- pad(axis_name, pad_width)[source]#
Pad axes
- Parameters
- axis_namestr
Name of the axis to pad.
- pad_widthint or tuple of int
Pad width
- Returns
- axes
MapAxes
Axes with squashed axis.
- axes
- pix_to_coord(pix)[source]#
Convert pixel coordinates to map coordinates.
- Parameters
- pixtuple
Tuple of pixel coordinates.
- Returns
- coordstuple
Tuple of map coordinates.
- replace(axis)[source]#
Replace a given axis
- Parameters
- axis
MapAxis
Map axis
- axis
- Returns
- axesMapAxes
Map axe
- resample(axis)[source]#
Resample axis binning.
This method groups the existing bins into a new binning.
- squash(axis_name)[source]#
Squash axis.
- Parameters
- axis_namestr
Axis to squash.
- Returns
- axes
MapAxes
Axes with squashed axis.
- axes
- to_header(format='gadf')[source]#
Convert axes to FITS header
- Parameters
- format{“gadf”}
Header format
- Returns
- header
Header
FITS header.
- header
- to_table(format='gadf')[source]#
Convert axes to table
- Parameters
- format{“gadf”, “gadf-dl3”, “fgst-ccube”, “fgst-template”, “ogip”, “ogip-sherpa”, “ogip-arf”, “ogip-arf-sherpa”} # noqa E501
Format to use.
- Returns
- table
Table
Table with axis data
- table
- to_table_hdu(format='gadf', hdu_bands=None)[source]#
Make FITS table columns for map axes.
- Parameters
- format{“gadf”, “fgst-ccube”, “fgst-template”}
Format to use.
- hdu_bandsstr
Name of the bands HDU to use.
- Returns
- hdu
BinTableHDU
Bin table HDU.
- hdu