爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 14361|回复: 16

[其他] NCL作图的一个简单且奇怪的问题

[复制链接]
发表于 2017-3-28 22:37:24 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 FrankieLJY 于 2017-3-29 10:14 编辑

我wrf输出数据是每小时一个输出,然后每天生成一个文件!
将一个月的30个文件用 cdo mergetime iFile wrfout1 生成一个合并的文件,时间维有720个小时!
之后再用   cdo timmean wrfout1 wrfout2 生成720个小时的平均值文件(我的理解应该是所有变量的数值都被平均了),最后确实所有值都只剩平均值,包括时间(如附件)!

想用平均值文件晚wrfout_2010_01.nc文件做一个温度的图出来,代码如下:
begin
    a=addfile("./wrfout_2010_01.nc", "r")
    type="pdf"
    wks=gsn_open_wks(type, "tempreture")
    res=True
    res@MainTitle = "Essay Plot"
    pltres=True
    mpres=True
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    mpres@mpDataBaseVersion           = "Ncarg4_1"
    mpres@mpDataSetName               = "Earth..4"
    ;mpres@mpGeophysicalLineColor      = "Black"
    ;mpres@mpGridLineColor             = "Black"      ;latitudes and longitudes.
    ;mpres@mpLimbLineColor             = "Black"
    mpres@mpNationalLineColor         = "Black"
    ;mpres@mpPerimLineColor            = "Black"
    mpres@mpUSStateLineColor          = "Black"
    mpres@mpOutlineBoundarySets       = "AllBoundaries"
;;;;;;;;;;;;;;;;;;;;;;;;
    t =wrf_user_getvar(a, "T2", 0)

    tc=t-273.16
    tc@description="Surface Temperature"
    tc@units="c"
    opts=res
    opts@cnFillOn=True
    opts@ContourParameters=(/-20.,20.,2./)
    opts@gsnSpreadColorEnd=-3
    contour_tc=wrf_contour(a, wks, tc, opts)        
    delete(opts)

    plot=wrf_map_overlays(a, wks, (/contour_tc/), pltres, mpres) ;;;43行就是这一行
    ;map=gsn_contour_map(wks, counter_tc, mpres)
end

我觉得我的代码应该是没有问题的,但是在运行中总是报如下错误:
fatal:Number of subscripts do not match number of dimensions of variable, (3) subscripts used, (2) subscripts expected
fatal:["Execute.c":8575]:Execute: Error occurred at or near line 4527 in file $NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl

fatal:["Execute.c":8575]:Execute: Error occurred at or near line 4619 in file $NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl

fatal:["Execute.c":8575]:Execute: Error occurred at or near line 4702 in file $NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl

fatal:["Execute.c":8575]:Execute: Error occurred at or near line 43 in file tempreture.ncl
希望能有大神解答一下,实在是很困惑。
我尝试了用这个代码去跑wrf输出的数据是没有问题的,我不知道错在了哪一步?
1.png
密码修改失败请联系微信:mofangbao
发表于 2017-3-28 22:46:02 | 显示全部楼层
这有什么奇怪, 时间维在里面呗  contour_tc=wrf_contour(a, wks, tc, opts)  改为 contour_tc=wrf_contour(a, wks, tc(0,:,:), opts)
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2017-3-28 23:01:27 | 显示全部楼层
本帖最后由 FrankieLJY 于 2017-3-28 23:22 编辑
freekiller 发表于 2017-3-28 22:46
这有什么奇怪, 时间维在里面呗  contour_tc=wrf_contour(a, wks, tc, opts)  改为 contour_tc=wrf_contour ...

你好,我按照这个方式改了之后,依旧出现问题:
Number of subscripts do not match number of dimensions of variable,(3) Subscripts used, (2) Subscripts expected
fatal:["Execute.c":8575]:Execute: Error occurred at or near line 40 in file tempreture.ncl
密码修改失败请联系微信:mofangbao
发表于 2017-3-29 07:17:31 | 显示全部楼层
时间维数设置了,高度维数还要设置
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2017-3-29 08:53:13 | 显示全部楼层
1649518749 发表于 2017-3-29 07:17
时间维数设置了,高度维数还要设置

你好,我的数据就是三维的啊,时间维数已经设置了是0,t=wrf_user_getvar(a,"T2",0),就只剩下维度和经度了,怎么会有高度呢?
密码修改失败请联系微信:mofangbao
发表于 2017-3-29 10:35:09 | 显示全部楼层
FrankieLJY 发表于 2017-3-29 08:53
你好,我的数据就是三维的啊,时间维数已经设置了是0,t=wrf_user_getvar(a,"T2",0),就只剩下维度和经度 ...

怎么我运行你的源脚本没问题啊
2017-03-28 19-37-37 的屏幕截图.png
2017-03-28 19-37-37 的屏幕截图.png
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2017-3-29 11:33:31 | 显示全部楼层
1649518749 发表于 2017-3-29 10:35
怎么我运行你的源脚本没问题啊

我的wrf输出数据是每小时一个输出,然后每天生成一个文件!
将一个月的30个文件用 cdo mergetime iFile wrfout1 生成一个合并的文件,时间维有720个小时!
之后再用   cdo timmean wrfout1 wrfout2 生成720个小时的平均值文件(我的理解应该是所有变量的数值都被平均了),最后确实所有值都只剩平均值,包括时间(如附件)!

以上是我数据的处理过程,我是对数据处理过,因为我有31个文件,请问大神,用ncl可以有什么方式合并数据然后求平均值吗?
密码修改失败请联系微信:mofangbao
发表于 2017-3-29 12:59:56 | 显示全部楼层
FrankieLJY 发表于 2017-3-29 11:33
我的wrf输出数据是每小时一个输出,然后每天生成一个文件!
将一个月的30个文件用 cdo mergetime iFile  ...

请问mergetime函数用法呢,我没找到呢。如果只是求时间平这些资料类型一样直接用timmean wrfout* wrfout2就行,
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2017-3-29 14:14:41 | 显示全部楼层
1649518749 发表于 2017-3-29 12:59
请问mergetime函数用法呢,我没找到呢。如果只是求时间平这些资料类型一样直接用timmean wrfout* wrfout2 ...

你好,用户手册上是这样的 “Merges all timesteps of all input files sorted by date and time. All input files need to have the same structure with the same variables on different timesteps. After this operation every input timestep is in ofile and all timesteps are sorted by date and time.”
我尝试了你的方法,直接用cdo timmean wrfout* 对多个文件是不行的,它只支持一个输入文件
密码修改失败请联系微信:mofangbao
发表于 2017-4-2 11:59:21 | 显示全部楼层
请问一下,你的ncl作图是需要自己创个文件 写脚本吗 我能不能直接运行ncl wrfout.2006.06.12,nc 这样的,还是说我必须自己要写一个脚本吗?
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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