From 471ad101dc76f154f84d93730af2838ef1cd3b41 Mon Sep 17 00:00:00 2001 From: teutoburg Date: Wed, 13 Sep 2023 19:14:11 +0200 Subject: [PATCH] Attempt to fix now-broken tests... --- .../mocks/py_objects/imagehdu_objects.py | 10 ++++++---- .../tests_optics/test_ImagePlaneUtils.py | 20 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/scopesim/tests/mocks/py_objects/imagehdu_objects.py b/scopesim/tests/mocks/py_objects/imagehdu_objects.py index 188104fb..d8576b5e 100644 --- a/scopesim/tests/mocks/py_objects/imagehdu_objects.py +++ b/scopesim/tests/mocks/py_objects/imagehdu_objects.py @@ -7,14 +7,15 @@ def _image_hdu_square(wcs_suffix=""): width = 100 the_wcs = wcs.WCS(naxis=2, key=wcs_suffix) if wcs_suffix == "": - the_wcs.wcs.ctype = ["RA---TAN", "DEC--TAN"] + # the_wcs.wcs.ctype = ["RA---TAN", "DEC--TAN"] + the_wcs.wcs.ctype = ["LINEAR", "LINEAR"] the_wcs.wcs.cunit = ["arcsec", "arcsec"] elif wcs_suffix == "D": the_wcs.wcs.ctype = ["LINEAR", "LINEAR"] the_wcs.wcs.cunit = ["mm", "mm"] the_wcs.wcs.cdelt = [1, 1] the_wcs.wcs.crval = [0, 0] - the_wcs.wcs.crpix = [width // 2, width // 2] + the_wcs.wcs.crpix = [(width - 1) / 2 + 1, (width - 1) / 2 + 1] # theta = 24 # ca, sa = np.cos(np.deg2rad(theta)), np.sin(np.deg2rad(theta)) @@ -33,14 +34,15 @@ def _image_hdu_rect(wcs_suffix=""): ca, sa = np.cos(np.deg2rad(angle)), np.sin(np.deg2rad(angle)) the_wcs = wcs.WCS(naxis=2, key=wcs_suffix) if wcs_suffix == "": - the_wcs.wcs.ctype = ["RA---TAN", "DEC--TAN"] + # the_wcs.wcs.ctype = ["RA---TAN", "DEC--TAN"] + the_wcs.wcs.ctype = ["LINEAR", "LINEAR"] the_wcs.wcs.cunit = ["arcsec", "arcsec"] elif wcs_suffix == "D": the_wcs.wcs.ctype = ["LINEAR", "LINEAR"] the_wcs.wcs.cunit = ["mm", "mm"] the_wcs.wcs.cdelt = [1, 1] the_wcs.wcs.crval = [0, 0] - the_wcs.wcs.crpix = [width // 2, height // 2] + the_wcs.wcs.crpix = [(width - 1) / 2 + 1, (height - 1) / 2 + 1] the_wcs.wcs.pc = [[ca, sa], [-sa, ca]] image = np.random.random(size=(height, width)) diff --git a/scopesim/tests/tests_optics/test_ImagePlaneUtils.py b/scopesim/tests/tests_optics/test_ImagePlaneUtils.py index d7131bcd..013c5fa8 100644 --- a/scopesim/tests/tests_optics/test_ImagePlaneUtils.py +++ b/scopesim/tests/tests_optics/test_ImagePlaneUtils.py @@ -42,14 +42,14 @@ def big_small_hdus(self, big_wh=(20, 10), big_offsets=(0, 0), w, h = np.array(big_wh) // 2 x = np.array([-w, -w, w, w]) + big_offsets[0] y = np.array([h, -h, -h, h]) + big_offsets[1] - big = imp_utils.header_from_list_of_xy(x, y, pixel_scale) + big = imp_utils.header_from_list_of_xy(x, y, pixel_scale, "X") im = np.ones([big["NAXIS2"], big["NAXIS1"]]) big = fits.ImageHDU(header=big, data=im) w, h = np.array(small_wh) // 2 x = np.array([-w, -w, w, w]) + small_offsets[0] y = np.array([h, -h, -h, h]) + small_offsets[1] - small = imp_utils.header_from_list_of_xy(x, y, pixel_scale) + small = imp_utils.header_from_list_of_xy(x, y, pixel_scale, "X") im = np.ones([small["NAXIS2"], small["NAXIS1"]]) small = fits.ImageHDU(header=small, data=im) @@ -60,7 +60,7 @@ def test_smaller_hdu_is_fully_in_larger_hdu(self): big, small = self.big_small_hdus() big_sum, small_sum = np.sum(big.data), np.sum(small.data) - new = imp_utils.add_imagehdu_to_imagehdu(small, big) + new = imp_utils.add_imagehdu_to_imagehdu(small, big, wcs_suffix="X") if PLOTS: plt.imshow(new.data, origin="lower") @@ -76,7 +76,7 @@ def test_smaller_cube_is_fully_inside_larger_cube(self): big_sum, small_sum = np.sum(big.data), np.sum(small.data) - new = imp_utils.add_imagehdu_to_imagehdu(small, big) + new = imp_utils.add_imagehdu_to_imagehdu(small, big, wcs_suffix="X") if PLOTS: plt.imshow(new.data[1, :, :], origin="lower") @@ -89,7 +89,7 @@ def test_larger_hdu_encompases_smaller_hdu(self): big, small = self.big_small_hdus() big_sum, small_sum = np.sum(big.data), np.sum(small.data) - new = imp_utils.add_imagehdu_to_imagehdu(big, small) + new = imp_utils.add_imagehdu_to_imagehdu(big, small, wcs_suffix="X") if PLOTS: plt.imshow(new.data, origin="lower") @@ -102,7 +102,7 @@ def test_smaller_hdu_is_partially_in_larger_hdu(self): big, small = self.big_small_hdus(small_wh=(20, 10), small_offsets=(10, 5)) big_sum, small_sum = np.sum(big.data), np.sum(small.data) - new = imp_utils.add_imagehdu_to_imagehdu(small, big) + new = imp_utils.add_imagehdu_to_imagehdu(small, big, wcs_suffix="X") if PLOTS: plt.imshow(new.data, origin="lower") @@ -115,7 +115,7 @@ def test_larger_hdu_is_partially_in_smaller_hdu(self): big, small = self.big_small_hdus(small_wh=(20, 10), small_offsets=(10, 5)) big_sum, small_sum = np.sum(big.data), np.sum(small.data) - new = imp_utils.add_imagehdu_to_imagehdu(big, small) + new = imp_utils.add_imagehdu_to_imagehdu(big, small, wcs_suffix="X") if PLOTS: @@ -131,7 +131,7 @@ def test_larger_cube_is_partially_in_smaller_cube(self): small.data = small.data[None, :, :] * np.ones(3)[:, None, None] big_sum, small_sum = np.sum(big.data), np.sum(small.data) - new = imp_utils.add_imagehdu_to_imagehdu(big, small) + new = imp_utils.add_imagehdu_to_imagehdu(big, small, wcs_suffix="X") if PLOTS: @@ -145,7 +145,7 @@ def test_larger_hdu_is_fully_outside_smaller_hdu(self): big, small = self.big_small_hdus(small_offsets=(15, 0)) big_sum, small_sum = np.sum(big.data), np.sum(small.data) - new = imp_utils.add_imagehdu_to_imagehdu(big, small) + new = imp_utils.add_imagehdu_to_imagehdu(big, small, wcs_suffix="X") if PLOTS: plt.imshow(new.data, origin="lower") @@ -333,5 +333,3 @@ def test_returns_expected_origin_fraction(self, x, y, frac): # x, y = np.array([1.1, 2.9]), np.array([0.0, 0.5]) # xs, ys, fracs = imp_utils.sub_pixel_fractions(x, y) # print(xs) - -