specutils icon indicating copy to clipboard operation
specutils copied to clipboard

not able to read correct unit to JWST spectrum

Open afaisst opened this issue 1 year ago • 1 comments

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

afaisst avatar Jun 14 '24 19:06 afaisst

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.

rosteen avatar Jun 18 '24 14:06 rosteen

I think is fixed by #1144. The new call would be

spec = specutils.Spectrum.read(filepath, flux_col="flux")

kelle avatar Jul 17 '25 18:07 kelle

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.

rosteen avatar Jul 22 '25 13:07 rosteen