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

Dennis Shea shea at ucar.edu
Sat Jun 10 07:30:42 MDT 2017


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/20170610/d7baed66/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: filters_8.ncl
Type: application/octet-stream
Size: 6712 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170610/d7baed66/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: filters_2_soi.ncl
Type: application/octet-stream
Size: 3200 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170610/d7baed66/attachment-0001.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: soi.nc.gz
Type: application/x-gzip
Size: 60026 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170610/d7baed66/attachment.gz 


More information about the ncl-talk mailing list