<div dir="ltr"><div>Perhaps the best approach: Contact NCAR's "<a href="https://geocat.ucar.edu/"><b>GeoCAT</b></a>" <br></div><div>They should have the Python expertise to help you.</div><div><br></div><div>Good Luck<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 8, 2023 at 1:36 PM Christophersen, Dr. Jonathan, Contractor, Code 7532 via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu">ncl-talk@mailman.ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="msg-2487645428256063165"><div lang="EN-US"><div class="m_-2487645428256063165WordSection1"><p class="MsoNormal">Hi NCL users,<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Apologies if this is more of a Pythonic question than NCL, but I’m in need of some help with converting NCL’s fft2df/fft2db over to Python NumPy’s (or SciPy’s) fft2/ifft2. I’ve gotten pretty close to a workable solution, but there are still some conversion problems.<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">The Python (pseudo-)code that I’ve been able to reproduce NCL’s fft2df function with breaks the result of the 2D-FFT into components, but this is just for investigative convenience for now :-). Code is as follows:<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">fftData = np.fft.fft2(F_x, axes=(-2, -1), norm='forward')<u></u><u></u></p><p class="MsoNormal">real_fft_tmp = np.real(fftData)<u></u><u></u></p><p class="MsoNormal">imag_fft_tmp = np.imag(fftData)<u></u><u></u></p><p class="MsoNormal">real_fft = 2*np.roll(np.flipud(real_fft_tmp), shift=1, axis=0)<u></u><u></u></p><p class="MsoNormal">imag_fft = 2*np.roll(np.flipud(imag_fft_tmp), shift=1, axis=0)<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">And if I’m only considering the data up to the Nyquist frequency (NCL’s fft2df only returns half the spectrum) then I get a pretty close match in spectral space for both real and imaginary components. However, the differences that are present (error within 10^-5) seem to throw off the inverse FFT2 and I end up with large errors. Is anybody working on a 2D-FFT conversion from NCL to Python that might be able to answer this or shed some light on what I might be doing wrong?<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Thanks so much for any help, and I’m happy to answer whatever questions there might be. I’m not permitted to share my actual source code, so apologies for any inconvenience.<u></u><u></u></p><p class="MsoNormal">Jon<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><u></u> <u></u></p></div></div>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="https://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">https://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
</div></blockquote></div>