Re: how to keep the beginning and ending information after band filtering?

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Tue, 25 Aug 2009 12:17:39 -0600

My suggestion: detrend, then taper

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"

xx = x(lev|:,lat|:,lon|:,time|:) ; convenience

xdtrend = dtrend(xx,False) ; detrend
xtaper = taper(xdtrend, 0.1, 0) ; taper

printMinMax(xx, True)
printMinMax(xdtrend, False)
printMinMax(xtaper, False)

cf = ezfftf (xtaper) ; 2 x lev x lat x lon x (ntim/2)
printVarSummary(cf)

fcf = fspan(0, 0.5, ntim/2)
ifcf = ind(fcf.lt.fca .or. fcf.gt.fcb)
cf(:,:,:,:,ifcf) = 0.0 ; set coef to zero
xfft = ezfftb (cf, cf_at_xbar)
copy_VarCoords(xx, xfft)

printVarSummary(xfft)
printMinMax(xfft, True)

======================
Note:
The taper reduces the amplitudes near the beginning and end
of the series input to the fft. The purpose is to make
the series periodic.

Also see: http://www.ncl.ucar.edu/Applications/filter.shtml

Xuguang Sun wrote:
> Dear everyone,
>
> I'd like to use the following code to do the band-pass filter,
>
> ;--------------------
> ; FFT filter (band filter) interannual...
> ;--------------------
> x = vara
> ntim = dimsizes(vara&time)
> fca = 1./(8.0*12) ; minimum freq 8-year, 8*12 months
> fcb = 1./13. ; maximum freq 13-month
> xtaper = taper(x(lev|:,lat|:,lon|:,time|:), 0.1, 0) ; taper
> xdtrend = dtrend(xtaper,False) ; detrend
> cf = ezfftf (xdtrend) ; sub period (2, ntim/2)
> fcf = fspan(0, 0.5, ntim/2)
> ifcf = ind(fcf.lt.fca .or. fcf.gt.fcb)
> cf(:,:,:,:,ifcf) = 0.0 ; set coef to zero
> xfft = ezfftb (cf, cf_at_xbar)
>
> After filtering, the magnitudes for the beginning and ending points are very low, and even not correct. I know there must be something unreal for those points due to FFT, but why and how the FFT method cause such kind of problem? and how to reduce the errors and keep the information?
>
> Thanks.
>
> Best regards,
> Xuguang
>
>
>
>
>
> ___________________________________________________________
> 好玩贺卡等你发,邮箱贺卡全新上线!
> http://card.mail.cn.yahoo.com/
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>

-- 
======================================================
Dennis J. Shea                  tel: 303-497-1361    |
P.O. Box 3000                   fax: 303-497-1333    |
Climate Analysis Section                             |
Climate & Global Dynamics Div.                       |
National Center for Atmospheric Research             |
Boulder, CO  80307                                   |
USA                        email: shea 'at' ucar.edu |
======================================================
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Aug 25 2009 - 12:17:39 MDT

This archive was generated by hypermail 2.2.0 : Wed Sep 02 2009 - 12:24:39 MDT