From 27bad6c4ad2c3b5945afa0e911938723505aca3c Mon Sep 17 00:00:00 2001 From: Jesse Averbukh Date: Tue, 31 Aug 2021 16:56:01 -0400 Subject: [PATCH 1/3] Mosviz hotfix --- jdaviz/configs/mosviz/helper.py | 8 +++----- notebooks/MosvizNIRISSExample.ipynb | 8 ++++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/jdaviz/configs/mosviz/helper.py b/jdaviz/configs/mosviz/helper.py index 213abf648b..5911f0a3f9 100644 --- a/jdaviz/configs/mosviz/helper.py +++ b/jdaviz/configs/mosviz/helper.py @@ -254,6 +254,9 @@ def load_data(self, spectra_1d=None, spectra_2d=None, images=None, msg = SnackbarMessage(msg, color='warning', sender=self) self.app.hub.broadcast(msg) + # Load the first object into the viewers automatically + self.app.get_viewer("table-viewer").figure_widget.highlighted = 0 + def load_spectra(self, spectra_1d, spectra_2d): """ Load 1D and 2D spectra using lists or strings to represent each. @@ -287,9 +290,6 @@ def load_spectra_from_directory(self, directory, instrument): """ self.load_data(directory=directory, instrument=instrument) - # Load the first object into the viewers automatically - self.app.get_viewer("table-viewer").figure_widget.highlighted = 0 - def load_metadata(self, data_obj): """ Load and parse a set of FITS objects to extract any relevant metadata. @@ -340,8 +340,6 @@ def load_2d_spectra(self, data_obj, data_labels=None): def load_niriss_data(self, data_obj, data_labels=None): super().load_data(data_obj, parser_reference="mosviz-niriss-parser") - # Load the first object into the viewers automatically - self.app.get_viewer("table-viewer").figure_widget.highlighted = 0 def load_images(self, data_obj, data_labels=None, share_image=0): """ diff --git a/notebooks/MosvizNIRISSExample.ipynb b/notebooks/MosvizNIRISSExample.ipynb index cea3e65ea3..ce1ebe020b 100644 --- a/notebooks/MosvizNIRISSExample.ipynb +++ b/notebooks/MosvizNIRISSExample.ipynb @@ -117,6 +117,14 @@ "mosviz.load_data(directory=data_dir, instrument=\"niriss\")" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "21a10cc7", + "metadata": {}, + "outputs": [], + "source": [] + } ], "metadata": { "kernelspec": { From c047fa72cbf8a56e5edd62b18ea9e85472749469 Mon Sep 17 00:00:00 2001 From: Jesse Averbukh Date: Tue, 31 Aug 2021 17:01:46 -0400 Subject: [PATCH 2/3] Remove empty cell --- notebooks/MosvizNIRISSExample.ipynb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/notebooks/MosvizNIRISSExample.ipynb b/notebooks/MosvizNIRISSExample.ipynb index ce1ebe020b..ae647501fa 100644 --- a/notebooks/MosvizNIRISSExample.ipynb +++ b/notebooks/MosvizNIRISSExample.ipynb @@ -116,14 +116,6 @@ "source": [ "mosviz.load_data(directory=data_dir, instrument=\"niriss\")" ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "21a10cc7", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { From e2b36dddeca098bb7cf1304539de7988fea3792d Mon Sep 17 00:00:00 2001 From: Ricky O'Steen Date: Wed, 1 Sep 2021 10:43:58 -0400 Subject: [PATCH 3/3] Handle missing slit information more gracefully --- jdaviz/configs/mosviz/helper.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jdaviz/configs/mosviz/helper.py b/jdaviz/configs/mosviz/helper.py index 5911f0a3f9..1530b9a85e 100644 --- a/jdaviz/configs/mosviz/helper.py +++ b/jdaviz/configs/mosviz/helper.py @@ -154,7 +154,11 @@ def _zoom_to_slit_params(self, msg): imview = self.app.get_viewer("image-viewer") specview = self.app.get_viewer("spectrum-2d-viewer") - sky_region = jwst_header_to_skyregion(specview.layers[0].layer.meta) + try: + sky_region = jwst_header_to_skyregion(specview.layers[0].layer.meta) + except KeyError: + # If the header didn't have slit params, can't zoom to it. + return None, None ra = sky_region.center.ra.deg dec = sky_region.center.dec.deg