added test for separation method for Hpx geom
@@ -838,6 +838,21 @@ def test_hpx_geom_region_mask():
solid_angle = (mask.data * geom.solid_angle()).sum()
assert_allclose(solid_angle, 2 * np.pi * (1 - np.cos(3 * u.deg)) * u.sr, rtol=0.01)
-
-
+def test_hpx_geom_separation():
+ geom = HpxGeom.create(skydir=(0,0), binsz=0.1, frame="galactic", nest=True)
+ position = SkyCoord(0, 0, unit="deg", frame="galactic")
+ separation = geom.separation(position)
+ assert separation.unit == "deg"
+ assert_allclose(separation.value[0], 45.000049)
+
+ # Make sure it also works for 2D maps as input
+ separation = geom.to_image().separation(position)
+ assert separation.unit == "deg"
+ assert_allclose(separation.value[0], 45.000049)
+
+ #make sure works for partial geometry
+ geom = HpxGeom.create(binsz=0.1, frame="galactic", nest=True, region="DISK(0,0,10)")
+ separation = geom.separation(position)
+ assert separation.unit == "deg"
+ assert_allclose(separation.value[0], 9.978725)
