From ba5cc7efe644d60b16207ca60c88b5c35778477b Mon Sep 17 00:00:00 2001 From: Duy Nguyen Date: Tue, 7 Feb 2023 17:00:08 -0500 Subject: [PATCH 1/5] Fix typo and add preventative test --- jdaviz/configs/mosviz/helper.py | 2 +- jdaviz/configs/mosviz/tests/test_parsers.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/jdaviz/configs/mosviz/helper.py b/jdaviz/configs/mosviz/helper.py index 593c2619cb..ad286e1d98 100644 --- a/jdaviz/configs/mosviz/helper.py +++ b/jdaviz/configs/mosviz/helper.py @@ -334,7 +334,7 @@ def _zoom_to_object_params(self, msg): return None, None ra = table_data["R.A."][msg.selected_index] - dec = table_data["R.A."][msg.selected_index] + dec = table_data["Dec."][msg.selected_index] if (ra == FALLBACK_NAME) or (dec == FALLBACK_NAME): return None, None diff --git a/jdaviz/configs/mosviz/tests/test_parsers.py b/jdaviz/configs/mosviz/tests/test_parsers.py index aba3452d99..ff6aa7e560 100644 --- a/jdaviz/configs/mosviz/tests/test_parsers.py +++ b/jdaviz/configs/mosviz/tests/test_parsers.py @@ -1,6 +1,8 @@ from zipfile import ZipFile import pytest +from astropy import units as u +from astropy.tests.helper import assert_quantity_allclose from astropy.utils.data import download_file from jdaviz.utils import PRIHDR_KEY, COMMENTCARD_KEY @@ -142,6 +144,14 @@ def test_niriss_parser(mosviz_helper, tmp_path): assert COMMENTCARD_KEY not in dc_1.meta assert dc_1.meta['bunit_data'] == 'MJy/sr' # ASDF metadata + # We should be centered on the coordinates of the first data point + imview = mosviz_helper.app.get_viewer(mosviz_helper._default_image_viewer_reference_name) + x_pixcenter = (imview.state.x_max + imview.state.x_min)/2.0 + y_pixcenter = (imview.state.y_max + imview.state.y_min)/2.0 + viewer_center_coord = imview.layers[0].layer.coords.pixel_to_world(x_pixcenter, y_pixcenter) + assert_quantity_allclose(viewer_center_coord.ra, dc_tab["R.A."][0]*u.deg) + assert_quantity_allclose(viewer_center_coord.dec, dc_tab["Dec."][0]*u.deg) + # Test all the spectra exist for dispersion in ('R', 'C'): for sourceid in (243, 249): From 40405485fc156095a10c011f23585cb80deacf2a Mon Sep 17 00:00:00 2001 From: Duy Nguyen Date: Tue, 7 Feb 2023 17:03:26 -0500 Subject: [PATCH 2/5] Changelog --- CHANGES.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.rst b/CHANGES.rst index be60611660..5f59f51fa2 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -83,6 +83,7 @@ Imviz Mosviz ^^^^^^ +- Fix typo where zoom Dec retrieval used RA instead. [#1992] Specviz ^^^^^^^ From b639af3e639bafcc00fdcb335ca70744f919e03e Mon Sep 17 00:00:00 2001 From: Duy Nguyen Date: Tue, 7 Feb 2023 17:10:35 -0500 Subject: [PATCH 3/5] Test degrees directly Co-authored-by: P. L. Lim <2090236+pllim@users.noreply.github.com> --- jdaviz/configs/mosviz/tests/test_parsers.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/jdaviz/configs/mosviz/tests/test_parsers.py b/jdaviz/configs/mosviz/tests/test_parsers.py index ff6aa7e560..89f217935c 100644 --- a/jdaviz/configs/mosviz/tests/test_parsers.py +++ b/jdaviz/configs/mosviz/tests/test_parsers.py @@ -1,7 +1,6 @@ from zipfile import ZipFile import pytest -from astropy import units as u from astropy.tests.helper import assert_quantity_allclose from astropy.utils.data import download_file @@ -149,8 +148,8 @@ def test_niriss_parser(mosviz_helper, tmp_path): x_pixcenter = (imview.state.x_max + imview.state.x_min)/2.0 y_pixcenter = (imview.state.y_max + imview.state.y_min)/2.0 viewer_center_coord = imview.layers[0].layer.coords.pixel_to_world(x_pixcenter, y_pixcenter) - assert_quantity_allclose(viewer_center_coord.ra, dc_tab["R.A."][0]*u.deg) - assert_quantity_allclose(viewer_center_coord.dec, dc_tab["Dec."][0]*u.deg) + assert_quantity_allclose(viewer_center_coord.ra.deg, dc_tab["R.A."][0]) + assert_quantity_allclose(viewer_center_coord.dec.deg, dc_tab["Dec."][0]) # Test all the spectra exist for dispersion in ('R', 'C'): From 4f4ba2c56630b953b99bcb06bfa41234c41b0f16 Mon Sep 17 00:00:00 2001 From: Duy Tuong Nguyen Date: Tue, 7 Feb 2023 17:19:11 -0500 Subject: [PATCH 4/5] Swap quantity test for value test Co-authored-by: P. L. Lim <2090236+pllim@users.noreply.github.com> --- jdaviz/configs/mosviz/tests/test_parsers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdaviz/configs/mosviz/tests/test_parsers.py b/jdaviz/configs/mosviz/tests/test_parsers.py index 89f217935c..ae7314b110 100644 --- a/jdaviz/configs/mosviz/tests/test_parsers.py +++ b/jdaviz/configs/mosviz/tests/test_parsers.py @@ -148,8 +148,8 @@ def test_niriss_parser(mosviz_helper, tmp_path): x_pixcenter = (imview.state.x_max + imview.state.x_min)/2.0 y_pixcenter = (imview.state.y_max + imview.state.y_min)/2.0 viewer_center_coord = imview.layers[0].layer.coords.pixel_to_world(x_pixcenter, y_pixcenter) - assert_quantity_allclose(viewer_center_coord.ra.deg, dc_tab["R.A."][0]) - assert_quantity_allclose(viewer_center_coord.dec.deg, dc_tab["Dec."][0]) + assert_allclose(viewer_center_coord.ra.deg, dc_tab["R.A."][0]) + assert_allclose(viewer_center_coord.dec.deg, dc_tab["Dec."][0]) # Test all the spectra exist for dispersion in ('R', 'C'): From 10fbec30840bb883b95b685d07d668257c3a95be Mon Sep 17 00:00:00 2001 From: Duy Tuong Nguyen Date: Tue, 7 Feb 2023 17:19:37 -0500 Subject: [PATCH 5/5] Change missing import Co-authored-by: P. L. Lim <2090236+pllim@users.noreply.github.com> --- jdaviz/configs/mosviz/tests/test_parsers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdaviz/configs/mosviz/tests/test_parsers.py b/jdaviz/configs/mosviz/tests/test_parsers.py index ae7314b110..5e690e4d79 100644 --- a/jdaviz/configs/mosviz/tests/test_parsers.py +++ b/jdaviz/configs/mosviz/tests/test_parsers.py @@ -1,7 +1,7 @@ from zipfile import ZipFile import pytest -from astropy.tests.helper import assert_quantity_allclose +from numpy.testing import assert_allclose from astropy.utils.data import download_file from jdaviz.utils import PRIHDR_KEY, COMMENTCARD_KEY