split_dataset#
- gammapy.datasets.split_dataset(dataset, width, margin, split_template_models=True)[source]#
Split dataset in multiple non-overlapping analysis regions.
- Parameters:
- dataset
Dataset Dataset to split.
- width
Angle Angular size of each sub-region.
- margin
Angle Angular size to be added to the
width. The margin should be defined such as sources outside the region of interest that contributes inside are well-defined. The mask_fit in the margin region is False and unchanged elsewhere.- split_template_modelsbool, optional
Apply cutout to template models or not. Default is True.
- dataset
- Returns:
- datasets
Datasets Split datasets.
- datasets
Examples
>>> from gammapy.datasets import MapDataset >>> from gammapy.datasets.utils import split_dataset >>> from gammapy.modeling.models import ( ... GaussianSpatialModel, ... PowerLawSpectralModel, ... SkyModel, ... ) >>> import astropy.units as u >>> dataset = MapDataset.read("$GAMMAPY_DATA/cta-1dc-gc/cta-1dc-gc.fits.gz") >>> # Split the dataset >>> width = 4 * u.deg >>> margin = 1 * u.deg >>> split_datasets = split_dataset( ... dataset, width, margin, split_template_models=False ... ) >>> # Apply a model and split the dataset >>> spatial_model = GaussianSpatialModel() >>> spectral_model = PowerLawSpectralModel() >>> sky_model = SkyModel( ... spatial_model=spatial_model, ... spectral_model=spectral_model, ... name="test-model", ... ) >>> dataset.models = [sky_model] >>> split_datasets = split_dataset( ... dataset, width=width, margin=margin, split_template_models=True ... )