section on spectrum dataset maker
"To maintain good performance it is always recommended to do a cutout\n",
"of the `MapDataset` as shown above. In case you want to increase the\n",
"offset-cut later, you can also choose a larger width of the cutout\n",
- "than `2 * offset_max`."
+ "than `2 * offset_max`.\n",
+ "\n",
+ "Note that we stack the individual `MapDataset`, which are computed\n",
+ "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."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Spectrum dataset\n",
+ "\n",
+ "The spectrum datasets represent 1D spectra along an energy axis whitin a given on region. The `SpectrumDataset` contains a counts spectrum, and a background model. The `SpectrumDatasetOnOff` contains ON and OFF count spectra, background is implicitly modeled via the OFF counts spectrum. \n",
+ "\n",
+ "The `SpectrumDatasetMaker` make spectrum dataset for a single observation.\n",
+ "In that case the irfs and background are computed at a single fixed offset, which is recommend only for point-sources.\n",
+ "\n",
+ "Here is an example of data reduction loop to create `SpectrumDatasetOnOff` datasets:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# on region is given by the CircleSkyRegion previously defined\n",
+ "geom = RegionGeom.create(region=circle, axes=[energy_axis])\n",
+ "exclusion_mask_2d = exclusion_mask.sum_over_axes(keepdims=False)\n",
+ "\n",
+ "spectrum_dataset_empty = SpectrumDataset.create(\n",
+ " geom=geom, energy_axis_true=energy_axis_true\n",
+ ")\n",
+ "\n",
+ "spectrum_dataset_maker = SpectrumDatasetMaker(\n",
+ " containment_correction=False, selection=[\"counts\", \"exposure\", \"edisp\"]\n",
+ ")\n",
+ "reflected_bkg_maker = ReflectedRegionsBackgroundMaker(exclusion_mask=exclusion_mask_2d)\n",
+ "safe_mask_masker = SafeMaskMaker(methods=[\"aeff-max\"], aeff_percent=10)\n",
+ "\n",
+ "datasets = Datasets()\n",
+ "\n",
+ "for observation in observations:\n",
+ " dataset = spectrum_dataset_maker.run(\n",
+ " spectrum_dataset_empty.copy(name=f\"obs-{observation.obs_id}\"), observation\n",
+ " )\n",
+ " dataset_on_off = reflected_bkg_maker.run(dataset, observation)\n",
+ " dataset_on_off = safe_mask_masker.run(dataset_on_off, observation)\n",
+ " datasets.append(dataset_on_off)\n",
+ "print(datasets)"
]
},
{
