爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 5244|回复: 2

[作图] NCL如何读取动态的变量名

[复制链接]

新浪微博达人勋

发表于 2018-7-28 09:30:49 | 显示全部楼层 |阅读模式

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

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

x
假设varname=(“humidity”,“temperature”),我知道可以写成比如:var =data ->humidity,但是如果我写成var =data ->varname[0]就报错,请问是需要加什么符号吗?

密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2018-7-30 09:34:56 | 显示全部楼层
可能是var =data ->$varname(0)$
密码修改失败请联系微信:mofangbao
回复 支持 1 反对 0

使用道具 举报

新浪微博达人勋

发表于 2018-7-30 09:35:21 | 显示全部楼层
http://www.ncl.ucar.edu/Document ... les.shtml#StringRef

String references
Sometimes it is impossible to know the names of the attributes and coordinates before writing a script, or these names may vary from variable to variable. To solve this problem, string variables can be used to reference attributes and coordinates by enclosing the variable reference within dollar signs '$'. The following are examples of this:
        dimnames = (/"frtime","lat","lon"/)
        attnames = (/"_FillValue", "long_name"/)

;
; access to attribute
;       
        att0 = temperature@$attnames(0)$

;
; Example of referencing a coordinate variable
; without knowing the dimension name
;
        if(iscoord(dimnames(0))
                coord0 = temperature&$temperature!0$
        end if
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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