[ncl-talk] How to obtain low pass gaussian filter in ncl?

Dennis Shea shea at ucar.edu
Sun Jun 11 21:36:15 MDT 2017


Oops!

The two filters_{2,8}.ncl scripts I attached to the previous response had a
'type-o' in both scripts. You mentioned a 9-year low-pass filter.

 fca   = 1./(9*12)                                        ; 9-year     ;
<<<===  This is the correct setting.

------
[snip]
  if (ihp.eq.0) then
      nwgt  = (/ 73,  97, 121, 151, 175 /)      ; test # of wgts
      bStrt = 5.
      fca   = 1./(9*12)                                    ;
9-year            <==== This is correct setting
      bLast = -999.                                        ; not used
      fcb   = -999.
;      pltName = pltName + ".LowPass."+bStrt
  end if
[snip]
---------------------
See attached ...

In an offline email, you asked about 'optimal filter for your research'. I
am not a filter expert.
For me it is typically trial and error process. The goodness of a filter is
best based on visual inspection of the results.
See filter_2.png

To me, the 97-point Lanczos weights look reasonable (See attached). You
don't gain that much by using more weights. You 'lose'  4-years at each
end. See: filter_8_1.png
---------------------
A number of papers use the Lanczos filter: For example, the following  uses
a Lanczos filter

Zhou and Lau: http://onlinelibrary.wiley.com/doi/10.1002/joc.700/pdf

Also:
Kosaka and Xie: http://www.nature.com/nature/journal/v501/n7467/full/
nature12534.html
See comments on figures 5 and 7


Good Luck





On Sat, Jun 10, 2017 at 7:30 AM, Dennis Shea <shea at ucar.edu> wrote:

> I would suggest the Lanczos filter:
>    https://www.ncl.ucar.edu/Document/Functions/Built-in/filwgts
> _lanczos.shtml
>
> See also:
>    https://www.ncl.ucar.edu/Applications/filter.shtml
>
> ---
> Attached are two scripts that were modified from the above URL.
>
> (a) filters_8.ncl:  This illustrates the response functions for specified
> numbers of weights and sigma factors
>
> (b) filters_2_soi.ncl:  An application to a time series of the Southern
> Oscillation Index (SOI).
>
> ---
> The filter does 'lose; data at the beginning and end.
>
> =======================
> Your script should look like:
>
>  a = addfile(“sst.nc”,”r”)
>  sst = a->sst  ;;  [time | 1920] x [lat | 90] x [lon | 180]
>
>  ihp = 0
>  sigma = 1.0
>  fca = 1.0/(9*12)
>  nwt     = ... your choice ...
>
> Wgts = filwgts_lanczos (nwt, ihp, fca, -999., sigma )
>
> end_pts = 0
>  sst_filter = wgt_runave_n_Wrap(sst, Wgts, end_pts, 0)
>  printVarSummary(sst_filter)
>
> ========================
>
> wgt_runave_n does not require the data to be reordered.
>
> end_pts: how to handle 'end' values: 0 or 1 ... not -1.
> 0 ... lose data at ends
> 1 ... reflective end values but may not be appropriate
>
> Good luck
>
>
>
>
>
>
>
>
>
>
> On Fri, Jun 9, 2017 at 11:49 AM, Zhang, Wei <wei.zhang at rsmas.miami.edu>
> wrote:
>
>> Hi all,
>>
>> I have a monthly SST dataset, how can I obtain a 9-year low pass gaussian
>> filtered SST in ncl. I think the Gaussian function *filwgts_normal* could
>> work and my code is as below. Is it correct? If not, how can I deal with
>> that?
>>
>>  a = addfile(“sst.nc”,”r”)
>>  sst = a->sst  ;;  [time | 1920] x [lat | 90] x [lon | 180]
>>  sigma = 1.0
>>  nwt = 9*12 ;; 9 year
>>  Wgts = filwgts_normal(nwt, sigma, 0) ; gaussian weight.
>>  sst_filter = wgt_runave_Wrap(sst(lat|:,lon|:,time|:),Wgts,0)       ;
>> 108 points running average
>>
>> I greatly appreciate it if anyone could help. Thanks.
>>
>> -------------------------------------
>> Wei Zhang
>> Ph.D student
>> University of Miami, Rosenstiel School of Marine and Atmospheric Science
>> Department of Atmospheric Sciences
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> 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/20170611/97108b23/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: filters_2_soi.ncl
Type: application/octet-stream
Size: 3010 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170611/97108b23/attachment-0002.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: filters_2.png
Type: image/png
Size: 201589 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170611/97108b23/attachment-0003.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: filters_8.ncl
Type: application/octet-stream
Size: 6733 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170611/97108b23/attachment-0003.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: filters_8_1.png
Type: image/png
Size: 62696 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170611/97108b23/attachment-0004.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: filters_8_2.png
Type: image/png
Size: 63940 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170611/97108b23/attachment-0005.png 


More information about the ncl-talk mailing list