SkyModel#

class gammapy.modeling.models.SkyModel[source]#

Bases: CovarianceMixin, ModelBase

Sky model component.

This model represents a factorised sky model. It has Parameters combining the spatial and spectral parameters.

Parameters:
spectral_modelSpectralModel

Spectral model.

spatial_modelSpatialModel

Spatial model (must be normalised to integrate to 1).

temporal_modelTemporalModel

Temporal model.

namestr

Model identifier.

apply_irfdict

Dictionary declaring which IRFs should be applied to this model. Options are {“exposure”: True, “psf”: True, “edisp”: True}.

datasets_nameslist of str

Which datasets this model is applied to.

Attributes Summary

default_parameters

evaluation_bin_size_min

Minimal spatial bin size for spatial model evaluation.

evaluation_radius

Evaluation radius as an Angle.

evaluation_region

Evaluation region as an Angle.

frame

name

parameters

Parameters as a Parameters object.

parameters_unique_names

List of unique parameter names.

position

Position as a SkyCoord.

position_lonlat

Spatial model center position (lon, lat) in radians and frame of the model.

spatial_model

Spatial model as a SpatialModel object.

spectral_model

Spectral model as a SpectralModel object.

tag

temporal_model

Temporal model as a TemporalModel object.

Methods Summary

__call__(lon, lat, energy[, time])

Call self as a function.

contributes(mask[, margin])

Check if a sky model contributes within a mask map.

copy([name, copy_data])

Copy sky model.

create(spectral_model[, spatial_model, ...])

Create a model instance.

evaluate(lon, lat, energy[, time])

Evaluate the model at given points.

evaluate_geom(geom[, gti])

Evaluate model on Geom.

freeze([model_type])

Freeze parameters depending on model type.

from_dict(data, **kwargs)

Create SkyModel from dictionary.

integrate_geom(geom[, gti, oversampling_factor])

Integrate model on Geom.

to_dict([full_output])

Create dictionary for YAML serilisation.

unfreeze([model_type])

Restore parameters frozen status to default depending on model type.

Attributes Documentation

default_parameters = <gammapy.modeling.parameter.Parameters object>#
evaluation_bin_size_min#

Minimal spatial bin size for spatial model evaluation.

evaluation_radius#

Evaluation radius as an Angle.

evaluation_region#

Evaluation region as an Angle.

frame#
name#
parameters#
parameters_unique_names#

List of unique parameter names. Return formatted as par_type.par_name.

position#

Position as a SkyCoord.

position_lonlat#

Spatial model center position (lon, lat) in radians and frame of the model.

spatial_model#

Spatial model as a SpatialModel object.

spectral_model#

Spectral model as a SpectralModel object.

tag = ['SkyModel', 'sky-model']#
temporal_model#

Temporal model as a TemporalModel object.

Methods Documentation

__call__(lon, lat, energy, time=None)[source]#

Call self as a function.

contributes(mask, margin='0 deg')[source]#

Check if a sky model contributes within a mask map.

Parameters:
maskWcsNDMap of boolean type

Map containing a boolean mask.

marginQuantity

Add a margin in degree to the source evaluation radius. Used to take into account PSF width.

Returns:
modelsDatasetModels

Selected models contributing inside the region where mask is True.

copy(name=None, copy_data=False, **kwargs)[source]#

Copy sky model.

Parameters:
namestr, optional

Assign a new name to the copied model. Default is None.

copy_databool, optional

Copy the data arrays attached to models. Default is False.

**kwargsdict

Keyword arguments forwarded to SkyModel.

Returns:
modelSkyModel

Copied sky model.

classmethod create(spectral_model, spatial_model=None, temporal_model=None, **kwargs)[source]#

Create a model instance.

Parameters:
spectral_modelstr

Tag to create spectral model.

spatial_modelstr, optional

Tag to create spatial model. Default is None.

temporal_modelstr, optional

Tag to create temporal model. Default is None.

**kwargsdict

Keyword arguments passed to SkyModel.

Returns:
modelSkyModel

Sky model.

evaluate(lon, lat, energy, time=None)[source]#

Evaluate the model at given points.

The model evaluation follows numpy broadcasting rules.

Return differential surface brightness cube. At the moment in units: cm-2 s-1 TeV-1 deg-2.

Parameters:
lon, latQuantity

Spatial coordinates.

energyQuantity

Energy coordinate.

time: `~astropy.time.Time`, optional

Time coordinate. Default is None.

Returns:
valueQuantity

Model value at the given point.

evaluate_geom(geom, gti=None)[source]#

Evaluate model on Geom.

freeze(model_type=None)[source]#

Freeze parameters depending on model type.

Parameters:
model_type{None, “spatial”, “spectral”, “temporal”}

Freeze all parameters or only spatial/spectral/temporal. Default is None, such that all parameters are frozen.

classmethod from_dict(data, **kwargs)[source]#

Create SkyModel from dictionary.

integrate_geom(geom, gti=None, oversampling_factor=None)[source]#

Integrate model on Geom.

See integrate_geom and integral.

Parameters:
geomGeom or RegionGeom

Map geometry.

gtiGTI, optional

GIT table. Default is None.

oversampling_factorint, optional

The oversampling factor to use for spatial integration. Default is None: the factor is estimated from the model minimal bin size.

Returns:
fluxMap

Predicted flux map.

to_dict(full_output=False)[source]#

Create dictionary for YAML serilisation.

unfreeze(model_type=None)[source]#

Restore parameters frozen status to default depending on model type.

Parameters:
model_type{None, “spatial”, “spectral”, “temporal”}

Restore frozen status to default for all parameters or only spatial/spectral/temporal. Default is None, such that all parameters are restored to default frozen status.

__init__(spectral_model, spatial_model=None, temporal_model=None, name=None, apply_irf=None, datasets_names=None, covariance_data=None)[source]#
classmethod __new__(*args, **kwargs)#