Skip to content

Commit

Permalink
Merge pull request #3108 from adonath/change_ul_backend
Browse files Browse the repository at this point in the history
Change FluxEstimator UL backend to scipy
  • Loading branch information
adonath committed Nov 4, 2020
2 parents 701ba54 + 007e8ca commit 8ed32cd
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
17 changes: 13 additions & 4 deletions docs/tutorials/light_curve.ipynb
Expand Up @@ -152,7 +152,7 @@
" min=0.7 * u.TeV, max=10 * u.TeV, nbins=5\n",
")\n",
"conf_3d.datasets.geom.axes.energy_true = dict(\n",
" min=0.3 * u.TeV, max=20 * u.TeV, nbins=10\n",
" min=0.3 * u.TeV, max=20 * u.TeV, nbins=20\n",
")"
]
},
Expand Down Expand Up @@ -340,10 +340,10 @@
"\n",
"# Finally we define the energy binning for the spectra\n",
"conf_1d.datasets.geom.axes.energy = dict(\n",
" min=0.7 * u.TeV, max=10 * u.TeV, nbins=20\n",
" min=0.7 * u.TeV, max=10 * u.TeV, nbins=5\n",
")\n",
"conf_1d.datasets.geom.axes.energy_true = dict(\n",
" min=0.3 * u.TeV, max=20 * u.TeV, nbins=40\n",
" min=0.3 * u.TeV, max=20 * u.TeV, nbins=20\n",
")"
]
},
Expand Down Expand Up @@ -436,6 +436,15 @@
"lc_1d = lc_maker_1d.run(analysis_1d.datasets)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"lc_1d.table"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -538,7 +547,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.7.0"
}
},
"nbformat": 4,
Expand Down
12 changes: 10 additions & 2 deletions docs/tutorials/light_curve_simulation.ipynb
Expand Up @@ -300,8 +300,16 @@
"metadata": {},
"outputs": [],
"source": [
"ax = lc_1d.plot(marker=\"o\", label=\"3D\")\n",
"plt.ylim(0, 4e-11)"
"lc_1d.table[\"is_ul\"] = lc_1d.table[\"ts\"] < 1"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ax = lc_1d.plot(marker=\"o\", label=\"3D\")"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/spectrum_analysis.ipynb
Expand Up @@ -543,8 +543,8 @@
"flux_points.table[\"is_ul\"] = flux_points.table[\"ts\"] < 4\n",
"ax = flux_points.plot(\n",
" energy_power=2, flux_unit=\"erg-1 cm-2 s-1\", color=\"darkorange\"\n",
")\n",
"flux_points.to_sed_type(\"e2dnde\").plot_ts_profiles(ax=ax)"
");\n",
"flux_points.to_sed_type(\"e2dnde\").plot_ts_profiles(ax=ax);"
]
},
{
Expand Down
4 changes: 3 additions & 1 deletion gammapy/estimators/parameter.py
Expand Up @@ -218,7 +218,9 @@ def estimate_ul(self, datasets, parameter):
"""
self._setup_fit(datasets)
self._fit.optimize()
res = self._fit.confidence(parameter=parameter, sigma=self.n_sigma_ul)
res = self._fit.confidence(
parameter=parameter, sigma=self.n_sigma_ul, backend="scipy"
)
return {f"{parameter.name}_ul": res["errp"] + parameter.value}

def run(self, datasets, parameter):
Expand Down

0 comments on commit 8ed32cd

Please sign in to comment.