Re: band pass filter via FFT [Was: could you help me!]

From: Dennis Shea (shea AT XXXXXX)
Date: Mon Apr 19 2004 - 10:04:49 MDT


>
>hi!:
>i used the fft ncl function to make a band-filter
>my ncl file is written as follows:
>*******************************************
> cf = new((/2,92/),float)
> cf(:,:) = ezfftf(raave0(i,:))
> cf(:,0:9)=0
> cf(:,17:91)=0
>; cf(:,0:2)=0
> rano_band(i,:) = ezfftb(cf,cf@xbar)
>*********************************************
> the length of the time series is 184 day, i want to extract 10-20 signals.
> do you think my ncl file is right?
> but the result is unbelievable. because rano_band is more bigger than the
raave0,
> i don't know why?
> could you help me?

Mechanically speaking, it should work. However,

[1] By abruptly setting the boundaries to 0.0, you are subject to
    Gibb's phenomena when creating the reconstructed series.
    
[2] More important ... and I speculate that this is why you question
    the results: the reconstructed series looks bad at the
    beginning and end of the series.

    Consider the 'classic' case of a filter [here a band-passed filter]
    where one passes a, say, 51-point filter over a series. EG:
    a filter like that created by
          http://ngwww.ucar.edu/ngdoc/ng/ref/ncl/functions/filwgts.html

    In this case, the first and last 25 points are set to missing.
    This is because the filter does not affect the end points.
    
    Often people think that they can use an FFT, set the appropriate
    coefficients to 0.0 and then create a series of just the
    desired frequencies. Better than the classic approach, you
    get the beginning and end pts!!! Eureka!!! :-)
    
    NOPE!! :-(
    
    The FFT does create values for (say) the first and last 25 pts
    but they are bogus. You can't get something for nothing!!!
    
[3] I suggest you create a classic filter using the "filwgts_lancos"
    function, then visually look at the series created
    by each method (ie overlaying each series on a plot).
    
    Then you can use the
>****************************>
; no need to do this => cf = new((/2,92/),float)
> cf = ezfftf(raave0(i,:))
> cf(:,0:9)=0
> cf(:,17:91)=0
> rano_band(i,:) = ezfftb(cf,cf@xbar) ; or: rano_band(i,:) = ezfftb(cf, 0.0)

Then set the bogus beginning and end pts to _FillValue. So if the
are M bogus pts and N pts in the series:

    rano_band(i,0:M-1) = raave0@_FillValue
    rano_band(i,N-M:N-1) = raave0@_FillValue
=========

You do not need to preallocate space for values returned by NCL functions.

No need/want to use:
   cf = new((/2,92/),float)
   cf(:,:) = ezfftf(raave0(i,:))
   
The above will result in slightly slower execution speeds. Just use
   cf = ezfftf(raave0(i,:))

good luck

[P.S. Please use better "Subject" titles that better reflect the issue.
      THX]

_______________________________________________
ncl-talk mailing list
ncl-talk AT ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk



This archive was generated by hypermail 2b29 : Thu Apr 22 2004 - 07:40:12 MDT