FitsLoader.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:black_holes 作者: codeforgoodconf 项目源码 文件源码
def load_fits(self, file_url):
        hdu = fits.open(f"{DATA_ROOT}//{file_url}.fits")
        dat, hdr = hdu[1].data, hdu[0].header
        z = hdu[2].data['Z'][0]    # This is the redshift
        hdu.close()

        wav_rest= 10**(dat['loglam'])/(1+z) #convert to rest frame
           # See https://en.wikipedia.org/wiki/Redshift
        fwav = dat['flux']    # Get flux density, in this case erg/cm^2/s/Angstrom.

        #xs = np.log(wav[idx])
        #ys = np.log(flx[idx])

        # Normalize the spectrum for plotting purposes.
        def find_nearest(array, value):
            """Quick nearest-value finder."""
            return int((np.abs(array - value)).argmin())

        norm = fwav[find_nearest(wav_rest, 5100)]
        fwav = fwav / norm

        return wav_rest, fwav
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号