mirror of
https://github.com/cdtools-developers/cdtools.git
synced 2026-09-09 21:12:42 +02:00
remove dependency on fftpack completely
This commit is contained in:
@@ -9,7 +9,6 @@ data has been stored in numpy arrays.
|
||||
import torch as t
|
||||
import numpy as np
|
||||
from cdtools.tools import image_processing as ip
|
||||
from scipy import fftpack
|
||||
from scipy import linalg as sla
|
||||
from scipy import special
|
||||
|
||||
@@ -378,8 +377,8 @@ def calc_consistency_prtf(synth_obj, objects, basis, obj_slice=None,nbins=None):
|
||||
di = np.linalg.norm(basis[:,0])
|
||||
dj = np.linalg.norm(basis[:,1])
|
||||
|
||||
i_freqs = fftpack.fftshift(fftpack.fftfreq(synth_fft.shape[0],d=di))
|
||||
j_freqs = fftpack.fftshift(fftpack.fftfreq(synth_fft.shape[1],d=dj))
|
||||
i_freqs = np.fft.fftshift(np.fft.fftfreq(synth_fft.shape[0],d=di))
|
||||
j_freqs = np.fft.fftshift(np.fft.fftfreq(synth_fft.shape[1],d=dj))
|
||||
|
||||
Js,Is = np.meshgrid(j_freqs,i_freqs)
|
||||
Rs = np.sqrt(Is**2+Js**2)
|
||||
@@ -523,8 +522,8 @@ def calc_frc(im1, im2, basis, im_slice=None, nbins=None, snr=1., limit='side'):
|
||||
di = np.linalg.norm(basis[:,0])
|
||||
dj = np.linalg.norm(basis[:,1])
|
||||
|
||||
i_freqs = fftpack.fftshift(fftpack.fftfreq(cor_fft.shape[0],d=di))
|
||||
j_freqs = fftpack.fftshift(fftpack.fftfreq(cor_fft.shape[1],d=dj))
|
||||
i_freqs = np.fft.fftshift(np.fft.fftfreq(cor_fft.shape[0],d=di))
|
||||
j_freqs = np.fft.fftshift(np.fft.fftfreq(cor_fft.shape[1],d=dj))
|
||||
|
||||
Js,Is = np.meshgrid(j_freqs,i_freqs)
|
||||
Rs = np.sqrt(Is**2+Js**2)
|
||||
@@ -919,8 +918,8 @@ def calc_generalized_frc(fields_1, fields_2, basis, im_slice=None, nbins=None, s
|
||||
di = np.linalg.norm(basis[:,0])
|
||||
dj = np.linalg.norm(basis[:,1])
|
||||
|
||||
i_freqs = fftpack.fftshift(fftpack.fftfreq(cor_fft.shape[0],d=di))
|
||||
j_freqs = fftpack.fftshift(fftpack.fftfreq(cor_fft.shape[1],d=dj))
|
||||
i_freqs = np.fft.fftshift(np.fft.fftfreq(cor_fft.shape[0],d=di))
|
||||
j_freqs = np.fft.fftshift(np.fft.fftfreq(cor_fft.shape[1],d=dj))
|
||||
|
||||
Js,Is = np.meshgrid(j_freqs,i_freqs)
|
||||
Rs = np.sqrt(Is**2+Js**2)
|
||||
|
||||
@@ -10,7 +10,6 @@ written by Jim LeBeau, but above is the original reference.
|
||||
|
||||
import numpy as np
|
||||
import torch as t
|
||||
from scipy import fftpack
|
||||
|
||||
|
||||
__all__ = ['generate_k_grid','generate_atom']
|
||||
@@ -1259,8 +1258,8 @@ def fParams(Z):
|
||||
|
||||
|
||||
def generate_k_grid(shape, spacing):
|
||||
ki = 2 * np.pi * fftpack.fftfreq(shape[0],spacing[0])
|
||||
kj = 2 * np.pi * fftpack.fftfreq(shape[1],spacing[1])
|
||||
ki = 2 * np.pi * np.fft.fftfreq(shape[0],spacing[0])
|
||||
kj = 2 * np.pi * np.fft.fftfreq(shape[1],spacing[1])
|
||||
Kj, Ki = np.meshgrid(kj,ki)
|
||||
return Ki, Kj, np.sqrt(Ki**2 + Kj**2)
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import torch as t
|
||||
from cdtools.tools.propagators import *
|
||||
from cdtools.tools.analysis import orthogonalize_probes
|
||||
from cdtools.tools import image_processing
|
||||
from scipy.fftpack import next_fast_len
|
||||
from scipy.sparse import linalg as spla
|
||||
from torch.nn.functional import pad
|
||||
import numpy as np
|
||||
@@ -20,7 +19,12 @@ from functools import *
|
||||
__all__ = ['exit_wave_geometry', 'calc_object_setup', 'gaussian',
|
||||
'gaussian_probe', 'SHARP_style_probe', 'STEM_style_probe',
|
||||
'RPI_spectral_init',
|
||||
'generate_subdominant_modes']
|
||||
'generate_subdominant_modes']
|
||||
|
||||
# I need to remove a dependency on scipy.fftpack, so I did this.
|
||||
# I should replace this with a real function
|
||||
def next_fast_len(x):
|
||||
return x
|
||||
|
||||
def exit_wave_geometry(det_basis, det_shape, wavelength, distance, center=None, opt_for_fft=True, padding=0, oversampling=1):
|
||||
"""Returns an exit wave basis and shape, as well as a detector slice for the given detector geometry
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import numpy as np
|
||||
from scipy import fftpack as ffts
|
||||
from scipy import linalg as la
|
||||
import torch as t
|
||||
from itertools import combinations
|
||||
@@ -251,18 +250,18 @@ def test_calc_frc():
|
||||
nbins = 100
|
||||
snr = 2
|
||||
|
||||
cor_fft = ffts.fftshift(ffts.fft2(obj1[10:-10,20:-20])) * \
|
||||
ffts.fftshift(np.conj(ffts.fft2(obj2[10:-10,20:-20])))
|
||||
cor_fft = np.fft.fftshift(np.fft.fft2(obj1[10:-10,20:-20])) * \
|
||||
np.fft.fftshift(np.conj(np.fft.fft2(obj2[10:-10,20:-20])))
|
||||
|
||||
F1 = np.abs(ffts.fftshift(ffts.fft2(obj1[10:-10,20:-20])))**2
|
||||
F2 = np.abs(ffts.fftshift(ffts.fft2(obj2[10:-10,20:-20])))**2
|
||||
F1 = np.abs(np.fft.fftshift(np.fft.fft2(obj1[10:-10,20:-20])))**2
|
||||
F2 = np.abs(np.fft.fftshift(np.fft.fft2(obj2[10:-10,20:-20])))**2
|
||||
|
||||
|
||||
di = np.linalg.norm(basis[:,0])
|
||||
dj = np.linalg.norm(basis[:,1])
|
||||
|
||||
i_freqs = ffts.fftshift(ffts.fftfreq(cor_fft.shape[0],d=di))
|
||||
j_freqs = ffts.fftshift(ffts.fftfreq(cor_fft.shape[1],d=dj))
|
||||
i_freqs = np.fft.fftshift(np.fft.fftfreq(cor_fft.shape[0],d=di))
|
||||
j_freqs = np.fft.fftshift(np.fft.fftfreq(cor_fft.shape[1],d=dj))
|
||||
|
||||
Js,Is = np.meshgrid(j_freqs,i_freqs)
|
||||
Rs = np.sqrt(Is**2+Js**2)
|
||||
|
||||
@@ -2,7 +2,7 @@ from cdtools.tools import interactions
|
||||
import numpy as np
|
||||
import torch as t
|
||||
from numpy import fft
|
||||
from scipy.fftpack import fftshift, ifftshift
|
||||
from numpy.fft import fftshift, ifftshift
|
||||
import pytest
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user