[ncl-talk] Fourier decompose

Gus Correa gus at ldeo.columbia.edu
Fri Feb 22 12:16:57 MST 2019


If what you want is the *spatial* 2D Fourier Transform
(" fourier decomposition ... over lat lon", as stated in your original
email),
i.e., if you're interested in the 2D wavenmuber  components (not in the
time frequencies)
you have to do it separately for each time record, as Dennis explained.

You can apply the 2D Fourier Transform function to the 2D array formed by
the reshaped
lat,lon coordinates (into a 1D array) concatenated over the time dimension,
because all you need to apply a 2D Fourier transform is a 2D numerical
array,
regardless of the meaning of the array components.
However, the result won't be the " fourier decomposition ... over lat lon"
that you said you want.

I hope this helps,
Gus Correa



On Fri, Feb 22, 2019 at 1:24 PM Soma Roy <somaroy892 at gmail.com> wrote:

> Best idea will be use nlat*nlon as total grid points using reshape and
> reorder the data so that input to the fft2df will be 2 dimensional (ngrids,
> ntim).
>
> Coef will then give you output as 2 x ngrids x (ntim/2+1).
>
> Soma
>
> On Fri, Feb 22, 2019, 21:32 Soma Roy <somaroy892 at gmail.com wrote:
>
>> Glad to know.
>> Many thanks Dennis.
>>
>> Soma
>>
>> On Fri, Feb 22, 2019, 21:09 Dennis Shea <shea at ucar.edu wrote:
>>
>>> *Please do not send direct emails to people. Only to ncl-talk.*
>>>
>>> If  "X" is the data then how can we use it?
>>>
>>> X (ntime, nlat, nlon).
>>>
>>> Output result matrix should be same as X.
>>> ==============
>>>
>>> *As noted in the documentation, *the function is prototyped as
>>> 2-dimensional
>>>
>>> *function fft2df ( x [*][*])*
>>>
>>> As I said, you must use a do loop. It is user (your) responsibility to
>>> do any book keepind [savinh]
>>>
>>>  ntim = 8
>>>   nlat = 6
>>>   mlon = 8
>>>   x = *random_normal* <http://www.ncl.ucar.edu/Document/Functions/Built-in/random_normal.shtml>( 10, 5, (/ntim,nlat,mlon/) )
>>>   xNew = new( *dimsizes*(x), "float")
>>>
>>>   do nt=0,ntim-1
>>>                                                       ; ANALYSIS
>>>      coef = *fft2df* (x(nt,:,:_)              ; *coef:  [2] x [6] x [5] ;     [2] x [nlat] x [mlon/2+1]*
>>>
>>> ; do something with coef *<== *YOUR* responsibility*
>>>
>>>       xNew(nt,:,:) = *fft2db* <http://www.ncl.ucar.edu/Document/Functions/Built-in/fft2db.shtml> (coef)          ; SYNTHESIS
>>>
>>>   end do
>>>
>>> Please do not use this if you do not know how to use 2D FFT output.
>>> ncl-talk can not become your programmer.
>>>
>>>  Again, as noted in the function documentation, a readable introduction to 2D-FFT is at:
>>>  *http://www.dspguide.com/pdfbook.htm* <http://www.dspguide.com/pdfbook.htm>
>>> ===
>>> As noted in the documentation, NCL uses*  FFTPACK5 <https://www2.cisl.ucar.edu/resources/legacy/fft5> *developed by Paul Swarztrauber and Richard Valent.
>>> The specific Fortran subroutines used are:
>>> *      fft2df:
>>>        http://www2.cisl.ucar.edu/resources/legacy/fft5/documentation#rfft2f.html <http://www2.cisl.ucar.edu/resources/legacy/fft5/documentation#rfft2f.html>
>>>
>>>        fft2db:
>>>        http://www2.cisl.ucar.edu/resources/legacy/fft5/documentation#rfft2b.html <http://www2.cisl.ucar.edu/resources/legacy/fft5/documentation#rfft2b.html>
>>> *
>>>
>>>
>>> On Fri, Feb 22, 2019 at 8:06 AM Soma Roy <somaroy892 at gmail.com> wrote:
>>>
>>>> If "X" is the data then how can we use it?
>>>>
>>>> X (ntime, nlat, nlon).
>>>>
>>>> Output result matrix should be same as X.
>>>>
>>>> Soma
>>>>
>>>>
>>>> On Fri, Feb 22, 2019, 20:24 Dennis Shea <shea at ucar.edu wrote:
>>>>
>>>>> Please look at NCL's function documentation
>>>>>
>>>>>
>>>>> *http://www.ncl.ucar.edu/Document/Functions/Built-in/fft2df.shtml
>>>>> <http://www.ncl.ucar.edu/Document/Functions/Built-in/fft2df.shtml>
>>>>> <http://goog_952811495>*
>>>>> *http://www.ncl.ucar.edu/Document/Functions/Built-in/fft2db.shtml*
>>>>> <http://www.ncl.ucar.edu/Document/Functions/Built-in/fft2db.shtml>
>>>>>
>>>>> You will have to loop over each time step.
>>>>>
>>>>>
>>>>>
>>>>> On Fri, Feb 22, 2019 at 12:09 AM Soma Roy <somaroy892 at gmail.com>
>>>>> wrote:
>>>>>
>>>>>> Hello,
>>>>>> I have a time series data (ntime, nlat, nlon) in spatial domain. I
>>>>>> want to calculate fourier decomposition of the same over lat lon.
>>>>>> How to do it using ncl? Is there any function available for the above?
>>>>>>
>>>>>> Kindly inform.
>>>>>>
>>>>>> Thank you,
>>>>>> Soma
>>>>>> _______________________________________________
>>>>>> ncl-talk mailing list
>>>>>> ncl-talk at ucar.edu
>>>>>> List instructions, subscriber options, unsubscribe:
>>>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>>>>
>>>>> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190222/2862eb58/attachment.html>


More information about the ncl-talk mailing list