Fourier Analysis#
Overview#
This section covers Fourier analysis functions from NCL:
Functions#
cfftf#
NCL’s cfftf calculates an unnormalized forward complex discrete Fourier transform of a real periodic sequence
Grab and Go#
import numpy as np
example_data = [
1002,
1017,
1018,
1020,
1018,
1027,
1028,
1030,
1012,
1012,
982,
1012,
1001,
996,
995,
1011,
1027,
1025,
1030,
1016,
996,
1006,
1002,
982,
]
cfftf = np.fft.fft(example_data)
print(cfftf.real)
[ 2.42650000e+04 1.60612517e+01 -1.61808312e+02 2.60000000e+01
3.95000000e+01 -6.47808940e+01 1.00000000e+00 -3.26972907e+01
3.25000000e+01 2.60000000e+01 -4.19168826e+00 3.54169330e+01
-4.30000000e+01 3.54169330e+01 -4.19168826e+00 2.60000000e+01
3.25000000e+01 -3.26972907e+01 1.00000000e+00 -6.47808940e+01
3.95000000e+01 2.60000000e+01 -1.61808312e+02 1.60612517e+01]
cfftb#
NCL’s cfftb calculates a backward complex discrete Fourier transform
Grab and Go#
import numpy as np
example_data = [
1002,
1017,
1018,
1020,
1018,
1027,
1028,
1030,
1012,
1012,
982,
1012,
1001,
996,
995,
1011,
1027,
1025,
1030,
1016,
996,
1006,
1002,
982,
]
cfftb = np.fft.ifft(example_data)
print(cfftb.real)
[ 1.01104167e+03 6.69218822e-01 -6.74201299e+00 1.08333333e+00
1.64583333e+00 -2.69920392e+00 4.16666667e-02 -1.36238711e+00
1.35416667e+00 1.08333333e+00 -1.74653677e-01 1.47570554e+00
-1.79166667e+00 1.47570554e+00 -1.74653677e-01 1.08333333e+00
1.35416667e+00 -1.36238711e+00 4.16666667e-02 -2.69920392e+00
1.64583333e+00 1.08333333e+00 -6.74201299e+00 6.69218822e-01]
Inverse Fourier transformation of the forward Fourier transform returns input data
import numpy as np
example_data = [
1002,
1017,
1018,
1020,
1018,
1027,
1028,
1030,
1012,
1012,
982,
1012,
1001,
996,
995,
1011,
1027,
1025,
1030,
1016,
996,
1006,
1002,
982,
]
cfftf = np.fft.fft(example_data)
cfftb = np.fft.ifft(cfftf)
print(cfftb.real)
[1002. 1017. 1018. 1020. 1018. 1027. 1028. 1030. 1012. 1012. 982. 1012.
1001. 996. 995. 1011. 1027. 1025. 1030. 1016. 996. 1006. 1002. 982.]
Python Resources#
numpy: Discrete Fourier Transform functions