smoothing.py 文件源码

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

项目:ThePayne 作者: pacargile 项目源码 文件源码
def smooth_fft(dx, spec, sigma):
    """Basic math for FFT convolution with a gaussian kernel.
    :param dx:
        The wavelength or velocity spacing, same units as sigma
    :param sigma:
        The width of the gaussian kernel, same units as dx
    :param spec:
        The spectrum flux vector
    """
    # The Fourier coordinate
    ss = rfftfreq(len(spec), d=dx)
    # Make the fourier space taper; just the analytical fft of a gaussian
    taper = np.exp(-2 * (np.pi ** 2) * (sigma ** 2) * (ss ** 2))
    ss[0] = 0.01  # hack
    # Fourier transform the spectrum
    spec_ff = np.fft.rfft(spec)
    # Multiply in fourier space
    ff_tapered = spec_ff * taper
    # Fourier transform back
    spec_conv = np.fft.irfft(ff_tapered)
    return spec_conv
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号