Modified cta_data_analysis notebook
" index=2, amplitude=1e-11 * u.Unit(\"cm-2 s-1 TeV-1\"), reference=1 * u.TeV\n",
")\n",
"\n",
- "datasets = extract.spectrum_observations.to_spectrum_datasets(model=model)\n",
+ "for dataset in extract.spectrum_observations:\n",
+ " dataset.model = model\n",
"\n",
- "fit = Fit(datasets)\n",
+ "fit = Fit(extract.spectrum_observations)\n",
"result = fit.run()\n",
"print(result)"
]
"outputs": [],
"source": [
"# Flux points are computed on stacked observation\n",
- "stacked_obs = extract.spectrum_observations.stack()\n",
+ "from gammapy.spectrum import SpectrumDatasetOnOffStacker\n",
+ "\n",
+ "stacker = SpectrumDatasetOnOffStacker(extract.spectrum_observations)\n",
+ "stacked_obs = stacker.run()\n",
+ "\n",
"print(stacked_obs)"
]
},
"source": [
"ebounds = EnergyBounds.equal_log_spacing(1, 40, 4, unit=u.TeV)\n",
"\n",
- "dataset = stacked_obs.to_spectrum_dataset()\n",
- "dataset.model = model\n",
+ "stacked_obs.model = model\n",
"\n",
"fpe = FluxPointsEstimator(datasets=[dataset], e_edges=ebounds)\n",
"flux_points = fpe.run()\n",
