爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 12875|回复: 14

关于gsn_csm_pres_hgt函数的问题

[复制链接]

新浪微博达人勋

发表于 2015-9-2 19:57:05 | 显示全部楼层 |阅读模式

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

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

x
想做一个温度露点的差的剖面图,省略res,以下是代码

;********************************************
; tkd.ncl
;********************************************
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"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
begin

;---Open some netCDF files.
diri = "/home/tl/grib2/"   ; input directory
fils = systemfunc ("ls " + diri + "*.grib2" ) ; file paths
f    = addfiles (fils, "r")   
ListSetType (f, "join")       ; join
; print(f)
;---Read variables off the file and do some conversions.
tk     = f[:]->TMP_P0_L100_GLL0 (1,0:20,:,100)      ;各层温度(提取其中21层与相对湿度层数相匹配)
rh     = f[:]->RH_P0_L100_GLL0 (1,:,:,100)   ;各层相对湿度
td    = dewtemp_trh  (tk,rh)   ;计算露点温度
tkd   = tk-td - 273.15        ;温度路点差
printVarSummary(tkd)
wks   =  gsn_open_wks ("ps", "tkd" )
plot  =  gsn_csm_pres_hgt(wks,tkd,False )

end


报错信息如下:
Variable: tkd
Type: float
Total Size: 15204 bytes
            3801 values
Number of Dimensions: 2
Dimensions and sizes: [21] x [181]
Coordinates:
Number Of Attributes: 1
  _FillValue : 1e+20
(0) gsn_csm_pres_hgt: Fatal: The first dimension of the input data must
(0) have a coordinate variable called 'lev.'
(0) Cannot create plot.
fatal:Illegal right-hand side type for assignment
fatal:["Execute.c":8128]:Execute: Error occurred at or near line 32 in file td.



找了很久不知道是哪里出错了,可否有同学帮忙解答,非常感谢了
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2015-9-2 19:58:06 | 显示全部楼层
沙发先占了
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2015-9-2 21:12:20 | 显示全部楼层
这个函数在官网上有个注释没看懂是什么意思,需要最最左边的维度如何处理呢:
; note this data is already on pressure levels. If this were model data,
; it would be necessary to interpolate the data from hybrid coordinates
; to pressure levels.
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-9-3 07:07:05 | 显示全部楼层
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2015-9-3 17:14:09 | 显示全部楼层
自己已解决了     是通过计算以后,坐标需要重新定义和赋值  呵呵
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-9-5 20:20:37 | 显示全部楼层
gsn_csm_pres_hgt 需要高度层次lev的属性
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2015-9-5 20:52:47 | 显示全部楼层
hjwen 发表于 2015-9-5 20:20
gsn_csm_pres_hgt 需要高度层次lev的属性

恩,是的 ,谢谢回复,我已经解决了
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-10-18 15:22:34 | 显示全部楼层
一般情况下,t维度在z维度的左侧,要先把t维度和z维度位置互换
还有就是原始数据一经计算就把很多metadata丢掉了,需要自己再加回来
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-10-27 21:10:44 | 显示全部楼层
hnqx 发表于 2015-9-3 17:14
自己已解决了     是通过计算以后,坐标需要重新定义和赋值  呵呵

你好,我最近也在画这个height-time图,也遇到了相同的问题,请教一下您是怎样对坐标重新定义和赋值的,可否解答一下,谢谢
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-5-31 18:43:32 | 显示全部楼层
小晨薇 发表于 2015-10-27 21:10
你好,我最近也在画这个height-time图,也遇到了相同的问题,请教一下您是怎样对坐标重新定义和赋值的, ...

用matlab将数据写入nc文件,设置属性,主要是units
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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