Skip to content

Commit

Permalink
NIRCam loading no longer errors out, needs confirmation that it's all…
Browse files Browse the repository at this point in the history
… correct
  • Loading branch information
rosteen committed Nov 15, 2022
1 parent 9a30ed3 commit afc8112
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion jdaviz/configs/mosviz/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
31 changes: 18 additions & 13 deletions jdaviz/configs/mosviz/plugins/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down Expand Up @@ -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)

Expand All @@ -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
Expand Down

0 comments on commit afc8112

Please sign in to comment.