Skip to content

Commit

Permalink
Merge pull request #4728 from cgalelli/bugfix_2dto3d
Browse files Browse the repository at this point in the history
Fixed offset calculation in Background2D.to_3d
  • Loading branch information
QRemy committed Aug 29, 2023
2 parents fe8e454 + d4cfb4d commit c71cb47
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 c71cb47

Please sign in to comment.