MCPcopy Create free account
hub / github.com/Meshcapade/difflocks / FDT

Function FDT

utils/general_util.py:81–114  ·  view source on GitHub ↗
(strand)

Source from the content-addressed store, hash-verified

79
80
81def FDT(strand):
82 codes = []
83 N = strand.shape[0]
84 count = 0
85
86 for j in range(3):
87 code = []
88 t = np.linspace(0, 1, N, endpoint=False)
89 signal = strand[:, j]
90
91 # calculate DFT
92 X = np.fft.fft(signal)
93
94 # calculate magnitude and phase
95 F_A = np.abs(X)
96 # phase_spectrum = np.angle(X)
97 # F_cos = X.real/F_A
98 # F_sin = X.imag/F_A
99 F_cos = X.real
100 F_sin = X.imag
101 # 频率索引
102
103 # frequencies = np.fft.fftfreq(N, d=t[1] - t[0])
104 # reconstructed_fft_result = F_A * np.exp(1j * phase_spectrum)
105 # reconstructed_fft_result = np.fft.ifft(reconstructed_fft_result)
106
107 count += 1
108 code.append(F_A[:N//2+1])
109 code.append(F_cos[:N//2+1])
110 code.append(F_sin[:N//2+1])
111 code = np.concatenate(code,0)[...,None]
112 codes.append(code)
113 codes = np.concatenate(codes,1)
114 return codes
115
116
117def inverse_FDT(code):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected