Last active
February 16, 2018 22:29
-
-
Save GCBallesteros/ec7c1521bba90fa320a3d28c88f94e65 to your computer and use it in GitHub Desktop.
Fourier Transform Of Fields
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# May need to pad with zeros the input fields to FFT to get the | |
# desired amount of frequency points. | |
n_sample_points = 2 * int(n_freq_points/(max_freq - min_freq) * max_freq) | |
fft_field = abs(np.fft.fft(field, n=n_sample_points, axis=-1).real) | |
fft_field = fft_field[:, :, :fft_field.shape[-1]//2] | |
freqs = np.fft.fftfreq(n_sample_points, d=dt)[:(n_sample_points/2)] | |
# We are only interested on the frequencies inside the source bandwidth | |
mask = (freqs >= min_freq) * (freqs <= max_freq) | |
freqs = freqs[mask] | |
fft_field = fft_field[:, :, mask] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment