Archived
Initial commit
This commit is contained in:
commit
d89b82be4a
103 files changed
+23110
No files matched your search
@@ -0,0 +1,23 @@
|
||||
import numpy as np
|
||||
from scipy.fftpack import fft
|
||||
|
||||
|
||||
def noise(x, fs, do_am=False, smooth=False):
|
||||
X = fft(x)
|
||||
n = len(X)
|
||||
|
||||
if n % 2 == 0:
|
||||
p = np.random.rand((n-2)/2)
|
||||
p = np.hstack((0, p, 0, -p))
|
||||
else:
|
||||
p = np.random.rand((n-1)/2)
|
||||
p = np.hstack((0, p, -p))
|
||||
|
||||
if not smooth:
|
||||
Y = np.abs(X) * np.exp(1j*2*np.pi*p)
|
||||
|
||||
y = np.real(np.fft.ifft(Y))
|
||||
|
||||
y = y * np.sqrt(np.mean(x**2)) / np.sqrt(np.mean(y**2))
|
||||
|
||||
return y
|
||||
Reference in new issue
Block a user