From afc8112d8b30d110e22f584189209c60df739a1e Mon Sep 17 00:00:00 2001 From: Ricky O'Steen Date: Tue, 15 Nov 2022 12:04:38 -0500 Subject: [PATCH] NIRCam loading no longer errors out, needs confirmation that it's all correct --- jdaviz/configs/mosviz/helper.py | 2 +- jdaviz/configs/mosviz/plugins/parsers.py | 31 ++++++++++++++---------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/jdaviz/configs/mosviz/helper.py b/jdaviz/configs/mosviz/helper.py index cf0a2abf3d..c62feb2c12 100644 --- a/jdaviz/configs/mosviz/helper.py +++ b/jdaviz/configs/mosviz/helper.py @@ -435,7 +435,7 @@ def load_data(self, spectra_1d=None, spectra_2d=None, images=None, instrument = "nirspec" if instrument.lower() == "nirspec": super().load_data(directory, parser_reference="mosviz-nirspec-directory-parser") - elif instrument.lower() == "niriss": + elif instrument.lower() in ("niriss", "nircam"): self.load_niriss_data(directory) elif directory is not None and is_zipfile(str(directory)): raise TypeError("Please extract your data first and provide the directory") diff --git a/jdaviz/configs/mosviz/plugins/parsers.py b/jdaviz/configs/mosviz/plugins/parsers.py index 95d7bba616..4764a2fb89 100644 --- a/jdaviz/configs/mosviz/plugins/parsers.py +++ b/jdaviz/configs/mosviz/plugins/parsers.py @@ -762,12 +762,12 @@ def mos_niriss_parser(app, data_dir, table_viewer_reference_name='table-viewer') if i == 0: filter = temp[0].header["FILTER"] if "EXTNAME" in temp[i].header: - if (temp[i].header["EXTNAME"] == "SCI" - and (temp[i].header["SOURCEID"] - in cat_id_dict.keys())): + if temp[i].header["EXTNAME"] == "SCI": + if cat_id_dict is not None: + if (temp[i].header["SOURCEID"] not in cat_id_dict.keys()): + continue sci_hdus.append(i) - wav_hdus[i] = ('WAVELENGTH', - temp[i].header['EXTVER']) + wav_hdus[i] = ('WAVELENGTH', temp[i].header['EXTVER']) # Now get a Spectrum1D object for each matching SCI HDU source_ids.extend(_get_source_identifiers_by_hdu([temp[sci] for sci in sci_hdus])) @@ -800,10 +800,12 @@ def mos_niriss_parser(app, data_dir, table_viewer_reference_name='table-viewer') add_to_glue[label] = spec2d # update labels for table viewer - ra, dec = cat_id_dict[temp[sci].header["SOURCEID"]] - ras.append(ra) - decs.append(dec) - image_add.append(image_dict[filter_name]) + if cat_id_dict is not None: + ra, dec = cat_id_dict[temp[sci].header["SOURCEID"]] + ras.append(ra) + decs.append(dec) + if filter_name in image_dict: + image_add.append(image_dict[filter_name]) spec_labels_2d.append(label) filters.append(filter) @@ -816,10 +818,13 @@ def mos_niriss_parser(app, data_dir, table_viewer_reference_name='table-viewer') with fits.open(fname, memmap=False) as temp: # Filter out HDUs we care about - source_ids_to_filter = cat_id_dict.keys() - filtered_hdul = fits.HDUList([hdu for hdu in temp if ( - (hdu.name in ('PRIMARY', 'ASDF')) or - (hdu.header.get('SOURCEID', None) in source_ids_to_filter))]) + if cat_id_dict is not None: + source_ids_to_filter = cat_id_dict.keys() + filtered_hdul = fits.HDUList([hdu for hdu in temp if ( + (hdu.name in ('PRIMARY', 'ASDF')) or + (hdu.header.get('SOURCEID', None) in source_ids_to_filter))]) + else: + filtered_hdul = temp # SRCTYPE is required for the specutils JWST x1d reader. The reader will # force this to POINT if not set. Under known cases, this field will be set