爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 5847|回复: 3

NCL利用lanczos带通滤波器官网例子3疑问

[复制链接]

新浪微博达人勋

发表于 2022-3-8 17:10:16 | 显示全部楼层 |阅读模式
3金钱
请教各位大神!利用NCL官网滤波程序例子3:[size=13.3333px]filters_3.ncl: Band pass filters via filwgts_lanczos对一个范围的风场进行带通滤波,提示维度不匹配,应该怎么解决呢?程序如下:
[size=13.3333px]; ****************************** ; filters_3.ncl ; ************************************ ;
[size=13.3333px]; These files are loaded by default in NCL V6.2.0 and newer ;

[size=13.3333px]load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" ;
[size=13.3333px]load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" ;
[size=13.3333px]load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
[size=13.3333px]begin
[size=13.3333px]

[size=13.3333px] vName = "uwnd"                    ; name of variable on the file
[size=13.3333px]fili = "/home/u/uwnd.850.1979-2020.nc"
[size=13.3333px]f = addfile(fili, "r")
[size=13.3333px]x = f->uwnd(:,{850},{0:65},{100:180})
[size=13.3333px]; ******************** ; create the filter weights and apply ; *************************
[size=13.3333px]ihp = 2                                         ; band pass
[size=13.3333px]sigma = 1.0                                     ; Lanczos sigma
[size=13.3333px]nWgt = 21                                     ; loose 100 each end
[size=13.3333px]fca = 1./60.                                   ; start freq
[size=13.3333px]fcb = 1./30.                                    ; last freq
[size=13.3333px]wgt = filwgts_lanczos (nWgt, ihp, fca, fcb, sigma )
[size=13.3333px]printVarSummary(wgt)
[size=13.3333px]xBPF    = wgt_runave_n ( x, wgt, 0, 0 )      ; 30-60 day
[size=13.3333px]printVarSummary(xBPF)
[size=13.3333px]; ******************* ; create new date array for use on the plot ; *********************
[size=13.3333px]date = cd_calendar(x&time,-2)                   ; yyyymmdd
[size=13.3333px]yrfrac = yyyymmdd_to_yyyyfrac (date, 0)
[size=13.3333px]delete(yrfrac@long_name)
[size=13.3333px]delete(x@long_name)
[size=13.3333px]pStrt = 19790101                                ; 4 years: winter 96-97 MJO gold standard
[size=13.3333px]pLast = 20201231
[size=13.3333px]iStrt = ind(date.eq.pStrt)                      ; user specified dates
[size=13.3333px]iLast = ind(date.eq.pLast)
[size=13.3333px]delete(date)
[size=13.3333px]pltType = "png"                                 ; send graphics to PNG file
[size=13.3333px]pltName = "filters"
[size=13.3333px]plot = new ( 2, "graphic")
[size=13.3333px]wks = gsn_open_wks (pltType,pltName)
[size=13.3333px]res = True                                      ; plot mods desired
[size=13.3333px]res@gsnDraw = False                             ; don't draw
[size=13.3333px]res@gsnFrame = False                            ; don't advance frame yet
[size=13.3333px]res@vpHeightF = 0.4                             ; change aspect ratio of plot
[size=13.3333px]res@vpWidthF = 0.8
[size=13.3333px]res@vpXF = 0.1                                  ; start plot at x ndc coord
[size=13.3333px]res@gsnYRefLine = 0.0                           ; create a reference line
[size=13.3333px]res@gsnCenterString = "Anomaly U [0:65 100:180]"
[size=13.3333px]res@tmXBFormat = "f"
[size=13.3333px]

[size=13.3333px]plot(0) = gsn_csm_xy (wks,yrfrac(iStrt:iLast),x(iStrt:iLast),res)
[size=13.3333px]res@gsnCenterString = "Band Pass Filtered: 30-60 day"
[size=13.3333px]plot(1) = gsn_csm_xy (wks,yrfrac(iStrt:iLast),xBPF(iStrt:iLast),res)
[size=13.3333px]resP = True
[size=13.3333px]resP@gsnMaximize = True
[size=13.3333px]gsn_panel(wks,plot,(/2,1/),resP)                ; Create XY plot of frequency versus response
[size=13.3333px]xyres = True
[size=13.3333px]xyres@gsnMaximize = True
[size=13.3333px]xyres@gsnFrame = False
[size=13.3333px]xyres@tiMainString = "Band Pass: 30-60 srate=1: sigma = " + sigma
[size=13.3333px]xyres@tiXAxisString = "frequency"
[size=13.3333px]xyres@tiYAxisString = "response"
[size=13.3333px]xyres@gsnLeftString = "fca=" + fca + "; fcb=" + fcb
[size=13.3333px]xyres@gsnRightString = nWgt
[size=13.3333px]xyres@trXMaxF = 0.1
[size=13.3333px]xyres@trYMaxF = 1.1
[size=13.3333px]xyres@trYMinF = -0.1
[size=13.3333px]plot = gsn_csm_xy(wks, wgt@freq, wgt@resp, xyres)
[size=13.3333px]X = (/0.0, fca, fca, fcb, fcb, 0.1/) ; ideal filter
[size=13.3333px]Y = (/0.0, 0.0, 1.0, 1.0, 0.0, 0.0 /)
[size=13.3333px]resGs = True
[size=13.3333px]resGs@gsLineThicknessF = 1.0
[size=13.3333px]gsn_polyline(wks,plot,X,Y,resGs)
[size=13.3333px]frame(wks)
[size=13.3333px]end


报错

报错

报错位置

报错位置
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2023-9-26 11:33:22 | 显示全部楼层
您好,可以请问下您的数据“uwnd.850.1979-2020.nc”是在哪里下载的吗?或者是否方便分享下该数据,查找官网例子,一直在找“uwnd.day.850.anomalies.1980-2005.nc”这个数据,但是一直没找到。。
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

发表于 2023-9-28 13:37:46 | 显示全部楼层
小羊趴在云朵上 发表于 2023-9-26 11:33
您好,可以请问下您的数据“uwnd.850.1979-2020.nc”是在哪里下载的吗?或者是否方便分享下该数据,查找官 ...

直接ncep下载下来每一年的数据合并下就行啦
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

发表于 2023-9-29 10:48:12 | 显示全部楼层
wsx 发表于 2023-9-28 13:37
直接ncep下载下来每一年的数据合并下就行啦

这样子呀,谢谢你告诉我这些
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表