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

Name of the axis.

Attributes Summary

as_plot_center

Plot labels

as_plot_edges

Plot labels

as_plot_labels

Plot labels

as_plot_xerr

Plot labels

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

Methods Summary

assert_name(required_name)

Assert axis name if a specific one is required.

coord_to_idx(coord, **kwargs)

Transform labels to indices

coord_to_pix(coord)

Transform from axis labels to pixel coordinates.

copy()

Copy axis

downsample(*args, **kwargs)

Downsample axis

format_plot_xaxis(ax)

Format plot axis.

from_table(table[, format, idx])

Create time map axis from table

pad(*args, **kwargs)

Resample axis

pix_to_coord(pix)

Transform from pixel to axis coordinates.

pix_to_idx(pix[, clip])

Convert pix to idx

resample(*args, **kwargs)

Resample axis

slice(idx)

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

to_header([format, idx])

Create FITS header

upsample(*args, **kwargs)

Upsample axis

Attributes Documentation

as_plot_center

Plot labels

as_plot_edges

Plot labels

as_plot_labels

Plot labels

as_plot_xerr

Plot labels

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

Methods Documentation

assert_name(required_name)[source]

Assert axis name if a specific one is required.

Parameters
required_namestr

Required

coord_to_idx(coord, **kwargs)[source]

Transform labels 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 from axis labels to pixel coordinates.

Parameters
coordndarray

Array of axis label values.

Returns
pixndarray

Array of pixel coordinate values.

copy()[source]

Copy axis

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

Downsample axis

format_plot_xaxis(ax)[source]

Format plot axis.

Parameters
axAxis

Plot axis to format.

Returns
axAxis

Formatted plot 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.

Returns
axisTimeMapAxis

Time map axis.

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

Resample axis

pix_to_coord(pix)[source]

Transform from pixel to axis coordinates.

Parameters
pixndarray

Array of pixel coordinate values.

Returns
coordndarray

Array of axis coordinate values.

pix_to_idx(pix, clip=False)[source]

Convert pix to idx

Parameters
pixtuple of ndarray

Pixel coordinates.

clipbool

Choose whether to clip indices to the valid range of the axis. If false then indices for coordinates outside the axi range will be set -1.

Returns
idxtuple ndarray

Pixel indices.

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

Resample axis

slice(idx)[source]

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

Parameters
idxslice

Slice object selecting a subselection of the axis.

Returns
axisLabelMapAxis

Sliced axis object.

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

Create FITS header

Parameters
format{“ogip”}

Format specification

idxint

Column index of the axis.

Returns
headerHeader

Header to extend.

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

Upsample axis