爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 13032|回复: 5

[分享资料] 不同scale_factor及add_offset的多变量NC资料描述文件

[复制链接]

新浪微博达人勋

发表于 2016-12-8 09:44:18 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 shirlyqiu 于 2016-12-9 11:50 编辑

最近用了ECMWF的reanalysis数据,为了方便一口气下了十几个变量,由于变量名自带小数点,grads识别不了,就写了个ctl(如下)来画图。
ctl:
dset …/surface_water_flux.nc
title surface water flux
undef -32767
options yrev
dtype netcdf
xdef 144 linear 0 2.5
ydef 73 linear -90 2.5
zdef 1 linear 0 1
tdef 416 linear 00Z01JAN1982 1mo
vars 15
p55.162=>p55 0 t,y,x Vertical integral of water vapour
p56.162=>p56 0 t,y,x Vertical integral of cloud liquid water
p57.162=>p57 0 t,y,x Vertical integral of cloud frozen water
p71.162=>p71 0 t,y,x Vertical integral of eastward water vapour flux
p72.162=>p72 0 t,y,x Vertical integral of northward water vapour flux
p79.162=>p79 0 t,y,x Vertical integral of divergence of cloud liquid water flux
p80.162=>p80 0 t,y,x Vertical integral of divergence of cloud frozen water flux
p84.162=>p84 0 t,y,x Vertical integral of divergence of moisture flux
p88.162=>p88 0 t,y,x Vertical integral of eastward cloud liquid water flux
p89.162=>p89 0 t,y,x Vertical integral of northward cloud liquid water flux
p90.162=>p90 0 t,y,x Vertical integral of eastward cloud frozen water flux
p91.162=>p91 0 t,y,x Vertical integral of northward cloud frozen water flux
tcw=>tcw 0 t,y,x Total column water
tcwv=>tcwv 0 t,y,x Total column water vapour
tclw=>tclw 0 t,y,x Total column liquid water
endvars
结果画出来图不对,用nc文件中可画图的tcw变量对比了一下,发现每个变量都有不同的scale_factor和add_offset。然后找到@river关于nc的描述文件帖nc资料(即NetCDF和HDF类的资料) 的描述文件-----升级版(可直接使用open命令),还是不知道怎么处理多变量的不同scale_factor和add_offset参数,在论坛里没找到相同的问题,然后我还试了下自己处理变量“真实数据=原始数据*scale_factor+add_offset”结果误差还是蛮大,就自己去发了个提问帖,石沉大海…

急性子的我只好用最笨的办法又把每个变量单独下一个nc文件,每个nc文件分别写ctl,就可以写详细的unpack信息,这样做是完全没问题的,这是解决方法一

我在river的帖子下留言,river提示我有其他童鞋有类似的情况,那位童鞋建议不写具体的scale_factor和add_offset,ctl如下:
dset …/surface_water_flux.nc
title surface water flux
undef -32767
unpack scale_factor add_offset
options yrev
dtype netcdf
xdef 144 linear 0 2.5
ydef 73 linear -90 2.5
zdef 1 linear 0 1
tdef 416 linear 00Z01JAN1982 1mo
vars 15
p55.162=>p55 0 t,y,x Vertical integral of water vapour
p56.162=>p56 0 t,y,x Vertical integral of cloud liquid water
p57.162=>p57 0 t,y,x Vertical integral of cloud frozen water
p71.162=>p71 0 t,y,x Vertical integral of eastward water vapour flux
p72.162=>p72 0 t,y,x Vertical integral of northward water vapour flux
p79.162=>p79 0 t,y,x Vertical integral of divergence of cloud liquid water flux
p80.162=>p80 0 t,y,x Vertical integral of divergence of cloud frozen water flux
p84.162=>p84 0 t,y,x Vertical integral of divergence of moisture flux
p88.162=>p88 0 t,y,x Vertical integral of eastward cloud liquid water flux
p89.162=>p89 0 t,y,x Vertical integral of northward cloud liquid water flux
p90.162=>p90 0 t,y,x Vertical integral of eastward cloud frozen water flux
p91.162=>p91 0 t,y,x Vertical integral of northward cloud frozen water flux
tcw=>tcw 0 t,y,x Total column water
tcwv=>tcwv 0 t,y,x Total column water vapour
tclw=>tclw 0 t,y,x Total column liquid water
endvars

然后运行grads时提示add_offset按默认赋值为0.0(这种情况下scale_factor可能是对的),画出来的图偏差比较大,感觉不能用这种方法来处理。


然后river又提供了一种思路,即在多变量情况下,要画某一变量时,给ctl提供该变量的具体unpack信息,譬如要画tcw变量时,直接给ctl的unpack项附上tcw变量的scale_factor和add_offset值,这样也能画出正确的tcw变量图,这是解决方法二


总而言之,这两种方法都不是很方便,仅供需要的童鞋参考(木有附图,有需要的童鞋自己找个数据试试吧)。在此特别感谢river的帮助。科研不易,且行且珍惜。

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

新浪微博达人勋

发表于 2016-12-8 11:30:54 | 显示全部楼层
{:eb502:}{:eb502:}
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

发表于 2017-7-6 21:58:16 | 显示全部楼层
学习一下,我加了偏移因子暂时也没有解决
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2019-9-4 13:49:52 | 显示全部楼层
衷心感谢。通过此贴,收获很大。
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2021-4-23 15:36:16 | 显示全部楼层
有scale factor的变量需要用short2flt函数转换,不需要自行计算
  f    = addfile("air.2m.gauss.1979.nc" , "r")
  t2m  = short2flt( f->air )

参见ncl官网

http://www.ncl.ucar.edu/Document/Functions/Contributed/short2flt.shtml
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2023-9-6 20:03:57 | 显示全部楼层
非常感谢!
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

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

本版积分规则

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

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

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