Energy¶
-
class
gammapy.utils.energy.
Energy
[source]¶ Bases:
astropy.units.quantity.Quantity
Energy quantity scalar or array.
This is a
Quantity
sub-class that adds convenience methods to handle common tasks for energy bin center arrays, like FITS I/O or generating equal-log-spaced grids of energies.See Energy handling in Gammapy for further information.
Parameters: energy :
array
, scalar,Quantity
Energy
unit :
UnitBase
, str, optionalThe unit of the value specified for the energy. This may be any string that
Unit
understands, but it is better to give an actual unit object.dtype :
dtype
, optionalSee
Quantity
.copy : bool, optional
See
Quantity
.Attributes Summary
nbins
The number of bins. range
The covered energy range (tuple). Methods Summary
equal_log_spacing
(emin, emax, nbins[, unit, ...])Create Energy with equal log-spacing ( Energy
).from_fits
(hdu[, unit])Read ENERGIES fits extension ( Energy
).to_fits
()Write ENERGIES fits extension Attributes Documentation
-
nbins
¶ The number of bins.
-
range
¶ The covered energy range (tuple).
Methods Documentation
-
classmethod
equal_log_spacing
(emin, emax, nbins, unit=None, per_decade=False)[source]¶ Create Energy with equal log-spacing (
Energy
).if no unit is given, it will be taken from emax
Parameters: emin :
Quantity
, floatLowest energy bin
emax :
Quantity
, floatHighest energy bin
nbins : int
Number of bins
unit :
UnitBase
, strEnergy unit
per_decade : bool
Whether nbins is per decade.
-
classmethod
from_fits
(hdu, unit=None)[source]¶ Read ENERGIES fits extension (
Energy
).Parameters: hdu: `~astropy.io.fits.BinTableHDU`
ENERGIES
extensions.unit :
UnitBase
, str, NoneEnergy unit
-
to_fits
()[source]¶ Write ENERGIES fits extension
Returns: hdu:
BinTableHDU
ENERGIES fits extension
-