Skip to content

Commit

Permalink
Attempt to fix now-broken tests...
Browse files Browse the repository at this point in the history
  • Loading branch information
teutoburg committed Sep 13, 2023
1 parent a52b9fc commit 471ad10
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
10 changes: 6 additions & 4 deletions scopesim/tests/mocks/py_objects/imagehdu_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))
Expand Down
20 changes: 9 additions & 11 deletions scopesim/tests/tests_optics/test_ImagePlaneUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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:

Expand All @@ -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:

Expand All @@ -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")
Expand Down Expand Up @@ -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)


0 comments on commit 471ad10

Please sign in to comment.