SkyModel#
- class gammapy.modeling.models.SkyModel(spectral_model, spatial_model=None, temporal_model=None, name=None, apply_irf=None, datasets_names=None, covariance_data=None)[source]#
Bases:
gammapy.modeling.models.core.ModelBase
Sky model component.
This model represents a factorised sky model. It has
Parameters
combining the spatial and spectral parameters.- Parameters
- spectral_model
SpectralModel
Spectral model.
- spatial_model
SpatialModel
Spatial model (must be normalised to integrate to 1).
- temporal_model
TemporalModel
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.
- spectral_model
Attributes Summary
Minimal spatial bin size for spatial model evaluation.
Evaluation radius as an
Angle
.Evaluation region as an
Angle
.Frozen status of a model, True if all parameters are frozen.
Parameters as a
Parameters
object.Position as a
SkyCoord
.Spatial model center position
(lon, lat)
in radians and frame of the model.Spatial model as a
SpatialModel
object.Spectral model as a
SpectralModel
object.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.
from_parameters
(parameters, **kwargs)Create model from parameter list.
integrate_geom
(geom[, gti, oversampling_factor])Integrate model on
Geom
.reassign
(datasets_names, new_datasets_names)Reassign a model from one dataset to another.
to_dict
([full_output])Create dictionary for YAML serilisation.
unfreeze
([model_type])Restore parameters frozen status to default depending on model type.
Attributes Documentation
- covariance#
- default_parameters = <gammapy.modeling.parameter.Parameters object>#
- evaluation_bin_size_min#
Minimal spatial bin size for spatial model evaluation.
- frame#
- frozen#
Frozen status of a model, True if all parameters are frozen.
- name#
- parameters#
- 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.
- type#
Methods Documentation
- contributes(mask, margin='0 deg')[source]#
Check if a sky model contributes within a mask map.
- Parameters
- Returns
- models
DatasetModels
Selected models contributing inside the region where mask is True.
- models
- 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
.
- 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_parameters(parameters, **kwargs)#
Create model from parameter list.
- Parameters
- parameters
Parameters
Parameters for init.
- parameters
- Returns
- model
Model
Model instance.
- model
- integrate_geom(geom, gti=None, oversampling_factor=None)[source]#
Integrate model on
Geom
.See
integrate_geom
andintegral
.- Parameters
- geom
Geom
orRegionGeom
Map geometry.
- gti
GTI
, 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.
- geom
- Returns
- flux
Map
Predicted flux map.
- flux
- 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
- model
Model
Reassigned model.
- model
- 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.