LabelMapAxis#

class gammapy.maps.LabelMapAxis(labels, name='')[source]#

Bases: object

Map axis using labels.

Parameters
labelslist of str

Labels to be used for the axis nodes.

namestr, optional

Name of the axis. Default is “”.

Attributes Summary

as_plot_center

Return labels for plotting.

as_plot_edges

Return labels for plotting.

as_plot_labels

Return labels for plotting.

as_plot_xerr

Return labels for plotting.

bin_width

Bin width is unity.

center

Center of the label axis.

edges

Edges of the label axis.

edges_max

Edges of the label axis.

edges_min

Edges of the label axis.

name

Name of the axis.

nbin

Number of bins.

node_type

unit

Unit of the axis.

Methods Summary

assert_name(required_name)

Assert axis name if a specific one is required.

concatenate(axis)

Concatenate another label map axis to this one into a new instance of LabelMapAxis.

coord_to_idx(coord, **kwargs)

Transform label coordinate to indices.

coord_to_pix(coord)

Transform label coordinate to pixel coordinate.

copy()

Copy the axis.

downsample(*args, **kwargs)

Not supported for label axis.

format_plot_xaxis(ax)

Format plot axis.

from_stack(axes)

Create a label map axis by merging a list of label axis.

from_table(table[, format, idx])

Create time map axis from table.

is_allclose(other, **kwargs)

Check if other map axis is all close.

pad(*args, **kwargs)

Not supported for label axis.

pix_to_coord(pix)

Transform pixel to label coordinate.

pix_to_idx(pix[, clip])

Convert pixel to idx

resample(*args, **kwargs)

Not supported for label axis.

slice(idx)

Create a new axis object by extracting a slice from this axis.

squash()

Create a new axis object by squashing the axis into one bin.

to_header([format, idx])

Create FITS header.

upsample(*args, **kwargs)

Not supported for label axis.

Attributes Documentation

as_plot_center#

Return labels for plotting.

as_plot_edges#

Return labels for plotting.

as_plot_labels#

Return labels for plotting.

as_plot_xerr#

Return labels for plotting.

bin_width#

Bin width is unity.

center#

Center of the label axis.

edges#

Edges of the label axis.

edges_max#

Edges of the label axis.

edges_min#

Edges of the label axis.

name#

Name of the axis.

nbin#

Number of bins.

node_type = 'label'#
unit#

Unit of the axis.

Methods Documentation

assert_name(required_name)[source]#

Assert axis name if a specific one is required.

Parameters
required_namestr

Required name.

concatenate(axis)[source]#

Concatenate another label map axis to this one into a new instance of LabelMapAxis.

Names must agree between the axes. Labels must be unique.

Parameters
axisLabelMapAxis

Axis to concatenate with.

Returns
axisLabelMapAxis

Concatenation of the two axis.

coord_to_idx(coord, **kwargs)[source]#

Transform label coordinate to indices.

If the label is not present an error is raised.

Parameters
coordTime

Array of axis coordinate values.

Returns
idxndarray

Array of bin indices.

coord_to_pix(coord)[source]#

Transform label coordinate to pixel coordinate.

Parameters
coordndarray

Array of axis label values.

Returns
pixndarray

Array of pixel coordinate values.

copy()[source]#

Copy the axis.

downsample(*args, **kwargs)[source]#

Not supported for label axis.

format_plot_xaxis(ax)[source]#

Format plot axis.

Parameters
axAxis

Plot axis to format.

Returns
axAxis

Formatted plot axis.

classmethod from_stack(axes)[source]#

Create a label map axis by merging a list of label axis.

Parameters
axeslist of LabelMapAxis

List of label map axis to be merged.

Returns
axisLabelMapAxis

Stacked axis.

classmethod from_table(table, format='gadf', idx=0)[source]#

Create time map axis from table.

Parameters
tableTable

Bin table HDU.

format{“gadf”}

Format to use.

idxint

Axis index. Default is 0.

Returns
axisTimeMapAxis

Time map axis.

is_allclose(other, **kwargs)[source]#

Check if other map axis is all close.

Parameters
otherLabelMapAxis

Other map axis.

Returns
is_allclosebool

Whether other axis is allclose.

pad(*args, **kwargs)[source]#

Not supported for label axis.

pix_to_coord(pix)[source]#

Transform pixel to label coordinate.

Parameters
pixndarray

Array of pixel coordinate values.

Returns
coordndarray

Array of axis coordinate values.

pix_to_idx(pix, clip=False)[source]#

Convert pixel to idx

Parameters
pixtuple of ndarray

Pixel coordinates.

clipbool, optional

Choose whether to clip indices to the valid range of the axis. Default is False. If False, then indices for coordinates outside the axis range will be set to -1.

Returns
idxtuple ndarray

Pixel indices.

resample(*args, **kwargs)[source]#

Not supported for label axis.

slice(idx)[source]#

Create a new axis object by extracting a slice from this axis.

Parameters
idxslice

Slice object selecting a sub-selection of the axis.

Returns
axisLabelMapAxis

Sliced axis object.

squash()[source]#

Create a new axis object by squashing the axis into one bin.

The label of the new axis is given as “first-label…last-label”.

Returns
axisLabelMapAxis

Squashed label map axis.

to_header(format='gadf', idx=0)[source]#

Create FITS header.

Parameters
format{“ogip”}

Format specification. Default is “gadf”.

idxint, optional

Column index of the axis. Default is 0.

Returns
headerHeader

Header to extend.

upsample(*args, **kwargs)[source]#

Not supported for label axis.