[ncl-talk] question regarding Butterworth filter

Daniel Barandiaran dbarandiaran at gmail.com
Tue Jun 16 12:42:59 MDT 2015


Sorry for the postscript, but one more thing I looked at was the filter
response relative to bandwidth size, following the example

http://www.ncl.ucar.edu/Applications/Scripts/filters_9.ncl

and the filter response is fine at wide bandwidths. The filter is
narrow-band optimized in that its frequency response is tighter and with
smoother drop-off at the cut-off frequencies, even with narrow bandwidths,
but the filter performance is not hindered by having that frequency window
being wide.

On Tue, Jun 16, 2015 at 12:38 PM, Daniel Barandiaran <dbarandiaran at gmail.com
> wrote:

> Ok, I've done some more investigation and testing and here is what I found.
>
> First off, like filtering methods in general, the Butterworth filter was
> designed with electronic applications in mind, such as audio processing,
> and so the processed end of the series being processed with this filter
> attenuates to zero. In audio this is no big deal, but when looking at
> something like a climate time series this can be a problem.
>
> I talked with one of the professors in my department who knows quite a bit
> about numerical methods, and he suggested padding the end of the series
> with 1.5*(order of filter/fca) zeros.  I am attaching a figure with the
> resulting filtered time series, with and without padding.
>
> I tested this result with a variety of bandpass settings both narrow and
> wide, low pass and high pass, and with length of the time series, and the
> result is consistent. Without the zero padding, the signal attenuates to
> zero, but with the padding the filtered data follows the raw data.
>
> here is the relevant code for what I did:
>
> fca   = 1./48.
> fcb   = 1./1200.
> order = 6
>
> opt   = True
> opt at m = order
>
> npad  = tointeger(1.5*(order/fca))
>
> ;-----------------------
>
> fin   = addfile("/export1/Databank/NCEP_Month/surface/air.2m.mon.mean.nc
> ","r")
> time  = fin->time
> TIME  = cd_calendar(time,0)
> tind  = ind(TIME(:,0).ge.minyr .and. TIME(:,0).le.maxyr)
> ntind = dimsizes(tind)
> t2m   = dim_avg_n(fin->air(tind,{minlat:maxlat},{minlon:maxlon}),(/1,2/))
> do j  = 0,11
>    t2m(j::12) = dim_rmvmean_n(t2m(j::12),0)
> end do
>
> dum   = new(ntind+npad,"float")
> dum   = 0
> dum(0:ntind-1)  = t2m
> dumf  = bw_bandpass_filter(dum,fca,fcb,opt,0)
>
> t2mfpad     = dumf(0:ntind-1)
> t2mfnopad   = bw_bandpass_filter(t2m,fca,fcb,opt,0)
>
>
> On Mon, Jun 15, 2015 at 5:43 PM, Dave Allured - NOAA Affiliate <
> dave.allured at noaa.gov> wrote:
>
>> Danny,
>>
>> The documentation for this filter says that it is optimized for narrow
>> bandwidths.  The description goes on to mention certain shortcuts in its
>> calculations.  Your settings describe a low pass filter with a very wide
>> pass band, far to one end of the signals in your time series.  This is not
>> what is meant by "narrow bandwidth".
>>
>> This is just speculation, but I think your settings may be breaking key
>> assumptions within this filter's code implementation.  You may have chosen
>> a filter function that is badly matched to your particular problem.
>> Perhaps, look at some of the other available NCL functions.  HTH.
>>
>> --Dave
>>
>>
>> On Mon, Jun 15, 2015 at 11:51 AM, Daniel Barandiaran <
>> dbarandiaran at gmail.com> wrote:
>>
>>> Hi everyone,
>>>
>>> I was trying out the bw_bandpass_filter function and found some
>>> unexpected results. The gist of the problem is that the end of the time
>>> series being filtered approaches a smoothed zero, even if the time series
>>> is doing something else entirely (see attached figure, consider bold blue
>>> line and shaded blue area). I imagine this is due to the internal workings
>>> of the filter itself, but regardless of that, does anyone have any ideas on
>>> "fixing" this?
>>>
>>> Some details: I have fca set to 1/60., or 5 years, and fcb set
>>> arbitrarily large, i.e. 1/100000., so the filter essentially behaves as low
>>> pass. I am also making sure to not give the function any missing values.
>>>
>>> --
>>> Danny Barandiaran
>>> Ph.D. Candidate
>>> Department of Plants, Soils, and Climate
>>> Utah State University
>>>
>>
>
>
> --
> Danny Barandiaran
> Ph.D. Candidate
> Department of Plants, Soils, and Climate
> Utah State University
>
>
>


-- 
Danny Barandiaran
Ph.D. Candidate
Department of Plants, Soils, and Climate
Utah State University
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150616/f949ceac/attachment.html 


More information about the ncl-talk mailing list