Skip to content

Commit

Permalink
Merge pull request #4736 from meeseeksmachine/auto-backport-of-pr-472…
Browse files Browse the repository at this point in the history
…8-on-v1.1.x

Backport PR #4728 on branch v1.1.x (Fixed offset calculation in Background2D.to_3d)
  • Loading branch information
registerrier committed Sep 4, 2023
2 parents 80b86aa + 339acee commit 85c4a08
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion gammapy/irf/background.py
Expand Up @@ -2,6 +2,7 @@
import logging
import numpy as np
import astropy.units as u
from astropy.coordinates import angular_separation
from astropy.visualization import quantity_support
import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm
Expand Down Expand Up @@ -254,7 +255,9 @@ def to_3d(self):

axes = MapAxes([self.axes["energy"], fov_lon, fov_lat])
coords = axes.get_coord()
offset = np.sqrt(coords["fov_lat"] ** 2 + coords["fov_lon"] ** 2)
offset = angular_separation(
0 * u.rad, 0 * u.rad, coords["fov_lon"], coords["fov_lat"]
)
data = self.evaluate(offset=offset, energy=coords["energy"])

return Background3D(
Expand Down

0 comments on commit 85c4a08

Please sign in to comment.