astropy / specutils

An Astropy coordinated package for astronomical spectroscopy. Maintainers: @nmearl @rosteen @keflavich @eteq
http://specutils.readthedocs.io/en/latest/
161 stars 124 forks source link

not able to read correct unit to JWST spectrum #1143

Open afaisst opened 2 weeks ago

afaisst commented 2 weeks ago

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.

jw02565-o001_s09775_nirspec_clear-prism_x1d.fits.zip

rosteen commented 2 weeks ago

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.