[docs]deffftshift(freq:np.ndarray)->np.ndarray:""" Centers FFT frequencies so that 0 is in the center. Parameters ---------- freq : array Reorders any FFT frequency-like array to have the 0th element in the center. """returnfft.fftshift(freq)
[docs]defifftshift(freq:np.ndarray)->np.ndarray:""" Uncenters FFT frequencies so that 0 is no longer in the center. Parameters ---------- freq : array Reorders any FFT frequency-like array to have the 0th element back to the normal convention and not in the center. """returnfft.ifftshift(freq)
[docs]defnormalise_freq(freq:np.ndarray,boxsize:float)->np.ndarray:""" Normalises fourier frequencies, i.e. removing the dependency on boxsize. Parameters ---------- freq : array FFT frequencies. boxsize : float Size of the original box. """shape=np.shape(freq)grid=shape[0]dim=len(shape)dx=boxsize/gridfreq/=dx**dimreturnfreq
[docs]defunnormalise_freq(freq:np.ndarray,boxsize:float)->np.ndarray:""" Unnormalises fourier frequencies, i.e. adds the dependency on boxsize. Parameters ---------- freq : array FFT frequencies. boxsize : float Size of the original box. """shape=np.shape(freq)grid=shape[0]dim=len(shape)dx=boxsize/gridfreq*=dx**dimreturnfreq