From 63704af6f138daad2fed851d355340c018979dce Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Fri, 10 May 2024 13:42:31 +0100 Subject: [PATCH 1/2] Use small angular offsets when determining compass properties --- jdaviz/configs/imviz/wcs_utils.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/jdaviz/configs/imviz/wcs_utils.py b/jdaviz/configs/imviz/wcs_utils.py index be9b2b7dd8..bae667b156 100644 --- a/jdaviz/configs/imviz/wcs_utils.py +++ b/jdaviz/configs/imviz/wcs_utils.py @@ -98,18 +98,26 @@ def calc_compass(image_wcs, x, y, len_deg_e, len_deg_n): def calc_compass_radius(image_wcs, x, y, radius_px): - xe, ye = add_offset_xy(image_wcs, x, y, 1.0, 0.0) - xn, yn = add_offset_xy(image_wcs, x, y, 0.0, 1.0) + + # Define an angular length we can use to determine the pixel scale + # along east and north - we want to make sure we use a small length so + # that the offset points still fall inside the image in case they have + # a bounding box set. + + delta = 0.1 / 3600 # 0.1 arcsec + + xe, ye = add_offset_xy(image_wcs, x, y, delta, 0.0) + xn, yn = add_offset_xy(image_wcs, x, y, 0.0, delta) # now calculate the length in pixels of those arcs # (planar geometry is good enough here) - px_per_deg_e = math.sqrt(math.fabs(ye - y) ** 2 + math.fabs(xe - x) ** 2) - px_per_deg_n = math.sqrt(math.fabs(yn - y) ** 2 + math.fabs(xn - x) ** 2) + px_per_delta_e = math.sqrt(math.fabs(ye - y) ** 2 + math.fabs(xe - x) ** 2) + px_per_delta_n = math.sqrt(math.fabs(yn - y) ** 2 + math.fabs(xn - x) ** 2) # now calculate the arm length in degrees for each arm # (this produces same-length arms) - len_deg_e = radius_px / px_per_deg_e - len_deg_n = radius_px / px_per_deg_n + len_deg_e = radius_px / px_per_delta_e * delta + len_deg_n = radius_px / px_per_delta_n * delta return calc_compass(image_wcs, x, y, len_deg_e, len_deg_n) From afef68a8870c64ab78cee750a1c49ac7ac3e23fe Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Fri, 10 May 2024 18:16:51 -0400 Subject: [PATCH 2/2] TST: Update test results --- jdaviz/configs/imviz/tests/test_wcs_utils.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/jdaviz/configs/imviz/tests/test_wcs_utils.py b/jdaviz/configs/imviz/tests/test_wcs_utils.py index 5e0b05d324..109b96be96 100644 --- a/jdaviz/configs/imviz/tests/test_wcs_utils.py +++ b/jdaviz/configs/imviz/tests/test_wcs_utils.py @@ -24,9 +24,9 @@ def test_simple_fits_wcs(): w = WCS() result = wcs_utils.get_compass_info(w, (100, 100), r_fac=0.25) assert_allclose(result[:-1], (50, 50, - 50, 73.57533083557558, - 73.57809873817803, 47.53791379556649, - 0, 95.96136875946559)) + 50, 73.573199, + 73.573199, 47.538975, + 0, 95.960048)) assert result[-1] # https://learn.astropy.org/tutorials/celestial_coords1.html @@ -44,9 +44,9 @@ def test_simple_fits_wcs(): 'NAXIS2': 1024}) result = wcs_utils.get_compass_info(w, (1024, 1024), r_fac=0.25) assert_allclose(result[:-1], (512.0, 512.0, - 512.2415718047745, 767.9895741540789, - 255.98982015749573, 512.240013842715, - 0.054068767449065434, -90.00035302773995)) + 512.2416, 768.0007, + 256.0009, 512.24, + 0.05406877, -90.00035)) assert not result[-1] @@ -103,9 +103,9 @@ def test_simple_gwcs(): result = wcs_utils.get_compass_info(w, (1024, 2048), r_fac=0.25) assert_allclose(result[:-1], (1024.0, 512.0, - 1131.0265005852038, 279.446189124443, - 1262.0057201165127, 606.2863901330095, - 155.2870478938214, -86.89813081941797)) + 1131.026544, 279.446094, + 1262.004542, 606.285924, + 155.287048, -86.898131)) assert not result[-1]