add in makers notebook
" SafeMaskMaker,\n",
" SpectrumDatasetMaker,\n",
" ReflectedRegionsBackgroundMaker,\n",
+ " DatasetsMaker\n",
")\n",
"from gammapy.datasets import MapDataset, SpectrumDataset, Datasets\n",
"from gammapy.data import DataStore\n",
" skydir=(83.63, 22.01), axes=[energy_axis], width=5, binsz=0.02\n",
")\n",
"\n",
- "maker = MapDatasetMaker()\n",
+ "dataset_maker = MapDatasetMaker()\n",
"safe_mask_maker = SafeMaskMaker(\n",
" methods=[\"aeff-default\", \"offset-max\"], offset_max=\"3 deg\"\n",
")\n",
"\n",
- "stacked = MapDataset.create(geom)\n",
+ "global_dataset = MapDataset.create(geom)\n",
"\n",
"for obs in observations:\n",
- " cutout = stacked.cutout(obs.pointing_radec, width=\"6 deg\")\n",
- " dataset = maker.run(cutout, obs)\n",
+ " local_dataset = global_dataset.cutout(obs.pointing_radec, width=\"6 deg\")\n",
+ " dataset = dataset_maker.run(local_dataset, obs)\n",
" dataset = safe_mask_maker.run(dataset, obs)\n",
" dataset = fov_bkg_maker.run(dataset)\n",
- " stacked.stack(dataset)\n",
+ " global_dataset.stack(dataset)\n",
"\n",
- "print(stacked)"
+ "print(global_dataset)"
]
},
{
"per observation into a larger dataset. During the stacking the safe data\n",
"range mask (`MapDataset.mask_safe`) is applied by setting data outside to\n",
"zero, then data is added to the larger map dataset. To stack multiple\n",
- "observations, the larger dataset must be created first."
+ "observations, the larger dataset must be created first.\n",
+ "\n",
+ "The data reduction loop shown above can be done throught the `DatasetsMaker`. Its `stack_datasets` option offers the possibily to stack or not the output datasets, and the `n_jobs` option allow to use multiple processes on run:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "global_dataset = MapDataset.create(geom)\n",
+ "makers = [dataset_maker, safe_mask_maker, fov_bkg_maker] #the order matter\n",
+ "datasets_maker = DatasetsMaker(makers, stack_datasets=False, n_jobs=1)\n",
+ "datasets = datasets_maker.run(global_dataset, observations)\n",
+ "print(datasets)"
]
},
{
"autocomplete": true,
"bibliofile": "biblio.bib",
"cite_by": "apalike",
- "current_citInitial": 1.0,
+ "current_citInitial": 1,
"eqLabelWithNumbers": true,
- "eqNumInitial": 1.0,
+ "eqNumInitial": 1,
"hotkeys": {
"equation": "Ctrl-E",
"itemize": "Ctrl-I"
