Fix tutorials/analysis_3d.ipynb on Python 2
"metadata": {},
"outputs": [],
"source": [
- "excess = Map.from_geom(geom.to_image())\n",
- "excess.data = counts.data - background.data\n",
+ "excess = counts - background\n",
"excess.smooth(5).plot(stretch=\"sqrt\", add_cbar=True);"
]
},
"metadata": {},
"outputs": [],
"source": [
- "combination = Map.from_geom(geom.to_image())\n",
- "combination.data = diffuse.data * exposure.data\n",
+ "combination = diffuse * exposure\n",
+ "combination.unit = \"\"\n",
"combination.smooth(5).plot(stretch=\"sqrt\", add_cbar=True);"
]
},
"metadata": {},
"outputs": [],
"source": [
- "excess2 = Map.from_geom(geom.to_image())\n",
- "excess2.data = counts.data - background.data - combination.data\n",
+ "excess2 = counts - background - combination\n",
"\n",
"fig, axs = plt.subplots(1, 2, figsize=(15, 5))\n",
"\n",
"metadata": {},
"outputs": [],
"source": [
- "residual = Map.from_geom(cmaps[\"counts\"].geom)\n",
- "residual.data = cmaps[\"counts\"].data - npred.data"
+ "residual = cmaps[\"counts\"] - npred"
]
},
{
"outputs": [],
"source": [
"# Checking normalization value (the closer to 1 the better)\n",
- "print(\n",
- " \"First model (SkyDiffuseCube): \", result_combined.model.model1.parameters\n",
- ")\n",
- "print(\"Second model (SkyModel): \", result_combined.model.model2.parameters)"
+ "print(\"Model 1 (SkyDiffuseCube): \", result_combined.model.model1.parameters)\n",
+ "print(\"Model 2 (SkyModel): \", result_combined.model.model2.parameters)"
]
},
{
"metadata": {},
"outputs": [],
"source": [
- "npred_combined = combined_fit.evaluator.compute_npred()\n",
- "\n",
- "residual2 = Map.from_geom(cmaps[\"counts\"].geom)\n",
- "residual2.data = cmaps[\"counts\"].data - npred_combined.data"
+ "residual2 = cmaps[\"counts\"] - combined_fit.evaluator.compute_npred()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "(the complete tutorial notebook of this analysis is available to be downloaded in [GAMMAPY-EXTRA](https://github.com/gammapy/gammapy-extra) repository at https://github.com/gammapy/gammapy-extra/blob/master/analyses/cta_1dc_gc_3d.ipynb)"
+ "The complete tutorial notebook of this analysis is available to be downloaded in [GAMMAPY-EXTRA](https://github.com/gammapy/gammapy-extra) repository at https://github.com/gammapy/gammapy-extra/blob/master/analyses/cta_1dc_gc_3d.ipynb)."
]
},
{
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.6.6"
+ "version": "3.7.0"
}
},
"nbformat": 4,
