爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 13858|回复: 15

[作图] 对于求月平均值calculate_monthl_values函数的报错问题

[复制链接]
发表于 2017-2-13 11:11:02 | 显示全部楼层 |阅读模式

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

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

x
希望将多个小时的wrfout数据的温度值来做平均,整个时间长度是一个月,即做一个月的平均温度,根据NCL官网找到calculate_monthly_valuies函数http://www.ncl.ucar.edu/Document ... onthly_values.shtml,根绝其中的example3:
diri    = "../"   fili    = systemfunc("cd "+diri+" ; ls ACCESS_SRF.*.nc")  ; all files beginning with 'ACCESS_SRF'   nfili   = dimsizes(fili)   print(fili)   varName = (/"snv" , "ts"/)   nName   = dimsizes(varName)   opt     = True   opt@nval_crit = 10              ; require at least 10 values   ndim    = 0   f = addfiles(diri+fili, "r")   ; read variables from all files   do nv=0,nName-1      print("")      print("-----------------------------------------------")      print("-----------  "+varName(nv)+"  -----------------")      print("-----------------------------------------------")      print("")      xhr := f[:]->$varName(nv)$           ; (time,lat,lon)       printVarSummary(xhr)      xdd := calculate_daily_values (xhr, "avg", ndim, opt)      printVarSummary(xdd)      xmm := calculate_monthly_values (xhr, "avg", ndim, opt)      printVarSummary(xmm)   end do

向各位大神指教2个问题
1.在语法上,:=(冒号+等号)什么意思,给一个数组赋值吗?
2.我将以上例子修改执行,但是报错
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/wrf/WRFUserARW.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"

    files=systemfunc("ls wrfout_d02_1995-01-*")
    theFile=addfiles(files, "r")
    varName=(/"T2"/)
    opt=True
    opt@nval_crit=10
    ndim=0

    xhr :=theFile[:]->$varName(0)$
    printVarSummary(xhr)

    xdd :=calculate_daily_values(xhr, "avg", ndim, opt)
    printVarSummary(xdd)

    xmm :=calculate_monthly_values(xhr, "avg", ndim, opt)
    printVarSummary(xmm)
程序报错如下:
fatal:Undefined identifier: (calculate_daily_values) is undefined, can't continue
fatal:["Execute.c":8575]:Execute: Error occurred at or near line 29 in file avg1.ncl

fatal:Variable (xdd) is undefined
fatal:["Execute.c":8575]:Execute: Error occurred at or near line 30 in file avg1.ncl

fatal:(time) is not a named dimension in variable (x).
fatal:["Execute.c":8575]:Execute: Error occurred at or near line 12875 in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl

fatal:["Execute.c":8575]:Execute: Error occurred at or near line 32 in file avg1.ncl

fatal:Variable (xmm) is undefined
fatal:["Execute.c":8575]:Execute: Error occurred at or near line 33 in file avg1.ncl

密码修改失败请联系微信:mofangbao
 楼主| 发表于 2017-2-13 11:13:13 | 显示全部楼层
fatal:Undefined identifier: (calculate_daily_values) is undefined, can't continue
这个函数还要先定义吗,该如何定义啊?
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2017-2-13 11:14:32 | 显示全部楼层
fatal:Variable (xdd) is undefined
变量不是也可以直接用吗,像xhr也没有先定义啊?
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2017-2-13 11:16:14 | 显示全部楼层
fatal:(time) is not a named dimension in variable (x).
整个脚本中就没有time和x这个两个变量啊,为什么说是一个没有命名的变量
密码修改失败请联系微信:mofangbao
发表于 2017-2-13 14:17:16 | 显示全部楼层
FrankieLJY 发表于 2017-2-13 11:16
fatal:(time) is not a named dimension in variable (x).
整个脚本中就没有time和x这个两个变量啊,为什 ...

wrfout是有专门的函数提取数据的
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2017-2-13 14:53:10 | 显示全部楼层
andrewsoong 发表于 2017-2-13 14:17
wrfout是有专门的函数提取数据的

您说的应该是wrf_user_getvar()吧,提取的方式可能有很多种,能指点一下我这个是怎么错的吗?
密码修改失败请联系微信:mofangbao
发表于 2017-2-14 11:33:16 | 显示全部楼层
本帖最后由 愛、星晴 于 2017-2-14 14:41 编辑

1. “:=” 就把它简单理解为 “=” 赋值就可以了,不用搞得太麻烦。

2.我看了这个函数,需要加载的库load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl",你也也没问题,为什么函数没调出来,我觉得可能是因为“Available in version 6.2.0 and later”,你的ncl版本可能不是6.2.0及以后的。
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2017-2-14 21:17:38 | 显示全部楼层
愛、星晴 发表于 2017-2-14 11:33
1. “:=” 就把它简单理解为 “=” 赋值就可以了,不用搞得太麻烦。

2.我看了这个函数,需要加载的库loa ...

您好 我的版本是6.3.0的,应该不是版本的问题。
我发现我处理的文件变量存在两个coordinate,如下,您知道这种情况是怎样去获取值的吗?!
Variable: times
Number of Dimensions: 3
Dimensions and sizes:        [XTIME | 1] x [south_north | 126] x [west_east | 147]
Coordinates:
            XTIME: [2850..2850] !!!!!!!!!!!!!!
Number Of Attributes: 6
  stagger :       
  description :        TEMP at 2 M
  MemoryOrder :        XY
  FieldType :        104
  coordinates :        XLAT XLONG !!!!!!!!!!!!!!
  units :        K
密码修改失败请联系微信:mofangbao
发表于 2017-2-14 21:29:58 | 显示全部楼层
FrankieLJY 发表于 2017-2-14 21:17
您好 我的版本是6.3.0的,应该不是版本的问题。
我发现我处理的文件变量存在两个coordinate,如下,您知 ...

时间变量一般都是一维的,像你这种三维的的我也是第一次看到,如果时间随经纬也发生变化的话处理起来真的是比较麻烦的
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2017-2-14 21:52:42 | 显示全部楼层
愛、星晴 发表于 2017-2-14 21:29
时间变量一般都是一维的,像你这种三维的的我也是第一次看到,如果时间随经纬也发生变化的话处理起来真的 ...

那个times是我随便取的名字 这个变量是2m的温度 但是现在这个变量中存在两个coordinate,我又点不明白,要是调用这个变量的话,该怎么调用呢
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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