def noise_amp(self, size):
"""
DESCRIPTION:
Creates a size x size matrix of randomly generated noise with
amplitude values with 1/f slope
ARGS:
:size: size of matrix
RETURNS:
:returns the amplitudes with noise added
"""
slope = 1
x = y = np.linspace(1, size, size)
xgrid, ygrid = np.meshgrid(x, y) # coordinates for a square grid
xgrid = np.subtract(xgrid, size // 2)
ygrid = np.subtract(ygrid, size // 2)
amp = self.fft.fftshift(np.divide(np.sqrt(np.square(xgrid) +
np.square(ygrid)),
size * np.sqrt(2)))
amp = np.rot90(amp, 2)
amp[0, 0] = 1
amp = 1 / amp**slope
amp[0, 0] = 0
return amp
评论列表
文章目录