EnergyBounds¶
-
class
gammapy.utils.energy.
EnergyBounds
[source]¶ Bases:
gammapy.utils.energy.Energy
EnergyBounds array.
This is a
Energy
sub-class that adds convenience methods to handle common tasks for energy bin edges arrays, like FITS I/O or generating arrays of bin centers.See Energy handling in Gammapy for further information.
Parameters: energy :
array
, scalar,Quantity
EnergyBounds
unit :
UnitBase
, strThe unit of the values specified for the energy. This may be any string that
Unit
understands, but it is better to give an actual unit object.Attributes Summary
bands
Width of the energy bins. boundaries
Energy range. log_centers
Log centers of the energy bounds. lower_bounds
Lower energy bin edges. nbins
The number of bins. upper_bounds
Upper energy bin edges. Methods Summary
bin
(i)Return energy bin edges (zero-based numbering). contains
(energy)Check of energy is contained in boundaries. equal_log_spacing
(emin, emax, nbins[, unit])EnergyBounds with equal log-spacing ( EnergyBounds
).find_energy_bin
(energy)Find the bins that contain the specified energy values. from_dict
(d)Read dict representing an energy range. from_ebounds
(hdu)Read EBOUNDS fits extension ( EnergyBounds
).from_lower_and_upper_bounds
(lower, upper[, unit])EnergyBounds from lower and upper bounds ( EnergyBounds
).from_rmf_matrix
(hdu)Read MATRIX fits extension ( EnergyBounds
).to_dict
()Construct dict representing an energy range. Attributes Documentation
-
bands
¶ Width of the energy bins.
-
boundaries
¶ Energy range.
-
log_centers
¶ Log centers of the energy bounds.
-
lower_bounds
¶ Lower energy bin edges.
-
nbins
¶ The number of bins.
-
upper_bounds
¶ Upper energy bin edges.
Methods Documentation
-
contains
(energy)[source]¶ Check of energy is contained in boundaries.
Parameters: energy :
Energy
Array of energies to test
-
classmethod
equal_log_spacing
(emin, emax, nbins, unit=None)[source]¶ EnergyBounds with equal log-spacing (
EnergyBounds
).If no unit is given, it will be taken from emax.
Parameters: emin :
Quantity
, floatLowest energy bin
emax :
Quantity
, floatHighest energy bin
bins : int
Number of bins
unit :
UnitBase
, str, NoneEnergy unit
-
find_energy_bin
(energy)[source]¶ Find the bins that contain the specified energy values.
Parameters: energy :
Energy
Array of energies to search for.
Returns: bin_index :
ndarray
Indices of the energy bins containing the specified energies.
-
classmethod
from_ebounds
(hdu)[source]¶ Read EBOUNDS fits extension (
EnergyBounds
).Parameters: hdu: `~astropy.io.fits.BinTableHDU`
EBOUNDS
extensions.
-
classmethod
from_lower_and_upper_bounds
(lower, upper, unit=None)[source]¶ EnergyBounds from lower and upper bounds (
EnergyBounds
).If no unit is given, it will be taken from upper.
Parameters: lower,upper :
Quantity
, floatLowest and highest energy bin
unit :
UnitBase
, str, NoneEnergy units
-
classmethod
from_rmf_matrix
(hdu)[source]¶ Read MATRIX fits extension (
EnergyBounds
).Parameters: hdu: `~astropy.io.fits.BinTableHDU`
MATRIX
extensions.
-