[ncl-talk] a classic (slow) Fourier transform function
Md. Jalal Uddin
dmjalal90 at gmail.com
Mon Sep 9 04:02:39 MDT 2019
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190909/092475dd/attachment.html>
More information about the ncl-talk
mailing list