Skip to content

Commit

Permalink
use sky_to_fov also for RADEC FoVAlignment
Browse files Browse the repository at this point in the history
  • Loading branch information
SimoneMender authored and QRemy committed Jul 17, 2024
1 parent dbed1a1 commit 122e26c
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions gammapy/makers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,33 @@ def make_map_background_irf(
)
coords["energy"] = geom.axes["energy"].edges.reshape((-1, 1, 1))

# for backwards compatibility, obstime should be required
if obstime is None:
warnings.warn(
"Future versions of gammapy will require the obstime keyword for this function",
DeprecationWarning,
)
obstime = pointing.obstime

pointing_altaz = pointing.get_altaz(obstime)
altaz_coord = sky_coord.transform_to(pointing_altaz.frame)

# Compute FOV coordinates of map relative to pointing
fov_lon, fov_lat = sky_to_fov(
altaz_coord.az, altaz_coord.alt, pointing_altaz.az, pointing_altaz.alt
)
elif bkg.fov_alignment == FoVAlignment.RADEC:
fov_lon, fov_lat = sky_to_fov(
sky_coord.ra, sky_coord.dec, pointing_icrs.ra, pointing_icrs.dec
)
else:
raise ValueError(
f"Unsupported background coordinate system: {bkg.fov_alignment!r}"
)

coords["fov_lon"] = fov_lon
coords["fov_lat"] = fov_lat

bkg_de = bkg.integrate_log_log(**coords, axis_name="energy")
data = (bkg_de * d_omega * ontime).to_value("")

Expand Down

0 comments on commit 122e26c

Please sign in to comment.