From a8b3e03dadc507651f3330e7eb2254449c89266a Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Mon, 30 Dec 2024 11:27:57 -0500 Subject: [PATCH] BUG: Also check for inf in spaxel tool (#3368) * BUG: Also check for inf in spaxel tool when setting new Y limits * Add change log * BUG: Avoid INF in MANGA IVAR uncert --- CHANGES.rst | 2 ++ jdaviz/configs/cubeviz/plugins/parsers.py | 1 + jdaviz/configs/cubeviz/plugins/tools.py | 7 +++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index b67cb9a4e6..81b91e64fa 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -45,6 +45,8 @@ Bug Fixes Cubeviz ^^^^^^^ +- Fixed copious warnings from spaxel tool when data has INF. [#3368] + Imviz ^^^^^ diff --git a/jdaviz/configs/cubeviz/plugins/parsers.py b/jdaviz/configs/cubeviz/plugins/parsers.py index 715df19f4d..017cde1264 100644 --- a/jdaviz/configs/cubeviz/plugins/parsers.py +++ b/jdaviz/configs/cubeviz/plugins/parsers.py @@ -456,6 +456,7 @@ def _parse_spectrum1d_3d(app, file_obj, data_label=None, flux = val << u.dimensionless_unscaled # DQ flags have no unit elif attr == "uncertainty": flux = val.represent_as(StdDevUncertainty).quantity + flux[np.isinf(flux)] = np.nan # Avoid INF from IVAR conversion else: flux = val diff --git a/jdaviz/configs/cubeviz/plugins/tools.py b/jdaviz/configs/cubeviz/plugins/tools.py index d49660ba9c..ec77106dda 100644 --- a/jdaviz/configs/cubeviz/plugins/tools.py +++ b/jdaviz/configs/cubeviz/plugins/tools.py @@ -172,5 +172,8 @@ def _mouse_move_worker(self, x, y): self.viewer.start_stream() self.viewer.update_sonified_cube(x, y) - self._profile_viewer.set_limits( - y_min=np.nanmin(y_values) * 0.8, y_max=np.nanmax(y_values) * 1.2) + # Data might have inf too. + new_ymin = np.nanmin(y_values) + new_ymax = np.nanmax(y_values) + if np.all(np.isfinite([new_ymin, new_ymax])): + self._profile_viewer.set_limits(y_min=new_ymin * 0.8, y_max=new_ymax * 1.2)