[ncl-talk] a classic (slow) Fourier transform function

Md. Jalal Uddin dmjalal90 at gmail.com
Mon Sep 9 21:51:40 MDT 2019


Thank you, sir. The problem of a and b is solved. Now, I am facing
difficulty for making a new array for f and output.

do n=0,N-1
   do k=0,KMAX-1
        f(k,n) = a(k)*cos(k*n*temp2)+ b(k)*sin(k*n*temp2)
   end do
   output(n)=(sum(f(0,n)))      ; 0 used for Fourier Decomposition (wave
number 1)
   return([/output/])
end do

On Mon, 9 Sep 2019 at 23:12, Dennis Shea <shea at ucar.edu> wrote:

> [1] You should put 'print' statements in your code when testing.
>
> [2] You did not initialize the a(k) and b(k) values for each 'k'
>
> [3]
> f = new((/ k,t /), typeof(in),getVarFillValue(in))
>
> the 'k' and 't' are index values for the previous do loops. They are not
> dimension sizes.
>
> ---
> Attached is an old test code that should help you.
> It produces results from '*ezfftf*
> <https://www.ncl.ucar.edu/Document/Functions/Built-in/ezfftf.shtml>'
> You can comment the fortran section.
> Please note, it is **your responsibility** to think about what is is being
> done.
>
> Please talk to a local person is knows the  Fourier Transform
>
> On Mon, Sep 9, 2019 at 4:02 AM Md. Jalal Uddin via ncl-talk <
> ncl-talk at ucar.edu> wrote:
>
>> Hi all,
>>
>> The following Fourier Transformation Function gives me constant 0 value.
>> Is there anyone who can guide me to solve this issue?
>>
>> undef ("fftwavenumber")
>> function fftwavenumber (in[*]:numeric)
>>
>> local in,p,a,b,f,output
>>
>> begin
>>     N=dimsizes(in)
>>
>>    if mod(N,2).eq.0 then
>>          p=N/2     ; N even
>>    else
>>          p=(N-1)/2 ; N odd
>>    end if
>>
>> pi=3.1416
>>
>> a = new((/ p /), typeof(in),getVarFillValue(in))
>> b = new((/ p /), typeof(in),getVarFillValue(in))
>>
>> do k=0,p-1
>>   do t=0,N-1
>>       a(k) = (2/N)*( in(t)*cos(2*pi*k*t/N) )
>>       b(k) = (2/N)*( in(t)*sin(2*pi*k*t/N) )
>>   end do
>> end do
>>
>> f = new((/ k,t /), typeof(in),getVarFillValue(in))
>> output = new((/ t /), typeof(in),getVarFillValue(in))
>>
>> do t=0,N-1
>>    do k=0,p-1
>>         f(k,t) = a(k)*cos(2*pi*k*t/N)+ b(k)*sin(2*pi*k*t/N)
>>    end do
>>    output(t)=(sum(f(0,t)))  ; 0 used for Fourier Decomposition (wave
>> number 1)
>>    return(output)
>> end do
>> end
>>
>>
>> --
>> *Md. Jalal Uddin*
>> MSc in Applied Meteorology
>> Nanjing University of Information, Science and Technology, China
>> B.Sc. in Disaster Management (Hons.)
>> Patuakhali Science and Technology University, Bangladesh.
>> Cell: +8613260859092, +8801792052662
>> Web: www.dmjalal90.weebly.com
>> Facebook: jalal.hossen.39
>> LinkedIn: https://bd.linkedin.com/in/md-jalal-uddin-80a026b0
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>

-- 
*Md. Jalal Uddin*
MSc in Applied Meteorology
Nanjing University of Information, Science and Technology, China
B.Sc. in Disaster Management (Hons.)
Patuakhali Science and Technology University, Bangladesh.
Cell: +8613260859092, +8801792052662
Web: www.dmjalal90.weebly.com
Facebook: jalal.hossen.39
LinkedIn: https://bd.linkedin.com/in/md-jalal-uddin-80a026b0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190910/a6d9fc4e/attachment.html>


More information about the ncl-talk mailing list