EnergyOffsetArray

class gammapy.background.EnergyOffsetArray(energy, offset, data=None, data_units='', data_err=None)[source]

Bases: object

Energy offset dependent array.

TODO: take quantity data in __init__ instead of data and data_units separately.

Parameters:

energy : EnergyBounds

Energy bounds vector (1D)

offset : Angle

Offset vector (1D)

data : ndarray, optional

Data array (2D)

data_err : ndarray, optional

Data array (2D) containing the errors on the data

Attributes Summary

bin_volume Per-pixel bin volume (solid angle * energy).
offset_bin_center Offset bin center location (1D Angle in deg).
solid_angle Solid angle for each offset bin (1D Quantity in sr).

Methods Summary

acceptance_curve_in_energy_band(energy_band) Compute acceptance curve in energy band.
evaluate([energy, offset, interp_kwargs]) Interpolate at a given offset and energy.
evaluate_at_energy(energy[, interp_kwargs]) Evaluate at one given energy.
evaluate_at_offset(offset[, interp_kwargs]) Evaluate at one given offset.
fill_events(event_lists) Fill events histogram.
from_table(table[, data_name]) Create from Table.
plot([ax]) Plot Energy_offset Array image (x=offset, y=energy).
read(filename[, hdu, data_name]) Read from FITS file.
to_cube([coordx_edges, coordy_edges, …]) Transform into a FOVCube.
to_table([data_name]) Convert to Table.
write(filename[, data_name]) Write to FITS file.

Attributes Documentation

bin_volume

Per-pixel bin volume (solid angle * energy). (2D Quantity in Tev sr).

offset_bin_center

Offset bin center location (1D Angle in deg).

solid_angle

Solid angle for each offset bin (1D Quantity in sr).

Methods Documentation

acceptance_curve_in_energy_band(energy_band, energy_bins=10, interp_kwargs=None)[source]

Compute acceptance curve in energy band.

Evaluate the EnergyOffsetArray at different energies in the energy_band. Then integrate them in order to get the total acceptance curve

Parameters:

energy_band : Quantity

Tuple (energy_min, energy_max)

energy_bins : int or Quantity

Energy bin definition.

interp_kwargs : dict

option for interpolation for RegularGridInterpolator

Returns:

table : Table

two column: offset and integral values (units = self.data.unit * self.energy.units)

evaluate(energy=None, offset=None, interp_kwargs=None)[source]

Interpolate at a given offset and energy.

Parameters:

energy : Quantity

energy value

offset : Angle

offset value

interp_kwargs : dict

option for interpolation for RegularGridInterpolator

Returns:

values : Quantity

Interpolated value

evaluate_at_energy(energy, interp_kwargs=None)[source]

Evaluate at one given energy.

Parameters:

energy : Quantity

Energy

interp_kwargs : dict

Option for interpolation for RegularGridInterpolator

Returns:

table : Table

Table with two columns: offset, value

evaluate_at_offset(offset, interp_kwargs=None)[source]

Evaluate at one given offset.

Parameters:

offset : Angle

Offset angle

interp_kwargs : dict

option for interpolation for RegularGridInterpolator

Returns:

table : Table

Table with two columns: energy, value

fill_events(event_lists)[source]

Fill events histogram.

This add the counts to the existing value array.

Parameters:

event_lists : list of EventList

Python list of event list objects.

classmethod from_table(table, data_name='data')[source]

Create from Table.

Parameters:

table : Table

Table

data_name : str

Name of the data column in the table

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

Plot Energy_offset Array image (x=offset, y=energy).

classmethod read(filename, hdu='bkg_2d', data_name='data')[source]

Read from FITS file.

Parameters:

filename : str

File name

hdu : str

HDU name

data_name : str

Name of the data column in the table

to_cube(coordx_edges=None, coordy_edges=None, energy_edges=None, interp_kwargs=None)[source]

Transform into a FOVCube.

Parameters:

coordx_edges : Angle, optional

Spatial bin edges vector (low and high). X coordinate.

coordy_edges : Angle, optional

Spatial bin edges vector (low and high). Y coordinate.

energy_edges : EnergyBounds, optional

Energy bin edges vector (low and high).

interp_kwargs : dict

option for interpolation for RegularGridInterpolator

Returns:

cube : FOVCube

FOVCube

to_table(data_name='data')[source]

Convert to Table.

Parameters:

data_name : str

Name of the data column in the table

Returns:

table : Table

Table containing the EnergyOffsetArray.

write(filename, data_name='data', **kwargs)[source]

Write to FITS file.

Parameters:

filename : str

File name

data_name : str

Name of the data column in the table