爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 25004|回复: 26

[作图] 求助:NCL运行滤波脚本出错

[复制链接]

新浪微博达人勋

发表于 2014-5-2 19:11:17 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
我现在要对olr资料滤波,olr资料用的是日平均的olr.day.mean.nc,学姐给了我一个滤波的脚本,我在windows系统上操作,运行出来一直显示第10行有错误,请求各位大大帮我看一下问题出在哪里了,十分感谢。
滤波脚本如下:
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
   diri    = "/cygdrive/D/MJO/"
   vName   = "olr"        ; name of variable on the file
   fili    = "olr.day.mean.nc"
   f       = addfile(diri+fili, "r")
   x       =short2flt( f->$vName$(:,:,:));直接利用所给资料滤波,始末时间未变
printVarSummary(x)
;nlat=f->olr&lat
;nlon=f->olr&lon
;ntime=f->olr&time
;anom = x ;(lat|:,lon|:,time|:)                 ; trick to copy cv's and atts
;   anom = dim_rmvmean(x(lat|:,lon|:,time|:))
;printVarSummary(anom)
; ***********************************************
; create the filter weights and apply
; ***********************************************
   ihp     = 2                             ; band pass
   sigma   = 1.0                           ; Lanczos sigma
   nWgt    = 201                          ; loose 100 each end                           
   fca     = 1./80.                       ; start freq
   fcb     = 1./20.                        ; last  freq
   wgt     = filwgts_lanczos (nWgt, ihp, fca, fcb, sigma )


   xBPF =wgt_runave ( x(lat|:,lon|:,time|:), wgt, 0 )  ; 20-80 day
xBPF!0="lat"
xBPF!1="lon"
   xBPF!2="time"
xBPF&lat=x&lat
xBPF&lon=x&lon
xBPF&time=x&time
; ***********************************************
; create new date array for use on the plot
; ***********************************************
   date    = cd_calendar(x&time,-2)        ; yyyymmdd
   yrfrac  = yyyymmdd_to_yyyyfrac (date, 0)
   delete(yrfrac@long_name)
   delete(x@long_name)
   pStrt = 19800101      ; 画图所用4 years: winter 96-97 MJO gold standard
   pLast = 19811231
   iStrt = ind(date.eq.pStrt)        ; user specified dates
   iLast = ind(date.eq.pLast)
   delete(date)

   pltType = "ps"
   pltName = "filters"
   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@vpXF         = 0.1             ; start plot at x ndc coord
   res@gsnYRefLine  = 0.0             ; create a reference line   
   
   res@gsnCenterString = "Anomaly olr [0, 120E]"
plot(0) = gsn_csm_xy (wks,yrfrac(iStrt:iLast),x(iStrt:iLast,{0},{120}),res)      
   
   res@gsnCenterString  = "Band Pass Filtered: 20-80 day"     
plot(1) = gsn_csm_xy (wks,yrfrac(iStrt:iLast),xBPF({0},{120},iStrt:iLast),res)     
   
   resP                 = True   
   resP@gsnMaximize     = True
   gsn_panel(wks,plot,(/2,1/),resP)
fout=addfile("filolr.nc","c")
filedimdef(fout,"time",-1,True)
fout->olrfil=xBPF(time|: ,lat|:,lon|:)
end

QQ截图20140502140401.png
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2014-10-11 10:48:20 | 显示全部楼层
找到这五个参数的解释了:http://www.ncl.ucar.edu/Document ... lwgts_lanczos.shtml
密码修改失败请联系微信:mofangbao
回复 支持 1 反对 0

使用道具 举报

新浪微博达人勋

发表于 2014-5-2 21:38:25 | 显示全部楼层
你注意一下,错误提示里面有个nclmalloc failed,分配内存失败了。这跟你用cygwin和32bit ncl有关,数据超过2GB了。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2014-5-2 22:31:55 | 显示全部楼层
longlivehj 发表于 2014-5-2 21:38
你注意一下,错误提示里面有个nclmalloc failed,分配内存失败了。这跟你用cygwin和32bit ncl有关,数据超 ...

所以我不能在windows上通过cygwin操作ncl,而是要在linux系统上用?
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2014-5-3 11:00:54 来自手机 | 显示全部楼层
可不可以只读局部区域数据?现在你做的是全球的。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2014-5-4 11:34:40 | 显示全部楼层
longlivehj 发表于 2014-5-3 11:00
可不可以只读局部区域数据?现在你做的是全球的。

谢谢你啊,的确是内存的问题,换个window 8系统的版本就能运行出来了
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2014-10-11 10:25:12 | 显示全部楼层
请问LZ,
  ihp     = 2                             ; band pass
   sigma   = 1.0                           ; Lanczos sigma
   nWgt    = 201                          ; loose 100 each end   
这三个参数在做滤波时是不是不用改变了,只需要改变fca和fcb?

在ncl官网上看到(http://www.ncl.ucar.edu/Applications/Scripts/filters_3.ncl)也是这样,这个三个参数的设置和所用的数据有没有什么关联?
非常感谢
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-3-16 11:55:04 | 显示全部楼层
楼主, xBPF =wgt_runave ( x(lat|:,lon|:,time|:), wgt, 0 )  ; 20-80 day
xBPF!0="lat"
xBPF!1="lon"
   xBPF!2="time"
xBPF&lat=x&lat
xBPF&lon=x&lon
xBPF&time=x&time
这句什么意思啊?
xBPF是滤波后的数据吧,为什么要把原始数据在赋值给xBPF呢?
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2015-3-16 13:56:56 | 显示全部楼层
philo~world 发表于 2015-3-16 11:55
楼主, xBPF =wgt_runave ( x(lat|:,lon|:,time|:), wgt, 0 )  ; 20-80 day
xBPF!0="lat"
xBPF!1="lon"

是把原始数据的经纬度信息赋给xBPF
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-3-17 10:15:06 | 显示全部楼层
xiaocaoqiqiao 发表于 2015-3-16 13:56
是把原始数据的经纬度信息赋给xBPF

唉?可是这样会不会改变xBPF的值呢?
xBPF&lat=x&lat
xBPF&lon=x&lon
xBPF&time=x&time
我感觉这是赋值语句。。。。除了把经纬度信息给了xBPF,x的数据信息不会也给了xBPF么?
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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