TemplateNPredModel

class gammapy.modeling.models.TemplateNPredModel(map, spectral_model=None, name=None, filename=None, datasets_names=None)[source]

Bases: gammapy.modeling.models.core.ModelBase

Background model.

Create a new map by a tilt and normalization on the available map

Parameters
mapMap

Background model map

spectral_modelSpectralModel

Normalized spectral model, default is PowerLawNormSpectralModel

Attributes Summary

covariance

default_parameters

energy_center

True energy axis bin centers (Quantity)

evaluation_radius

Angle

frozen

Frozen status of a model, True if all parameters are frozen

map

A lazy FITS data descriptor.

name

parameters

Parameters (Parameters)

position

SkyCoord

spectral_model

SpectralModel

tag

type

Methods Summary

copy([name])

A deep copy.

cutout(position, width[, mode, name])

Cutout background model.

evaluate()

Evaluate background model.

freeze([model_type])

Freeze model parameters

from_dict(data)

from_parameters(parameters, **kwargs)

Create model from parameter list

reassign(datasets_names, new_datasets_names)

Reassign a model from one dataset to another

stack(other[, weights, nan_to_num])

Stack background model in place.

to_dict([full_output])

Create dict for YAML serialisation

unfreeze([model_type])

Restore parameters frozen status to default

Attributes Documentation

covariance
default_parameters = <gammapy.modeling.parameter.Parameters object>
energy_center

True energy axis bin centers (Quantity)

evaluation_radius

Angle

frozen

Frozen status of a model, True if all parameters are frozen

map

A lazy FITS data descriptor.

Parameters
cachebool

Whether to cache the data.

name
parameters

Parameters (Parameters)

position

SkyCoord

spectral_model

SpectralModel

tag = 'TemplateNPredModel'
type

Methods Documentation

copy(name=None)[source]

A deep copy.

cutout(position, width, mode='trim', name=None)[source]

Cutout background model.

Parameters
positionSkyCoord

Center position of the cutout region.

widthtuple of Angle

Angular sizes of the region in (lon, lat) in that specific order. If only one value is passed, a square region is extracted.

mode{‘trim’, ‘partial’, ‘strict’}

Mode option for Cutout2D, for details see Cutout2D.

namestr

Name of the returned background model.

Returns
cutoutTemplateNPredModel

Cutout background model.

evaluate()[source]

Evaluate background model.

Returns
background_mapMap

Background evaluated on the Map

freeze(model_type='spectral')[source]

Freeze model parameters

classmethod from_dict(data)[source]
classmethod from_parameters(parameters, **kwargs)

Create model from parameter list

Parameters
parametersParameters

Parameters for init

Returns
modelModel

Model instance

reassign(datasets_names, new_datasets_names)

Reassign a model from one dataset to another

Parameters
datasets_namesstr or list

Name of the datasets where the model is currently defined

new_datasets_namesstr or list

Name of the datasets where the model should be defined instead. If multiple names are given the two list must have the save length, as the reassignment is element-wise.

Returns
modelModel

Reassigned model.

stack(other, weights=None, nan_to_num=True)[source]

Stack background model in place.

Stacking the background model resets the current parameters values.

Parameters
otherTemplateNPredModel

Other background model.

nan_to_num: bool

Non-finite values are replaced by zero if True (default).

to_dict(full_output=False)[source]

Create dict for YAML serialisation

unfreeze(model_type='spectral')[source]

Restore parameters frozen status to default