6

我在用 Iraf 生成的 fit 文件中有一个光谱。波长轴在标头中编码为:

WAT0_001= 'system=multispec'
WAT1_001= 'wtype=multispec label=Wavelength units=angstroms'
WAT2_001= 'wtype=multispec spec1 = "1 1 2 1. 2.1919422441886 4200 0. 452.53 471'
WAT3_001= 'wtype=linear'
WAT2_002= '.60 1. 0. 3 3 1. 4200.00000000001 1313.88904209266 1365.65012876239 '
WAT2_003= '1422.67911152069 1479.0560707956 1535.24082980747 1584.94609332243'

有没有一种简单的方法可以将它加载到 python 中?

4

2 回答 2

9

我一直在使用Rick White 给我的代码但是,specutils包可能是更好的方法:

from specutils.io import read_fits
spectra_list = read_fits.read_fits_spectrum1d('mymultispec.fits')
print spectra_list[0]
   Spectrum1D([ 338.06109619,  395.59234619,  326.0012207 , ...,
         660.0098877 ,  686.54498291,  689.58374023])

print spectra_list[1].dispersion
   <Quantity [ 8293.44875263, 8293.40459999, 8293.36044556,...,
        8166.53073537, 8166.48250242, 8166.43426803] Angstrom>
于 2015-04-28T15:17:00.280 回答
0

跟进@kgully 的答案 - 以及相关讨论:specutils支持再次读取多规范文件(已经有好几年了,尽管在这些答案之间没有工作一段时间)。相关的代码片段(对于任何IRAF 格式的文件)现在是:

>>> from specutils import Spectrum1D
>>> spec = Spectrum1D.read('mymultispec.fits')
>>> print(spec)
Spectrum1D (length=762078)
flux:             [ 0.4408 adu, ..., -1.0 adu ],  mean=0.74146 adu
spectral axis:    [ 3726.7 Angstrom, ..., 9300.0 Angstrom ],  
mean=6094.4 Angstrom

如果您的多规格文件实际上有多个光谱,则替换Spectrum1D为。SpectrumCollection

于 2021-06-19T17:04:40.617 回答