EffectiveAreaTable2D#

class gammapy.irf.EffectiveAreaTable2D(axes, data=0, unit='', is_pointlike=False, fov_alignment=FoVAlignment.RADEC, meta=None, interp_kwargs=None)[source]#

Bases: gammapy.irf.core.IRF

2D effective area table.

Data format specification: AEFF_2D

Parameters
energy_axis_trueMapAxis

True energy axis

offset_axisMapAxis

Field of view offset axis.

dataQuantity

Effective area

metadict

Meta data

Examples

Here’s an example you can use to learn about this class:

>>> from gammapy.irf import EffectiveAreaTable2D
>>> filename = '$GAMMAPY_DATA/cta-1dc/caldb/data/cta/1dc/bcf/South_z20_50h/irf_file.fits'
>>> aeff = EffectiveAreaTable2D.read(filename, hdu='EFFECTIVE AREA')
>>> print(aeff)
EffectiveAreaTable2D
--------------------

  axes  : ['energy_true', 'offset']
  shape : (42, 6)
  ndim  : 2
  unit  : m2
  dtype : >f4

Here’s another one, created from scratch, without reading a file:

>>> from gammapy.irf import EffectiveAreaTable2D
>>> from gammapy.maps import MapAxis
>>> energy_axis_true = MapAxis.from_energy_bounds(
        "0.1 TeV", "100 TeV", nbin=30, name="energy_true"
    )
>>> offset_axis = MapAxis.from_bounds(0, 5, nbin=4, name="offset")
>>> aeff = EffectiveAreaTable2D(axes=[energy_axis_true, offset_axis], data=1e10, unit="cm2")
>>> print(aeff)
EffectiveAreaTable2D
--------------------

  axes  : ['energy_true', 'offset']
  shape : (30, 4)
  ndim  : 2
  unit  : cm2
  dtype : float64

Attributes Summary

axes

MapAxes

data

default_interp_kwargs

default_unit

fov_alignment

Alignment of the field of view coordinate axes, see FoVAlignment

has_offset_axis

Whether the IRF explicitly depends on offset

is_pointlike

Whether the IRF is pointlike of full containment.

quantity

Quantity

required_axes

tag

unit

Map unit (Unit)

Methods Summary

cumsum(axis_name)

Compute cumsum along a given axis

evaluate([method])

Evaluate IRF

from_hdulist(hdulist[, hdu, format])

Create from HDUList.

from_parametrization([energy_axis_true, ...])

Create parametrized effective area.

from_table(table[, format])

Read from Table.

integral(axis_name, **kwargs)

Compute integral along a given axis

integrate_log_log(axis_name, **kwargs)

Integrate along a given axis.

interp_missing_data(axis_name)

Interpolate missing data along a given axis

is_allclose(other[, rtol_axes, atol_axes])

Compare two data IRFs for equivalency

normalize(axis_name)

Normalise data in place along a given axis.

pad(pad_width, axis_name, **kwargs)

Pad irf along a given axis.

peek([figsize])

Quick-look summary plots.

plot([ax, add_cbar])

Plot effective area image.

plot_energy_dependence([ax, offset])

Plot effective area versus energy for a given offset.

plot_offset_dependence([ax, energy])

Plot effective area versus offset for a given energy.

read(filename[, hdu, format])

Read from file.

slice_by_idx(slices)

Slice sub IRF from IRF object.

to_hdulist([format])

to_table([format])

Convert to table

to_table_hdu([format])

Convert to BinTableHDU.

to_unit(unit)

Convert irf to different unit

write(filename, *args, **kwargs)

Write IRF to fits.

Attributes Documentation

axes#

MapAxes

data#
default_interp_kwargs = {'bounds_error': False, 'fill_value': 0.0}#
default_unit = Unit("m2")#
fov_alignment#

Alignment of the field of view coordinate axes, see FoVAlignment

has_offset_axis#

Whether the IRF explicitly depends on offset

is_pointlike#

Whether the IRF is pointlike of full containment.

quantity#

Quantity

required_axes = ['energy_true', 'offset']#
tag = 'aeff_2d'#
unit#

Map unit (Unit)

Methods Documentation

cumsum(axis_name)#

Compute cumsum along a given axis

Parameters
axis_namestr

Along which axis to integrate.

Returns
irfIRF

Cumsum IRF

evaluate(method=None, **kwargs)#

Evaluate IRF

Parameters
**kwargsdict

Coordinates at which to evaluate the IRF

methodstr {‘linear’, ‘nearest’}, optional

Interpolation method

Returns
arrayQuantity

Interpolated values

classmethod from_hdulist(hdulist, hdu=None, format='gadf-dl3')#

Create from HDUList.

