asgardpy.base.reduction module¶
Classes containing the Dataset Reduction config parameters for the high-level interface and also various functions to support in Dataset Reduction and creating of the appropriate DL4 dataset.
- pydantic model asgardpy.base.reduction.BackgroundConfig[source]¶
Bases:
BaseConfigConfig section for getting main information for creating a Background Reduction Makers object.
- Fields:
-
field exclusion:
ExclusionRegionsConfig= ExclusionRegionsConfig(target_source=True, regions=[], exclusion_file=PosixPath('.'))¶
-
field method:
BackgroundMethodEnum= BackgroundMethodEnum.reflected¶
-
field region_finder_method:
BackgroundRegionFinderMethodEnum= BackgroundRegionFinderMethodEnum.wobble¶
- pydantic model asgardpy.base.reduction.ObservationsConfig[source]¶
Bases:
BaseConfigConfig section for getting main information for creating an Observations object.
Currently event types are considered only for HAWC data where events are classified as portion of arrays being used for recording them.
- Fields:
-
field obs_cone:
SkyPositionConfig= SkyPositionConfig(frame='icrs', lon=<Quantity 0. deg>, lat=<Quantity 0. deg>, radius=<Quantity 0. deg>)¶
- pydantic model asgardpy.base.reduction.SafeMaskConfig[source]¶
Bases:
BaseConfigConfig section for getting main information for creating a Safe Mask Makers object.
- asgardpy.base.reduction.generate_dl4_dataset(tag, observations, dataset_reference, dataset_maker, bkg_maker, safe_maker, n_jobs, parallel_backend)[source]¶
From the given Observations, Dataset reference and various Makers, use the multiprocessing method with DatasetsMaker, create the appropriate DL4 Dataset for {1, 3}D type of DL3 data.
- Parameters:
tag (str) – Determining either the {1, 3}d Dataset type.
observations (gammapy.data.Observations) – Selected list of Observation object
dataset_reference (gammapy.dataset.SpectrumDataset or) – gammapy.dataset.MapDataset Appropriate Dataset reference for {1, 3}D type of DL4 Datasets.
dataset_maker (gammapy.makers.MapDatasetMaker or) – gammapy.makers.SpectrumDatasetMaker Appropriate gammapy object to bin the Observations Map data or 1D spectrum extraction data for {1, 3}D type of DL4 Datasets.
bkg_maker (gammapy.makers.background()) – Appropriate gammapy Background Maker objects as per the config.
safe_maker (gammapy.makers.SafeMaskMaker) – Gammapy Dataset Reduction Maker, for safe data range mask.
n_jobs (int) – Number of parallel processing jobs for gammapy.makers.DatasetsMaker
parallel_backend (str) – Name of the parallel backend used for the parallel processing. By default “multiprocessing” is used for now.
- Returns:
datasets – A Datasets object containing appropriate gammapy.dataset.MapDataset or gammapy.dataset.SpectrumDataset for {1, 3}D type of DL3 dataset.
- Return type:
gammapy.datasets.Datasets
- asgardpy.base.reduction.get_bkg_maker(bkg_config, exclusion_mask)[source]¶
Generate Background reduction maker by including a boolean exclusion mask, with methods to find background normalization using the information provided in the config for using specific methods.
- Parameters:
bkg_config (asgardpy.base.reduction.BackgroundConfig) – Config information for evaluating a particular Background normalization maker for dataset reduction.
exclusion_mask (gammapy.maps.WcsNDMap) – Boolean region mask for the exclusion regions
- Returns:
bkg_maker – Appropriate gammapy Background Maker objects as per the config.
- Return type:
gammapy.makers.background()
- asgardpy.base.reduction.get_dataset_maker(tag, dataset_config)[source]¶
Create a Dataset Maker object to support creating an appropriate {1, 3}D type of DL4 Dataset along with other reduction makers.
- Parameters:
tag (str) – Determining either the {1, 3}d Dataset type.
dataset_config (asgardpy.data.dataset_1d.Dataset1DInfoConfig or) – asgardpy.data.dataset_3d.Dataset3DInfoConfig Config information on creating appropriate {1, 3}d DL4 dataset type.
- Returns:
dataset_maker – gammapy.makers.MapDatasetMaker Appropriate Dataset Maker for {1, 3}D type of DL4 Datasets.
- Return type:
gammapy.makers.SpectrumDatasetMaker or
- asgardpy.base.reduction.get_dataset_reference(tag, geom, geom_config, name=None)[source]¶
Create a base Dataset object to fill up with the appropriate {1, 3}D type of DL3 data to generate the reduced DL4 dataset, using the given base geometry and relevant axes details.
- Parameters:
tag (str) – Determining either the {1, 3}d Dataset type.
geom (‘gammapy.maps.RegionGeom’ or gammapy.maps.WcsGeom) – Appropriate Base geometry objects for {1, 3}D type of DL4 Datasets.
geom_config (asgardpy.base.geom.GeomConfig) – Config information on creating the Base Geometry of the DL4 dataset.
name (str) – Name for the dataset.
- Returns:
dataset_reference – gammapy.dataset.MapDataset Appropriate Dataset reference for {1, 3}D type of DL4 Datasets.
- Return type:
gammapy.dataset.SpectrumDataset or
- asgardpy.base.reduction.get_exclusion_region_mask(exclusion_params, excluded_geom, exclusion_regions, config_target, geom_config, log)[source]¶
Generate from a given parameters, base geometry for exclusion mask, list of exclusion regions, config information on the target source and the base geometry for the exclusion mask, a background exclusion region mask. # Create exclusion mask either by given regions, catalog or from a file.
- Parameters:
exclusion_params (asgardpy.base.reduction.ExclusionRegionsConfig) – Config information on the list of Exclusion Regions
excluded_geom (‘gammapy.maps.RegionGeom’ or gammapy.maps.WcsGeom) – Appropriate Base geometry objects for exclusion regions for {1, 3}D type of DL4 Datasets.
exclusion_regions (list of gammapy.maps.WcsMap) – Existing list of excluded regions.
config_target (asgardpy.config.generator.AsgardpyConfig.target) – Config information on the target source
geom_config (asgardpy.base.geom.GeomConfig) – Config information on creating the Base Geometry of the DL4 dataset.
log (logging()) – Common log file.
- Returns:
exclusion_mask – Boolean region mask for the exclusion regions
- Return type:
gammapy.maps.WcsNDMap
- asgardpy.base.reduction.get_filtered_observations(dl3_path, obs_config, log, dl3_index_files=None, event_type=None)[source]¶
From the path of the DL3 index files, create gammapy Observations object and apply any observation filters provided in the obs_config object to return the selected Observations object.
- Parameters:
dl3_path (pathlib.Path) – Path to the DL3 index files, to create gammapy.data.DataStore object.
obs_config (asgardpy.base.reduction.ObservationsConfig) – Config information for creating the gammapy.data.Observations object.
log (logging()) – Common log file.
dl3_index_files (list) – List of HDU and Observation index files (in that order) to create the DataStore object with. Currently being used only for HAWC data. Default is an empty list.
event_type (str or int) – Event type, currently being used only for HAWC data as defined in the paper https://iopscience.iop.org/article/10.3847/1538-4357/ab2f7d. Default is None.
- Returns:
observations – Selected list of Observation object
- Return type:
gammapy.data.Observations
- asgardpy.base.reduction.get_safe_mask_maker(safe_config)[source]¶
Generate Safe mask reduction maker as per the given config information.
- Parameters:
safe_config (asgardpy.base.reduction.SafeMaskConfig) – Config information to create gammapy.makers.SafeMaskMaker object.
- Returns:
safe_maker – Gammapy Dataset Reduction Maker, for safe data range mask.
- Return type:
gammapy.makers.SafeMaskMaker