Skip to content

Commit

Permalink
Using specific mapaxis functions to iterate
Browse files Browse the repository at this point in the history
  • Loading branch information
cgalelli committed Sep 18, 2024
1 parent f426f6a commit 37fd1ea
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions gammapy/estimators/resolvedestimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, model, axis):
raise TypeError(
"Can't iterate a model with a temporal component over a time axis."
)
elif "energy" in axis.unit.physical_type:
elif axis.is_energy_axis():
self._category = "energy"
self._axis = axis
self._model = model
Expand All @@ -32,11 +32,15 @@ def run(self, datasets):
valid_intervals = []
fit_result = []
index = 0
for bin_min, bin_max in zip(self._axis.edges_min, self._axis.edges_max):
for bin_min, bin_max in self._axis.iter_by_edges:
if self._category == "time":
if not isinstance(self._axis, TimeMapAxis):
bin_min = bin_min + self._axis.reference_time
bin_max = bin_max + self._axis.reference_time

datasets_to_fit = datasets.select_time(
time_min=bin_min + self._axis.reference_time,
time_max=bin_max + self._axis.reference_time,
time_min=bin_min,
time_max=bin_max,
)

elif self._category == "energy":
Expand Down

0 comments on commit 37fd1ea

Please sign in to comment.