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

  1. 例一:从netCDF文件中读入一个变量,取15S到15N之间的所有纬度的平均值,在“时间”维度上应用用户指定的过滤器,并创建一个彩色Hovmueller图。
; ================================ ; filters_1.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 ("chi200_ud_smooth.nc", "r") 
scale = 1.e6                                          ; create scale factor 
tmp = f->CHI                                          ; get chi 
tmp = tmp/scale                                       ; scale for convenience 
;============================== ; filter over time dimension ;========================= 
wgt = (/1., 3., 5., 6., 5., 3., 1./)                  ; weights 
wgt = wgt/sum(wgt)                                    ; normalize wgts 
yhov = wgt_runave (tmp(lon|:,time|:), wgt, 0)         ; compute running ave 
yhov!0 = "lon"                                        ; name dimensions 
yhov!1 = "time" 
;======== ; return variable to original dimension order for plotting ;=============================== 
chov = yhov(time|:,lon|:)                             ; move to 2D array for plot 
chov&time = tmp&time                                  ; set coordinate 
chov&lon = tmp&lon 
copy_VarAtts(tmp,chov)                                ; copy attributes 
;============================== ; create plot ;===================================== 
wks = gsn_open_wks ("png", "filters" )                ; send graphics to PNG file 
res = True                                            ; Plot mods desire 
res@tiMainString = "Pacific Region"                   ; title 
res@trYReverse = True                                 ; reverse y axis 
res@cnLevelSelectionMode = "ManualLevels"             ; manually set contour levels 
res@cnMinLevelValF = -10.                             ; min level 
res@cnMaxLevelValF = 10.                              ; max level 
res@cnLevelSpacingF = 2.                              ; contour interval 
res@cnFillOn = True                                   ; turn on color fill 
res@cnFillPalette = "BlWhRe"                          ; set color map 
res@cnLinesOn = False                                 ; turn off contour lines 
res@tmYLMode = "Explicit"                             ; Define own tick mark labels. 
res@tmYLValues = (/ 0. , 30., 61., 89., 120., 150. /) 
res@tmYLLabels = (/"DEC","JAN","FEB","MAR" ,"APR","MAY" /) 
plot = gsn_csm_hov(wks, chov(:,{100:220}), res) 
end 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值