Skip to content

Commit

Permalink
Merge pull request gammapy#4945 from cgalelli/dtime
Browse files Browse the repository at this point in the history
Return the coordinate for the doubling time as an astropy.Time object
  • Loading branch information
AtreyeeS authored Dec 6, 2023
2 parents 336f45e + adae2d2 commit 279eaab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 6 additions & 1 deletion gammapy/estimators/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
resample_energy_edges,
)
from gammapy.maps import Map, MapAxis
from gammapy.utils.testing import requires_data
from gammapy.utils.testing import assert_time_allclose, requires_data


class TestFindPeaks:
Expand Down Expand Up @@ -191,6 +191,11 @@ def test_compute_lightcurve_doublingtime():
dtime = compute_lightcurve_doublingtime(lightcurve)
ddtime = dtime["doublingtime"].quantity
ddtime_err = dtime["doubling_err"].quantity
dcoord = dtime["doubling_coord"]

assert_allclose(ddtime, [[[245305.49]], [[481572.59]]] * u.s)
assert_allclose(ddtime_err, [[[45999.766]], [[11935.665]]] * u.s)
assert_time_allclose(
dcoord,
Time([[[55197.99960648]], [[55197.99960648]]], format="mjd", scale="utc"),
)
6 changes: 4 additions & 2 deletions gammapy/estimators/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,10 +439,12 @@ def compute_lightcurve_doublingtime(lightcurve, flux_quantity="flux"):
energies[1:],
doubling_dict["doubling"],
doubling_dict["doubling_err"],
doubling_dict["doubling_coord"],
lightcurve.geom.axes["time"].reference_time
+ doubling_dict["doubling_coord"],
doubling_dict["halving"],
doubling_dict["halving_err"],
doubling_dict["halving_coord"],
lightcurve.geom.axes["time"].reference_time
+ doubling_dict["halving_coord"],
],
names=(
"min_energy",
Expand Down

0 comments on commit 279eaab

Please sign in to comment.