How to compute fft to store sine and cosine values and then set the higher harmonics to zero for performing Fourier smoothing in python? #4654
Unanswered
dikshitanavle
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Hi @dikshitanavle — there's a lot in your question. Could you break it down — what's the xarray-specific part of the question? Could you abstract that from the FFT part of your question? Here are some resources for asking engageable questions: |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Fourier Transform in Python can be taken by using various functions in scipy or numpy modules. I want to perform Fourier smoothing on the available data by:
Taking Fourier Transform of the available data
Setting higher harmonics to 0
And then taking its Inverse Fourier Transform
I tried this by using numpy in python as follows:
I have a 4-dimensional daily dataset for air temperature which has dimensions- time, level, latitude and longitude. But I want to take Fourier transform such that the FFT coefficients: real(cosine) and imaginary(sine) are stored as two different parts. The FFT function should introduce an extra (5th) dimension for this purpose. For example, fftofds[0,0:11,6,6,6] should return the real(cosine) part at time(0:11),level(6), latitude(6), longitude(6) and , fftofds[1,0:11,6,6,6] should return the imaginary(sine) part at time(0:11),level(6), latitude(6), longitude(6).
Further the higher harmonics should be set to zero. eg: fftofds[3:]=0 and then the Inverse FFT should be performed on it. How can I achieve this using Python?
Beta Was this translation helpful? Give feedback.
All reactions