AnalysisConfig#

class gammapy.analysis.AnalysisConfig[source]#

Bases: GammapyBaseConfig

Gammapy analysis configuration.

This class defines the full analysis configuration schema, organised into different sections. It can be read from or written to a YAML file using read() and write(), respectively.

Attributes:
generalGeneralConfig

General settings for output, logging, and file paths.

observationsObservationsConfig

Settings for the Observation selection including IDs, regions, and time filters.

datasetsDatasetsConfig

Settings for the Dataset Including but not limited to geometry (GeomConfig), background (BackgroundConfig), safe mask (SafeMaskConfig), and stacking.

fitFitConfig

Configuration for the Fit strategy and global fit energy range.

flux_pointsFluxPointsConfig

Configuration for the FluxPointsEstimator.

excess_mapExcessMapConfig

Configuration for the ExcessMapEstimator.

light_curveLightCurveConfig

Configuration for the LightCurveEstimator.

Examples

Read from a yaml file:

>>> from gammapy.analysis import AnalysisConfig
>>> config = AnalysisConfig.read("config.yaml")
>>> print(config.datasets.geom)

Create from scratch

>>> config = AnalysisConfig()
>>> config.observations.datastore = "$GAMMAPY_DATA/hess-dl3-dr1"
>>> config.observations.obs_cone = {"frame": "icrs", "lon": "83.633 deg", "lat": "22.014 deg", "radius": "5 deg"}
>>> print(config.observations.obs_cone.lat.deg)
22.014

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Attributes Summary

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Methods Summary

from_yaml(config_str)

Create from YAML string.

read(path)

Read from YAML file.

set_logging()

Set logging config.

to_yaml()

Convert to YAML string.

update([config])

Update config with provided settings.

write(path[, overwrite])

Write to YAML file.

Attributes Documentation

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'use_enum_values': True, 'validate_assignment': True, 'validate_default': True}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

Methods Documentation

classmethod from_yaml(config_str)[source]#

Create from YAML string.

Parameters:
config_strstr

yaml str

classmethod read(path)[source]#

Read from YAML file.

Parameters:
pathstr

input filepath

set_logging()[source]#

Set logging config.

Calls logging.basicConfig, i.e. adjusts global logging state.

to_yaml()[source]#

Convert to YAML string.

update(config=None)[source]#

Update config with provided settings.

Parameters:
configstr or AnalysisConfig object, optional

Configuration settings provided in dict() syntax. Default is None.

write(path, overwrite=False)[source]#

Write to YAML file.

Parameters:
pathpathlib.Path or str

Path to write files.

overwritebool, optional

Overwrite existing file. Default is False.

__init__(**data)#

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:

data (Any)

Return type:

None

classmethod __new__(*args, **kwargs)#