[ncl-talk] Fourier decompose

Soma Roy somaroy892 at gmail.com
Tue Feb 26 10:14:36 MST 2019


Hello,
What will be the size of "x" in the below line when I have 135 lon. and 129
lat. as in the input dataset?

  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")

Kindly inform me.

Soma


On Mon, Feb 25, 2019, 23:18 Soma Roy <somaroy892 at gmail.com wrote:

> So if we use fft2df, spatial extent will be reduced in output matrix?
> I can save coef., split coef. into real and imaginary part..but that is
> not the issue I am looking for.
>
> Kindly inform me.
>
> Soma
>
>
>
> On Mon, Feb 25, 2019, 14:26 Soma Roy <somaroy892 at gmail.com wrote:
>
>> As per the below;
>>
>>  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
>>
>> We can see that longitude is reduced from 8 to 5..
>>
>> Can we place time dimension on that place keeping latxlon as total grid points in the 2 nd dimension?
>>
>> Otherwise at the time of spatial plot, no.of grids will be short due to the reduction along longitude.
>>
>> Kindly inform me about the above issue.
>>
>> Let me know if I am thinking wrong in it.
>>
>>
>> Thanking you,
>>
>> Soma
>>
>>
>>
>>
>> On Sat, Feb 23, 2019, 04:02 Gus Correa <gus at ldeo.columbia.edu wrote:
>>
>>> Just follow the very clear script outline that Dennis sent to you.
>>> And where he wrote:
>>>
>>> >> ; do something with coef *<== *YOUR* responsibility*
>>>
>>> take responsibility and do it.
>>> Maybe, create a 4D array of dimensions (time, 2, k_lon, k_lat), (or if
>>> you prefer (2,time,k_lon,k_lat) ),
>>> where k_lon, k_lat are the corresponding wavenumber index dimension
>>> sizes, and for each time record,
>>> save the output of fft2df in the corresponding (time, :, :, :) array
>>> section/slice.
>>> You may want to read the fft2df documentation to understand what you're
>>> doing, and create the array
>>> to store what the function returns (complex numbers, separated in real
>>> and imaginary parts) with the correct size:
>>>
>>> http://www.ncl.ucar.edu/Document/Functions/Built-in/fft2df.shtml
>>>
>>> On Fri, Feb 22, 2019 at 3:37 PM Soma Roy <somaroy892 at gmail.com> wrote:
>>>
>>>> Then how can I proceed?
>>>> Please give me a hint..
>>>>
>>>> Soma
>>>>
>>>> On Sat, Feb 23, 2019, 00:47 Gus Correa <gus at ldeo.columbia.edu wrote:
>>>>
>>>>> 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
>>>>>>
>>>>> _______________________________________________
>>>>> 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/20190226/31ff736c/attachment.html>


More information about the ncl-talk mailing list