Parameters
hdulistHDUList

HDU list

hdustr

HDU name

format{“gadf-dl3”}

Format specification

Returns
irfIRF

IRF class

classmethod from_parametrization(energy_axis_true=None, instrument='HESS')[source]#

Create parametrized effective area.

Parametrizations of the effective areas of different Cherenkov telescopes taken from Appendix B of Abramowski et al. (2010), see https://ui.adsabs.harvard.edu/abs/2010MNRAS.402.1342A .

\[A_{eff}(E) = g_1 \left(\frac{E}{\mathrm{MeV}}\right)^{-g_2}\exp{\left(-\frac{g_3}{E}\right)} # noqa: E501\]

This method does not model the offset dependence of the effective area, but just assumes that it is constant.

Parameters
energy_axis_trueMapAxis

Energy binning, analytic function is evaluated at log centers

instrument{‘HESS’, ‘HESS2’, ‘CTA’}

Instrument name

Returns
aeffEffectiveAreaTable2D

Effective area table

classmethod from_table(table, format='gadf-dl3')#

Read from Table.

Parameters
tableTable

Table with irf data

format{“gadf-dl3”}

Format specification

Returns
irfIRF

IRF class.

integral(axis_name, **kwargs)#

Compute integral along a given axis

This method uses interpolation of the cumulative sum.

Parameters
axis_namestr

Along which axis to integrate.

**kwargsdict

Coordinates at which to evaluate the IRF

Returns
arrayQuantity

Returns 2D array with axes offset

integrate_log_log(axis_name, **kwargs)#

Integrate along a given axis.

This method uses log-log trapezoidal integration.

Parameters
axis_namestr

Along which axis to integrate.

**kwargsdict

Coordinates at which to evaluate the IRF

Returns
arrayQuantity

Returns 2D array with axes offset

interp_missing_data(axis_name)#

Interpolate missing data along a given axis

is_allclose(other, rtol_axes=0.001, atol_axes=1e-06, **kwargs)#

Compare two data IRFs for equivalency

Parameters
othergammapy.irfs.IRF

The irf to compare against

rtol_axesfloat

Relative tolerance for the axes comparison.

atol_axesfloat

Relative tolerance for the axes comparison.

**kwargsdict

keywords passed to numpy.allclose

Returns
is_allclosebool

Whether the IRF is all close.

normalize(axis_name)#

Normalise data in place along a given axis.

Parameters
axis_namestr

Along which axis to normalize.

pad(pad_width, axis_name, **kwargs)#

Pad irf along a given axis.

Parameters
pad_width{sequence, array_like, int}

Number of pixels padded to the edges of each axis.

axis_namestr

Which axis to downsample. By default spatial axes are padded.

**kwargsdict

Keyword argument forwarded to pad

Returns
irfIRF

Padded irf

peek(figsize=(15, 5))[source]#

Quick-look summary plots.

Parameters
figsizetuple

Size of the figure.

plot(ax=None, add_cbar=True, **kwargs)[source]#

Plot effective area image.

plot_energy_dependence(ax=None, offset=None, **kwargs)[source]#

Plot effective area versus energy for a given offset.

Parameters
axAxes, optional

Axis

offsetAngle

Offset

kwargsdict

Forwarded tp plt.plot()

Returns
axAxes

Axis

plot_offset_dependence(ax=None, energy=None, **kwargs)[source]#

Plot effective area versus offset for a given energy.

Parameters
axAxes, optional

Axis

energyQuantity

Energy

**kwargsdict

Keyword argument passed to plot

Returns
axAxes

Axis

classmethod read(filename, hdu=None, format='gadf-dl3')#

Read from file.

Parameters
filenamestr or Path

Filename

hdustr

HDU name

format{“gadf-dl3”}

Format specification

Returns
irfIRF

IRF class

slice_by_idx(slices)#

Slice sub IRF from IRF object.

Parameters
slicesdict

Dict of axes names and slice object pairs. Contains one element for each non-spatial dimension. Axes not specified in the dict are kept unchanged.

Returns
slicedIRF

Sliced IRF object.

to_hdulist(format='gadf-dl3')#
to_table(format='gadf-dl3')#

Convert to table

Parameters
format{“gadf-dl3”}

Format specification

Returns
tableTable

IRF data table

to_table_hdu(format='gadf-dl3')#

Convert to BinTableHDU.

Parameters
format{“gadf-dl3”}

Format specification

Returns
hduBinTableHDU

IRF data table hdu

to_unit(unit)#

Convert irf to different unit

Parameters
unitUnit or str

New unit

Returns
irfIRF

IRF with new unit and converted data

write(filename, *args, **kwargs)#

Write IRF to fits.

Calls writeto, forwarding all arguments.