TemplateNPredModel#
- class gammapy.modeling.models.TemplateNPredModel(map, spectral_model=None, name=None, filename=None, datasets_names=None, copy_data=True, spatial_model=None, covariance_data=None)[source]#
Bases:
ModelBase
Background model.
Create a new map by a tilt and normalization on the available map.
- Parameters:
- map
Map
Background model map.
- spectral_model
SpectralModel
Normalized spectral model. Default is
PowerLawNormSpectralModel
.- copy_databool
Create a deepcopy of the map data or directly use the original. Default is True. Use False to save memory in case of large maps.
- spatial_model
SpatialModel
Unitless Spatial model (unit is dropped on evaluation if defined). Default is None.
- map
Attributes Summary
True energy axis bin centers as a
Quantity
.Evaluation radius as a
Angle
.Frozen status of a model, True if all parameters are frozen.
A lazy FITS data descriptor.
Parameters as a
Parameters
object.List of unique parameter names.
Position as a
SkyCoord
.Spectral model as a
SpectralModel
object.Methods Summary
copy
([name, copy_data])Copy template npred model.
cutout
(position, width[, mode, name])Cutout background model.
evaluate
()Evaluate background model.
freeze
([model_type])Freeze model parameters.
from_dict
(data, **kwargs)from_parameters
(parameters, **kwargs)Create model from parameter list.
reassign
(datasets_names, new_datasets_names)Reassign a model from one dataset to another.
slice_by_energy
([energy_min, energy_max, name])Select and slice model template in energy range
stack
(other[, weights, nan_to_num])Stack background model in place.
to_dict
([full_output])Create dictionary for YAML serialisation.
unfreeze
([model_type])Restore parameters frozen status to default.
write
([overwrite])Write the map.
Attributes Documentation
- covariance#
- default_parameters = <gammapy.modeling.parameter.Parameters object>#
- 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_unique_names#
List of unique parameter names. Return formatted as par_type.par_name.
- spectral_model#
Spectral model as a
SpectralModel
object.
- tag = 'TemplateNPredModel'#
- type#
Methods Documentation
- copy(name=None, copy_data=False, **kwargs)[source]#
Copy template npred 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
TemplateNPredModel
.
- Returns:
- model
TemplateNPredModel
Copied template npred model.
- model
- cutout(position, width, mode='trim', name=None)[source]#
Cutout background model.
- Parameters:
- position
SkyCoord
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
. Default is “trim”.- namestr, optional
Name of the returned background model. Default is None.
- position
- Returns:
- cutout
TemplateNPredModel
Cutout background model.
- cutout
- evaluate()[source]#
Evaluate background model.
- Returns:
- background_map
Map
Background evaluated on the Map.
- background_map
- classmethod from_parameters(parameters, **kwargs)#
Create model from parameter list.
- Parameters:
- parameters
Parameters
Parameters for init.
- parameters
- Returns:
- model
Model
Model instance.
- model
- 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
- slice_by_energy(energy_min=None, energy_max=None, name=None)[source]#
Select and slice model template in energy range
- Parameters:
- energy_min, energy_max
Quantity
Energy bounds of the slice. Default is None.
- namestr
Name of the sliced model. Default is None.
- energy_min, energy_max
- Returns:
- model
TemplateNpredModel
Sliced Model.
- 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:
- other
TemplateNPredModel
Other background model.
- weightsfloat, optional
Weights. Default is None.
- nan_to_num: bool, optional
Non-finite values are replaced by zero if True. Default is True.
- other