Adapt extended spectral analysis tutorial
"outputs": [],
"source": [
"%%time\n",
- "spectrum_datasets = []\n",
+ "datasets = Datasets()\n",
"\n",
"for obs in observations:\n",
" # A MapDataset is filled in this geometry\n",
" stacked.stack(dataset)\n",
"\n",
" # Extract 1D spectrum\n",
- " spectrum_dataset = dataset.to_spectrum_dataset(on_region)\n",
+ " spectrum_dataset = dataset.to_spectrum_dataset(on_region, name=f\"obs-{obs.obs_id}\")\n",
" # Compute OFF\n",
" spectrum_dataset = bkg_maker.run(spectrum_dataset, obs)\n",
" # Define safe mask\n",
" spectrum_dataset = safe_mask_maker.run(spectrum_dataset, obs)\n",
" # Append dataset to the list\n",
- " spectrum_datasets.append(spectrum_dataset)\n",
- "\n",
- "datasets = Datasets(spectrum_datasets)"
+ " datasets.append(spectrum_dataset)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "datasets.meta_table"
]
},
{
"spectral_model = PowerLawSpectralModel(\n",
" index=2, amplitude=2e-11 * u.Unit(\"cm-2 s-1 TeV-1\"), reference=1 * u.TeV\n",
")\n",
- "model = SkyModel(spectral_model=spectral_model)\n",
+ "model = SkyModel(spectral_model=spectral_model, name=\"RXJ 1713\")\n",
"\n",
- "for dataset in datasets:\n",
- " dataset.models = model"
+ "datasets.models = [model]"
]
},
{
"# Plot the result\n",
"reduced.plot_fit();"
]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
}
],
"metadata": {
