NCL滤波器学习(官网实例二代码分析)

阅读每月的南方涛动指数(只有达尔文市)

使用不同的过滤器长度(49[实线],121[虚线]),生成两个低通过滤器,(理想情况下)将消除24个月(2年)以内的波动。

使用不同的过滤器长度(121[实线],241[虚线]),生成两个低通过滤器,(理想情况下)将消除小于120个月(10年)的波动。

蓝色(49权)和红色(121权)曲线是为24个月的过滤器。在这种情况下,使用长得多的过滤器(121 vs 49)并不能获得很多。

此外,使用49点过滤器在末端返回更多的数据。

绿色(121权)和黑色(241权)曲线是用于120个月的过滤器。响应函数相差不大,因此,年代际曲线相差不大。

 

; ***************************** ; filters_2.ncl ; ************************************* ;
; These files are loaded by default in NCL V6.2.0 and newer ; 
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" ; 
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" ; 
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" 
; *********************************************** 
begin 
f = addfile ("./SOI.nc" , "r") 
dsoi = f->SOI_DARWIN 
ihp = 0                                         ; low_pass 
sigma = 1.0                                     ; Lanczos sigma 
nWgt = 49                                       ; loose 24 months each end 
fca = 1./24.                                    ; 2 years 
wgtq = filwgts_lanczos (nWgt, ihp, fca, -999., sigma ) 
nWgt = 121                                      ; loose 60 months each end 
fca = 1./24.                                    ; 2 years 
wgtr = filwgts_lanczos (nWgt, ihp, fca, -999., sigma ) 
nWgt = 121                                      ; loose 60 months each end 
fca = 1./120.                                   ; decadal 
wgts = filwgts_lanczos (nWgt, ihp, fca, -999., sigma ) 
nWgt = 241                                      ; loose 120 months each end 
fca = 1./120.                                   ; decadal 
wgtt = filwgts_lanczos (nWgt, ihp, fca, -999., sigma ) 
ntim = dimsizes( dsoi ) 
yPlot = new ( (/4,ntim/) , typeof(dsoi), getFillValue(dsoi) ) 
yPlot(0,:) = wgt_runave ( dsoi, wgtq, 0 ) ; 2 year 
yPlot(1,:) = wgt_runave ( dsoi, wgtr, 0 ) ; 2 year 
yPlot(2,:) = wgt_runave ( dsoi, wgts, 0 ) ; 10 year 
yPlot(3,:) = wgt_runave ( dsoi, wgtt, 0 ) ; 10 year 
; ****************** ; create new date array for use on the plot ; ******************* 
pltType = "png"                                 ; send graphics to PNG file 
pltName = "filters" 
date = f->time                                  ; yyyymm 
ntim = dimsizes(date) 
yrfrac = yyyymm_to_yyyyfrac (date, 0) 
delete(yrfrac@long_name) 
delete(dsoi@long_name) 
plot = new ( 2, "graphic") 
wks = gsn_open_wks (pltType,pltName) 
res = True                                      ; plot mods desired 
res@gsnDraw = False                             ; don't draw 
res@gsnFrame = False                            ; don't advance frame yet 
res@vpHeightF = 0.4                             ; change aspect ratio of plot 
res@vpWidthF = 0.8 
res@trYMinF = -3.0                              ; min value on y-axis 
res@trYMaxF = 3.0                               ; max value on y-axis 
res@trXMinF = 1860                              ; min value on x-axis 
res@trXMaxF = 2016                              ; max value on x-axis 
res@vpXF = 0.1                                  ; start plot at x ndc coord 
res@gsnYRefLine = 0.0                           ; create a reference line 
res@gsnCenterString = "Darwin Southern Oscillation Index" 
plot(0) = gsn_csm_xy (wks,yrfrac,dsoi,res) 
res@xyMonoDashPattern= True 
res@xyLineThicknessF = 2 
res@xyLineColors = (/ "blue", "red", "green", "black" /) 
res@gsnCenterString = "Low Pass Filtered: 2-year and 10-year" 
plot(1) = gsn_csm_xy (wks,yrfrac,yPlot,res) 
resP = True 
resP@gsnMaximize = True 
gsn_panel(wks,plot,(/2,1/),resP) 
end 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值