From f25391e615a10de17cff54a6924c4f0167d4d3ee Mon Sep 17 00:00:00 2001 From: teutoburg Date: Fri, 22 Dec 2023 16:58:12 +0100 Subject: [PATCH] Sort corner pixels to deal with negative CDELTs --- scopesim/optics/fov_utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scopesim/optics/fov_utils.py b/scopesim/optics/fov_utils.py index 4cb42067..63dd20ad 100644 --- a/scopesim/optics/fov_utils.py +++ b/scopesim/optics/fov_utils.py @@ -308,6 +308,8 @@ def extract_area_from_imagehdu(imagehdu, fov_volume): # Round to avoid floating point madness xyp = image_wcs.wcs_world2pix(np.array([xy0s, xy1s]), 0).round(7) + # To deal with negative CDELTs + xyp.sort(axis=0) xy0p = np.max(((0, 0), np.floor(xyp[0]).astype(int)), axis=0) xy1p = np.min(((naxis1, naxis2), np.ceil(xyp[1]).astype(int)), axis=0)