Skip to content

Commit

Permalink
WIP: Specviz2d to parse NIRSpec level 2 s2d
Browse files Browse the repository at this point in the history
  • Loading branch information
pllim committed Aug 30, 2022
1 parent 6e6626c commit f270db0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ Mosviz
Specviz
^^^^^^^

Specviz2d
^^^^^^^^^

- Fix parser for Level 2 NIRSpec ``s2d`` files. [#1608]

Other Changes and Additions
---------------------------

Expand Down
16 changes: 14 additions & 2 deletions jdaviz/configs/mosviz/plugins/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,22 @@ def _parse_as_spectrum1d(path):
with fits.open(path) as hdulist:
data = hdulist[1].data
header = hdulist[1].header
wcs = WCS(header)
data_unit = u.Unit(header['BUNIT'])
metadata = standardize_metadata(header)
metadata[PRIHDR_KEY] = standardize_metadata(hdulist[0].header)
return Spectrum1D(data, wcs=wcs, meta=metadata)
wcs = WCS(header)

# FITS WCS is invalid, so ignore it.
if wcs.spectral.naxis == 0:
# UnitTypeError: SpectralCoord instances require units equivalent to
# '(Unit("Hz"), Unit("m"), Unit("J"), Unit("1 / m"), Unit("km / s"))',
# so cannot set it to 'pix'.
# kw = {'spectral_axis': np.arange(data.shape[1]) * u.pix}
kw = {'wcs': None}
else:
kw = {'wcs': wcs}

return Spectrum1D(flux=data * data_unit, meta=metadata, **kw)

# Coerce into list-like object
if not isinstance(data_obj, (list, tuple, SpectrumCollection)):
Expand Down

0 comments on commit f270db0

Please sign in to comment.