当前位置: 首页>>代码示例>>Python>>正文


Python fft.ifftn方法代码示例

本文整理汇总了Python中numpy.fft.ifftn方法的典型用法代码示例。如果您正苦于以下问题:Python fft.ifftn方法的具体用法?Python fft.ifftn怎么用?Python fft.ifftn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在numpy.fft的用法示例。


在下文中一共展示了fft.ifftn方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: impute_aligned_vols

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifftn [as 别名]
def impute_aligned_vols(t, v, vm, normalize=None):
    assert (normalize is not None)
    if normalize:
        v = ((v - v.mean()) / v.std())
        if (t is not None):
            t = ((t - t.mean()) / t.std())
    if (t is None):
        return v
    t_f = NF.fftshift(NF.fftn(t))
    v_f = NF.fftshift(NF.fftn(v))
    v_f[(vm == 0)] = t_f[(vm == 0)]
    v_f_if = N.real(NF.ifftn(NF.ifftshift(v_f)))
    if normalize:
        v_f_if = ((v_f_if - v_f_if.mean()) / v_f_if.std())
    if N.all(N.isfinite(v_f_if)):
        return v_f_if
    else:
        print('warning: imputation failed')
        return v 
开发者ID:xulabs,项目名称:aitom,代码行数:21,代码来源:util.py

示例2: average

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifftn [as 别名]
def average(dj, mask_count_threshold):
    vol_sum = None
    mask_sum = None
    for d in dj:
        v = IF.read_mrc_vol(d['subtomogram'])
        if (not N.all(N.isfinite(v))):
            raise Exception('error loading', d['subtomogram'])
        vm = IF.read_mrc_vol(d['mask'])
        v_r = GR.rotate_pad_mean(v, angle=d['angle'], loc_r=d['loc'])
        assert N.all(N.isfinite(v_r))
        vm_r = GR.rotate_mask(vm, angle=d['angle'])
        assert N.all(N.isfinite(vm_r))
        if (vol_sum is None):
            vol_sum = N.zeros(v_r.shape, dtype=N.float64, order='F')
        vol_sum += v_r
        if (mask_sum is None):
            mask_sum = N.zeros(vm_r.shape, dtype=N.float64, order='F')
        mask_sum += vm_r
    ind = (mask_sum >= mask_count_threshold)
    vol_sum_fft = NF.fftshift(NF.fftn(vol_sum))
    avg = N.zeros(vol_sum_fft.shape, dtype=N.complex)
    avg[ind] = (vol_sum_fft[ind] / mask_sum[ind])
    avg = N.real(NF.ifftn(NF.ifftshift(avg)))
    return {'v': avg, 'm': (mask_sum / len(dj)), } 
开发者ID:xulabs,项目名称:aitom,代码行数:26,代码来源:aligned_refine.py

