Unit Error when using JWST wasp-96 spectrum fits file in SpecViz. #1486
-
I want to simply plot the spectrum on the SpecViz app. Here is my code snippet from jupyter-lab.
I have also tried all other formats available for JWST just to be sure. Although, I am not finding anything useful in the documentation. I have been using it the same way for SDSS (with a different format ofc) and it worked in the past. But for JWST, it gives the following error.
Forgive me if this is a very stupid question. I will appreciate any help. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Hi @prashant050701 - unfortunately jdaviz does not currently support x1dint files (but do support x1d files). I created #1487 to track progress for either implementing that in the future or at least raising a more informative error message. Thanks for bringing this to our attention! |
Beta Was this translation helpful? Give feedback.
-
For more context @prashant050701, I reached out to one of our project scientists (@camipacifici), and x1dints are level 2 data products coming out of the JWST pipeline. Specviz is designed to work with the level 3 "combined" products. Not sure what your science use case is, but unless you're looking for something at the integration level, I would also suggest looking at the corresponding final, combined x1d file for those spectra in your project |
Beta Was this translation helpful? Give feedback.
-
I think the table header is missing If you download the file first to a local disk, you can fix it yourself like this: from astropy.io import fits
filename = 'jw02734-o002_t002_niriss_clear-gr700xd-substrip256_x1dints.fits'
with fits.open(filename, mode='update') as pf:
for hdu in pf:
if hdu.name == 'EXTRACT1D' and 'TUNIT1' not in hdu.header:
hdu.header['TUNIT1'] = 'um' That said, after the fix is applied and Specviz not longer crashes, it took a long time to load all 840 spectra from that file. Do people even want to load all 840 spectra at once? What is the science goal of looking at this file? I tried to load all the extensions and it took so long I had to kill the notebook. If you only want to load a particular spectrum, once you determined the extension number of interest, you can do the following to only load one: from astropy import units as u
from astropy.io import fits
from astropy.table import QTable
from specutils import Spectrum1D
from jdaviz import Specviz
filename = 'jw02734-o002_t002_niriss_clear-gr700xd-substrip256_x1dints.fits'
pf = fits.open(filename)
extnum = 1 # Change this as needed
t = QTable.read(pf[extnum], format='fits')
# Assuming you did not fix the TUNIT1 yourself, you have to apply wavelength unit here manually.
sp = Spectrum1D(spectral_axis=t['WAVELENGTH'] * u.micron, flux=t['FLUX'])
viz = Specviz()
viz.load_data(sp, data_label=f'EXT {extnum}')
viz.show() |
Beta Was this translation helpful? Give feedback.
-
For completeness, I was able to randomly select three of the extensions and able to overplot them fine in Specviz. |
Beta Was this translation helpful? Give feedback.
I think the table header is missing
TUNIT1
that defines the wavelength unit (in addition to format that should beformat='JWST x1d multi'
), which I think the data provider needs to fix. cc @havok2063If you download the file first to a local disk, you can fix it yourself like this:
That said, after the fix is applied and Specviz not longer crashes, it took a long time to load all 840 spectra from that file. Do peo…