OffDataBackgroundMaker

class gammapy.background.OffDataBackgroundMaker(data_store, outdir=None, run_list=None, obs_table=None, ntot_group=None, excluded_sources=None)[source]

Bases: object

OffDataBackgroundMaker class.

Class that will select an OFF list run from a Data list and then group this runlist in group. Then for each group, it will compute the background rate model in 3D (X, Y, energy) or 2D (energy, offset) via the class FOVCubeBackgroundModel (3D) or EnergyOffsetBackgroundModel (2D).

Parameters:

data_store : DataStore

Data for the background model

outdir : str

directory where will go the output

run_list : str

filename where is store the OFF run list

obs_table : ObservationTable

observation table of the OFF run List used for the background modelling require GROUP_ID column

ntot_group : int

Number of group

excluded_sources : Table

Table of excluded sources. Required columns: RA, DEC, Radius

Methods Summary

define_obs_table() Make an obs table for the OFF runs list.
filename(modeltype, group_id[, smooth]) Filename for a given modeltype and group_id.
group_observations() Group the background observation list.
make_bkg_index_table(data_store, modeltype) Make background model index table.
make_model(modeltype[, ebounds, offset]) Make background models.
make_total_index_table(data_store, modeltype) Create a hdu-index table with a row containing the link to the background model for each observation.
save_model(modeltype, ngroup[, smooth]) Save model to fits for one group.
save_models(modeltype[, smooth]) Save model to fits for all the groups.
select_observations(selection[, n_obs_max]) Make off run list for background models.
smooth_model(modeltype, ngroup) Smooth the bkg model for one group.
smooth_models(modeltype) Smooth the bkg model for each group.

Methods Documentation

define_obs_table()[source]

Make an obs table for the OFF runs list.

This table is created from the obs table of all the runs

Returns:

table : Table

observation table of the OFF run List

static filename(modeltype, group_id, smooth=False)[source]

Filename for a given modeltype and group_id.

Parameters:

modeltype : {‘3D’, ‘2D’}

Type of the background modelisation

group_id : int

number of the background model group

smooth : bool

True if you want to use the smooth bkg model

group_observations()[source]

Group the background observation list.

For now we’ll just use the zenith binning from HAP.

make_bkg_index_table(data_store, modeltype, out_dir_background_model=None, filename_obs_group_table=None, smooth=False)[source]

Make background model index table.

Parameters:

data_store : DataStore

DataStore for the runs for which ones we want to compute a background model

modeltype : {‘3D’, ‘2D’}

Type of the background modelisation

out_dir_background_model : str

directory where are located the backgrounds models for each group

filename_obs_group_table : str

name of the file containing the Table with the group infos

smooth : bool

True if you want to use the smooth bkg model

Returns:

index_table_bkg : Table

Index hdu table only for the background in order to associate a bkg model for each observation

make_model(modeltype, ebounds=None, offset=None)[source]

Make background models.

Create the list of background model (FOVCubeBackgroundModel (3D) or EnergyOffsetBackgroundModel (2D)) for each group

Parameters:

modeltype : {‘3D’, ‘2D’}

Type of the background modelisation

ebounds : EnergyBounds

Energy bounds vector (1D)

offset : Angle

Offset vector (1D)

make_total_index_table(data_store, modeltype, out_dir_background_model=None, filename_obs_group_table=None, smooth=False)[source]

Create a hdu-index table with a row containing the link to the background model for each observation.

Parameters:

data_store : DataStore

DataStore for the runs for which ones we want to compute a background model

modeltype : {‘3D’, ‘2D’}

Type of the background modelisation

out_dir_background_model : str

directory where are located the backgrounds models for each group

filename_obs_group_table : str

name of the file containing the Table with the group infos

smooth : bool

True if you want to use the smooth bkg model

Returns:

index_table_new : Table

Index hdu table with a background row

save_model(modeltype, ngroup, smooth=False)[source]

Save model to fits for one group.

Parameters:

modeltype : {‘3D’, ‘2D’}

Type of the background modelisation

ngroup : int

Groups ID

save_models(modeltype, smooth=False)[source]

Save model to fits for all the groups.

Parameters:

modeltype : {‘3D’, ‘2D’}

Type of the background modelisation

select_observations(selection, n_obs_max=None)[source]

Make off run list for background models.

  • selection=’offplane’ is all runs where - Observation is available here - abs(GLAT) > 5 (i.e. not in the Galactic plane)
  • selection=’all’ – all available observations
Parameters:

selection : {‘offplane’, ‘all’}

Observation selection method.

n_obs_max : int, None

Maximum number of observations (useful for quick testing)

smooth_model(modeltype, ngroup)[source]

Smooth the bkg model for one group.

Parameters:

modeltype : {‘3D’, ‘2D’}

Type of the background modelisation

ngroup : int

Groups ID

smooth_models(modeltype)[source]

Smooth the bkg model for each group.

Parameters:

modeltype : {‘3D’, ‘2D’}

Type of the background modelisation