示例3: run_lct

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifftn [as 别名]
def run_lct(self, meas, X, Y, Z, S, x_max, y_max):
        self.max_dist = int(self.T * self.v/2 / self.channels[0])
        slope_x = self.dx * x_max / (self.fend/self.B * self.max_dist) * (1 + ((self.fstart/self.B)/(self.fend/self.B))**2)
        slope_y = self.dy * y_max / (self.fend/self.B * self.max_dist) * (1 + ((self.fstart/self.B)/(self.fend/self.B))**2)
        
        # params
        psf, fpsf = lct.getPSF(X, Y, Z, S, slope_x, slope_y)
        mtx, mtxi = lct.interpMtx(Z, S, self.fstart/self.B * self.max_dist, self.fend/self.B * self.max_dist)

        def pad_array(x, S, Z, X, Y):
            return np.pad(x, ((S*Z//2, S*Z//2), (Y//2, Y//2), (X//2, X//2)), 'constant')

        def trim_array(x, S, Z, X, Y):
            return x[S*int(np.floor(Z/2))+1:-S*int(np.ceil(Z/2))+1, Y//2+1:-Y//2+1, X//2+1:-X//2+1]

        invpsf = np.conj(fpsf) / (abs(fpsf)**2 + 1 / self.snr)
        tdata = np.matmul(mtx, meas.reshape((Z, -1))).reshape((-1, Y, X))

        fdata = fftn(pad_array(tdata, S, Z, X, Y))
        tvol = abs(trim_array(ifftn(fdata * invpsf), S, Z, X, Y))
        out = np.matmul(mtxi, tvol.reshape((S*Z, -1))).reshape((-1, Y, X))

        return out 
开发者ID:computational-imaging,项目名称:AcousticNLOS,代码行数:25,代码来源:AcousticNLOSReconstruction.py

示例4: lct

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifftn [as 别名]
def lct(x1, y1, t1, v, vol, snr):
    X = len(x1)
    Y = len(y1)
    Z = len(t1)
    S = 2
    slope = np.max(x1) / (np.max(t1) * v/2)
    slope = np.max(y1) / (np.max(t1) * v/2)
    psf, fpsf = getPSF(X, Y, Z, S, slope)
    mtx, mtxi = interpMtx(Z, S, 0, np.max(t1)*v)

    def pad_array(x, S, Z, X):
        return np.pad(x, ((S*Z//2, S*Z//2), (X//2, X//2), (Y//2, Y//2)), 'constant')

    def trim_array(x, S, Z, X):
        return x[S*(Z//2)+1:-S*(Z//2)+1, X//2+1:-X//2+1, Y//2+1:-Y//2+1]

    invpsf = np.conj(fpsf) / (abs(fpsf)**2 + 1 / snr)
    tdata = np.matmul(mtx, vol)
    fdata = fftn(pad_array(tdata, S, Z, X))
    tvol = abs(trim_array(ifftn(fdata * invpsf), S, Z, X))
    vol = np.matmul(mtxi, tvol)
    return vol 
开发者ID:computational-imaging,项目名称:AcousticNLOS,代码行数:24,代码来源:lct.py

示例5: run_test_c2c_impl

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifftn [as 别名]
def run_test_c2c_impl(self, shape, axes, inverse=False, fftshift=False):
        shape = list(shape)
        shape[-1] *= 2 # For complex
        known_data = np.random.normal(size=shape).astype(np.float32).view(np.complex64)
        idata = bf.ndarray(known_data, space='cuda')
        odata = bf.empty_like(idata)
        fft = Fft()
        fft.init(idata, odata, axes=axes, apply_fftshift=fftshift)
        fft.execute(idata, odata, inverse)
        if inverse:
            if fftshift:
                known_data = np.fft.ifftshift(known_data, axes=axes)
            # Note: Numpy applies normalization while CUFFT does not
            norm = reduce(lambda a, b: a * b, [known_data.shape[d]
                                               for d in axes])
            known_result = gold_ifftn(known_data, axes=axes) * norm
        else:
            known_result = gold_fftn(known_data, axes=axes)
            if fftshift:
                known_result = np.fft.fftshift(known_result, axes=axes)
        x = (np.abs(odata.copy('system') - known_result) / known_result > RTOL).astype(np.int32)
        a = odata.copy('system')
        b = known_result
        compare(odata.copy('system'), known_result) 
开发者ID:ledatelescope,项目名称:bifrost,代码行数:26,代码来源:test_fft.py

示例6: potential

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifftn [as 别名]
def potential(self, q, steps):
        hx = steps[0]
        hy = steps[1]
        hz = steps[2]
        Nx = q.shape[0]
        Ny = q.shape[1]
        Nz = q.shape[2]
        out = np.zeros((2*Nx-1, 2*Ny-1, 2*Nz-1))
        out[:Nx, :Ny, :Nz] = q
        K1 = self.sym_kernel(q.shape, steps)
        K2 = np.zeros((2*Nx-1, 2*Ny-1, 2*Nz-1))
        K2[0:Nx, 0:Ny, 0:Nz] = K1
        K2[0:Nx, 0:Ny, Nz:2*Nz-1] = K2[0:Nx, 0:Ny, Nz-1:0:-1] #z-mirror
        K2[0:Nx, Ny:2*Ny-1,:] = K2[0:Nx, Ny-1:0:-1, :]        #y-mirror
        K2[Nx:2*Nx-1, :, :] = K2[Nx-1:0:-1, :, :]             #x-mirror
        t0 = time.time()
        if pyfftw_flag:
            nthreads = int(conf.OCELOT_NUM_THREADS)
            if nthreads < 1:
                nthreads = 1
            K2_fft = pyfftw.builders.fftn(K2, axes=None, overwrite_input=False, planner_effort='FFTW_ESTIMATE',
                                       threads=nthreads, auto_align_input=False, auto_contiguous=False, avoid_copy=True)
            out_fft = pyfftw.builders.fftn(out, axes=None, overwrite_input=False, planner_effort='FFTW_ESTIMATE',
                                          threads=nthreads, auto_align_input=False, auto_contiguous=False, avoid_copy=True)
            out_ifft = pyfftw.builders.ifftn(out_fft()*K2_fft(), axes=None, overwrite_input=False, planner_effort='FFTW_ESTIMATE',
                                          threads=nthreads, auto_align_input=False, auto_contiguous=False, avoid_copy=True)
            out = np.real(out_ifft())

        else:
            out = np.real(ifftn(fftn(out)*fftn(K2)))
        t1 = time.time()
        logger.debug('fft time:' + str(t1-t0) + ' sec')
        out[:Nx, :Ny, :Nz] = out[:Nx,:Ny,:Nz]/(4*pi*epsilon_0*hx*hy*hz)
        return out[:Nx, :Ny, :Nz] 
开发者ID:ocelot-collab,项目名称:ocelot,代码行数:36,代码来源:sc.py

示例7: ifftd

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifftn [as 别名]
def ifftd(I, dims=None):

    # Compute fft
    if dims is None:
        X = ifftn(I)
    elif dims == 2:
        X = ifft2(I, axes=(0, 1))
    else:
        X = ifftn(I, axes=tuple(range(dims)))

    return X 
开发者ID:comp-imaging,项目名称:ProxImaL,代码行数:13,代码来源:utils.py

示例8: ifftnc

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifftn [as 别名]
def ifftnc(x, axes, ortho=True):
    tmp = fft.fftshift(x, axes=axes)
    tmp = fft.ifftn(tmp, axes=axes, norm="ortho" if ortho else None)
    return fft.ifftshift(tmp, axes=axes) 
开发者ID:MRSRL,项目名称:dl-cs,代码行数:6,代码来源:fftc.py

示例9: filter_given_curve

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifftn [as 别名]
def filter_given_curve(v, curve):
    grid = GV.grid_displacement_to_center(v.shape, GV.fft_mid_co(v.shape))
    rad = GV.grid_distance_to_center(grid)
    rad = N.round(rad).astype(N.int)
    b = N.zeros(rad.shape)
    for (i, a) in enumerate(curve):
        b[(rad == i)] = a
    vf = ifftn(ifftshift((fftshift(fftn(v)) * b)))
    vf = N.real(vf)
    return vf 
开发者ID:xulabs,项目名称:aitom,代码行数:12,代码来源:band_pass.py

示例10: vol_avg

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifftn [as 别名]
def vol_avg(dj, op, img_db):
    if len(dj) < op['mask_count_threshold']:        return None

    vol_sum = None
    mask_sum = None

    # temporary collection of local volume, and mask.
    for d in dj:
        v = img_db[d['subtomogram']]
        vm = img_db[d['mask']]

        v_r = GR.rotate_pad_mean(v, angle=d['angle'], loc_r=d['loc']);
        assert N.all(N.isfinite(v_r))
        vm_r = GR.rotate_mask(vm, angle=d['angle']);
        assert N.all(N.isfinite(vm_r))

        if vol_sum is None:     vol_sum = N.zeros(v_r.shape, dtype=N.float64, order='F')
        vol_sum += v_r

        if mask_sum is None:        mask_sum = N.zeros(vm_r.shape, dtype=N.float64, order='F')
        mask_sum += vm_r

    ind = mask_sum >= op['mask_count_threshold']
    if ind.sum() <= 0:  return None

    vol_sum = NF.fftshift(NF.fftn(vol_sum))
    avg = N.zeros(vol_sum.shape, dtype=N.complex)
    avg[ind] = vol_sum[ind] / mask_sum[ind]
    avg = N.real(NF.ifftn(NF.ifftshift(avg)))

    return {'v': avg, 'm': mask_sum / float(len(dj))} 
开发者ID:xulabs,项目名称:aitom,代码行数:33,代码来源:classify.py

示例11: inv_fourier_transform

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifftn [as 别名]
def inv_fourier_transform(v):
    return ifftn(ifftshift(v)).real 
开发者ID:xulabs,项目名称:aitom,代码行数:4,代码来源:faml.py

示例12: apply_ctf

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifftn [as 别名]
def apply_ctf(v, ctf):
    vc = N.real(     ifftn(  ifftshift(  ctf * fftshift(fftn(v)) ) )     )           # convolute v with ctf
    return vc 
开发者ID:xulabs,项目名称:aitom,代码行数:5,代码来源:ctf.py

示例13: dog_smooth__large_map

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifftn [as 别名]
def dog_smooth__large_map(v, s1, s2=None):

    if s2 is None:      s2 = s1 * 1.1       # the 1.1 is according to a DoG particle picking paper
    assert      s1 < s2

    size = v.shape


    pad_width = int(N.round(s2*2))
    vp = N.pad(array=v, pad_width=pad_width, mode='reflect')

    v_fft = fftn(vp).astype(N.complex64)
    del v;      GC.collect()


    g_small = difference_of_gauss_function(size=N.array([int(N.round(s2 * 4))]*3), sigma1=s1, sigma2=s2)
    assert      N.all(N.array(g_small.shape) <= N.array(vp.shape))       # make sure we can use CV.paste_to_whole_map()

    g = N.zeros(vp.shape)
    paste_to_whole_map(whole_map=g, vol=g_small, c=None)

    g_fft_conj = N.conj(   fftn(ifftshift(g)).astype(N.complex64)   )    # use ifftshift(g) to move center of gaussian to origin
    del g;      GC.collect()

    prod_t = (v_fft * g_fft_conj).astype(N.complex64)
    del v_fft;      GC.collect()
    del g_fft_conj;      GC.collect()

    prod_t_ifft = ifftn( prod_t ).astype(N.complex64)
    del prod_t;      GC.collect()

    v_conv = N.real( prod_t_ifft )
    del prod_t_ifft;      GC.collect()
    v_conv = v_conv.astype(N.float32)

    v_conv = v_conv[(pad_width+1):(pad_width+size[0]+1), (pad_width+1):(pad_width+size[1]+1), (pad_width+1):(pad_width+size[2]+1)]
    assert      size == v_conv.shape

    return v_conv 
开发者ID:xulabs,项目名称:aitom,代码行数:41,代码来源:gaussian.py

示例14: translation_align__given_unshifted_fft

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifftn [as 别名]
def translation_align__given_unshifted_fft(v1f, v2f):
    cor = fftshift( N.real( ifftn( v1f * N.conj(v2f) ) ) )

    mid_co = IVU.fft_mid_co(cor.shape)
    loc = N.unravel_index( cor.argmax(), cor.shape )

    return {'loc': (loc - mid_co), 'cor': cor[loc[0], loc[1], loc[2]]}




# for each angle, do a translation search 
开发者ID:xulabs,项目名称:aitom,代码行数:14,代码来源:util.py

示例15: fconv

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifftn [as 别名]
def fconv(x, otf):
    return np.real(ifftn(fftn(x) * otf)) 
开发者ID:computational-imaging,项目名称:AcousticNLOS,代码行数:4,代码来源:ADMMReconstruction.py


注:本文中的numpy.fft.ifftn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。