not able to read correct unit to JWST spectrum
I found that specutils does not read in the correct units for JWST NIRSpec spectra.
Specifically using
spec1d = Spectrum1D.read(filepath)
returns
<Spectrum1D(flux=[0.0 ... 0.0] MJy / sr (shape=(431,), mean=0.25295 MJy / sr); spectral_axis=<SpectralAxis [0.5493196 0.55267611 0.55607917 ... 5.36297138 5.37025765 5.37753207] um> (length=431); uncertainty=StdDevUncertainty)>
note that the flux units it returns are MJy/sr, however, the correct units should be Jy.
Using astropy Table.read:
spec = Table.read(filepath , hdu=1)
spec["FLUX"].unit
returns "Jy".
The file used for this is attached.
Thanks for this report. It looks like the reason you're getting MJy/sr is because the header of the file has a SRCTYPE keyword value of "EXTENDED", which means the reader will use the surface brightness column values rather than flux, which would be used for a "POINT" or "UNKNOWN" SRCTYPE.
For now, if you do want to create a Spectrum1D with the flux instead of surface brightness for this file, you can manually grab the flux and wavelength columns and create a Spectrum1D with the flux and spectral_axis keywords (and probably uncertainty) specified. Obviously that's not as convenient, so I'll open an issue to add a keyword to Spectrum1D.read() to override the column that's used for the flux.
I think is fixed by #1144. The new call would be
spec = specutils.Spectrum.read(filepath, flux_col="flux")
I think is fixed by #1144. The new call would be
spec = specutils.Spectrum.read(filepath, flux_col="flux")
Yes indeed, thanks for the reminder to close this.