[ncl-talk] ezfftf (NCL vs. Matlab)

Dennis Shea shea at ucar.edu
Wed Apr 15 11:25:22 MDT 2015


To add a bit more to Maria's response ....

===
I used NCL's ezfftf and cfftf to look at the simple Example 1.
Normalized and unnormalized coefficients plus periodogram values are
printed out.
Note that the 'cfftf' have twice the number of coef. They are normalized
via (1/N) while ezfftf values use (N/2).
Note that the periodogram values for cfftf coefficients are symmetric.

Good luck

On Wed, Apr 15, 2015 at 10:20 AM, Maria Gehne - NOAA Affiliate <
maria.gehne at noaa.gov> wrote:

> Hi Thomas,
>
> It is actually the imaginary part of the FFT in matlab that has opposite
> sign. If you compute example 1 on the NCL ezfftf page
> https://www.ncl.ucar.edu/Document/Functions/Built-in/ezfftf.shtml
> in Matlab you can see that. I attached a Matlab script that shows this.
>
> Unlike NCL Matlab returns the same number of coefficients as input data N
> ( NCL only returns half N/2). The first coefficient in the Matlab FFT is
> the sum of all elements, divide by N and you get the mean. The next N/2-1
> entries are the same as the N/2-1 last entries, except that they are
> complex conjugates. So depending on which direction you read from you will
> either get the same sign for the imaginary part as you get in NCL or the
> opposite.
>
> Also the magnitudes returned by Matlab are not the same automatically. You
> need to divide the results by N/2 to match the NCL result.
>
>
> Hope this helps,
> Maria
>
> On Tue, Apr 14, 2015 at 9:47 AM, Thomas Tobian <thomastobian at gmail.com>
> wrote:
>
>> Dear NCL developers,
>>
>> I recently worked a lot with Fourier analysis. Once, I compared the
>> results of forward fft function in ncl and matlab. Please find attached, an
>> example of FFT product for the meridional wind (V).  So in general, the
>> amplitudes and imaginary coefs produced by NCL and MATLAB are the same but
>> the real part is of opposite sign. Any idea why? What is the process to use
>> for the complex parts in NCL to convert back to longitude projection ? is
>> there any big differences if the data has longitude -180 to 180 VS. 0-360?
>>
>> Cheers,
>> Thomas
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> 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/20150415/3cb5d62b/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tst_ezfft.ncl
Type: application/octet-stream
Size: 1385 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150415/3cb5d62b/attachment.obj 


More information about the ncl-talk mailing list