Adapt mask maps tutorial
"\n",
"One might also exclude some specific part of the sky for the fit. For instance, if one wants not to model a specific source in the region of interest, or if one want to reduce the region of interest in the dataset `Geom`.\n",
"\n",
- "In the following we restrict the fit region to a square around the Crab nebula. Here we use the healper function `gammapy.utils.regions.mak_region` that creates region objects from ds9-like strings.\n",
+ "In the following we restrict the fit region to a square around the Crab nebula. Here we use the `regions` API to create a region from a ds9-like strings.\n",
"\n",
"Note: the dataset geometry is aligned on the galactic frame, we use the same frame to define the box to ensure a correct alignment."
]
"metadata": {},
"outputs": [],
"source": [
- "box_region = Regions.parse(\"galactic;box(184.55, -5.78, 3.0, 3.0)\", format=\"ds9\")"
+ "regions = Regions.parse(\"galactic;box(184.55, -5.78, 3.0, 3.0)\", format=\"ds9\")"
]
},
{
"metadata": {},
"outputs": [],
"source": [
- "mask_map = dataset.counts.geom.region_mask(box_region)"
+ "mask_map = dataset.counts.geom.region_mask(regions)"
]
},
{
"metadata": {},
"outputs": [],
"source": [
- "_ = dataset.mask_fit.plot_grid(ncols=5, vmin=0, vmax=1)"
+ "_ = dataset.mask_fit.plot_grid(ncols=5, vmin=0, vmax=1, figsize=(14, 3))"
]
},
{
"outputs": [],
"source": [
"inside_geom = geom.contains(fgl.positions)\n",
- "idx = np.where(inside_geom)[0]"
+ "positions = fgl.positions[inside_geom]"
]
},
{
"outputs": [],
"source": [
"exclusion_radius = Angle(\"0.3 deg\")\n",
- "regions = [CircleSkyRegion(fgl[i].position, exclusion_radius) for i in idx]"
+ "regions = [CircleSkyRegion(position, exclusion_radius) for position in positions]"
]
},
{
"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"
