jdaviz: Fix bug when loading level 2 nirspec MSA spectra into mosviz
Reporter: Erik Tollerud
While trying to load a level 2 nirspec MSA file from MAST into mosviz, I got a curious error:
mosviz.load_spectra(results['Local Path'][1], results['Local Path'][0])
IORegistryError: Format could not be identified based on the file name or contents, please provide a 'format' argument.
Tracing this a bit further, I tried loading the file as a Spectrum1D and got:
specutils.Spectrum1D.read(results['Local Path'][1], format='JWST x1d')
which yielded a more useful error:
RuntimeError: Input data has 71 spectra. Use SpectrumList.read() instead.
which makes sense, so I then did
specutils.SpectrumList.read(results['Local Path'][1], format='JWST x1d')
which yielded the exact same error, which does not make sense!
I can provide the file to reproduce if needed, but would have to be via private message because it’s currently proprietary data. (and probably any NIRSpec MSA level 2 files will do? So there might be something public that can be tested on.)
DISCLAIMER: This issue was autocreated by the Jdaviz Issue Creation Bot on behalf of the reporter. If any information is incorrect, please contact Duy Nguyen
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 17 (9 by maintainers)
Loading level 2 nirspec data is part of the grand scheme for mosviz, but we are not there yet.
But to make things more interesting, specutils does grab GWCS depending if your logic goes to the correct loader…
https://github.com/astropy/specutils/blob/695e475ca392eb1c5be8cfff30b144239b777136/specutils/io/default_loaders/jwst_reader.py#L422
Ah, asking Mosviz to do this would be a new feature request and should be a separate ticket – cc @camipacifici
I tracked this down - it’s because for some reason
SpectrumCollection.metadefaults to None instead of an emptydict. So I manually set it, and then ran into another problem where the mosviz loader doessomething.meta = something_else, andSpectrumCollectiondoesn’t allow setting ofmeta, which I fixed by just using.updateinstead. I can make a PR for just that, but it still doesn’t solve the problem because then I get:Which is pretty clear, but surprising to me: how do we even show 2D spectra that are not rectified without a
SpectrumCollectionadapter?