爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 23063|回复: 12

[其他] NCL读取nc文件简单问题求教

[复制链接]

新浪微博达人勋

发表于 2011-11-30 20:05:39 | 显示全部楼层 |阅读模式

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

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

x
大侠们好:
我才开始学NCL,有一个简单问题想请教大家,大家帮我看看错在哪里吧,谢谢啊。
经过WRF之后,得到了很多output,比如wrfout_d03*这类的,但是他们没有自带后缀。
我就用NCL最简单的命令去读取这些东西,script如下:

begin

   f = addfile("/nuwa_cluster/home/rcecstu03/RunLiu/WRF/run/PRD/wrfout_d03_2008-11-01_01:00:00.nc","r")
  T = f->T
   printVarSummary(T)

end
这样是可以的,会显示如下:Variable: T
Type: float
Total Size: 1154736 bytes
            288684 values
Number of Dimensions: 4
Dimensions and sizes:   [Time | 1] x [bottom_top | 27] x [south_north | 99] x [west_east | 108]
Coordinates:
Number Of Attributes: 6
  FieldType :   104
  MemoryOrder : XYZ
  description : perturbation potential temperature (theta-t0)
  units :       K
  stagger :
  coordinates : XLONG XLAT

然后我又进行修改,改成
begin

  diri = "/nuwa_cluster/home/rcecstu03/RunLiu/WRF/run/PRD/"
  fils = systemfunc ("ls " +diri+ "wrfout_d03_2008-11-01_1*.nc")
  f = addfiles(fils,"r")
   T = f->T
   printVarSummary(T)

end
结果就不行了。
错误如下:ls: /nuwa_cluster/home/rcecstu03/RunLiu/WRF/run/PRD/wrfout_d03_2008-11-01_1*.nc: No such file or directory
warning:Argument 0 of the current function or procedure was coerced to the appropriate type and thus will not change if the function or procedure modifies its value
fatal:(-2147483647) has no file extension, can't determine type of file to open
fatal:["NclVar.c":1376]:Assignment type mismatch, right hand side can't be coerced to type of left hand side
fatal:Execute: Error occurred at or near line 12 in file file.ncl

或者我把  fils = systemfunc ("ls " +diri+ "wrfout_d03_2008-11-01_1*.nc") 改成 fils = systemfunc ("ls " +diri+ "wrfout_d03_2008-11-01_1*") ,也不行,错误如下:
fatal:(/nuwa_cluster/home/rcecstu03/RunLiu/WRF/run/PRD/wrfout_d03_2008-11-01_19:00:00) has no file extension, can't determine type of file to open
fatal:(/nuwa_cluster/home/rcecstu03/RunLiu/WRF/run/PRD/wrfout_d03_2008-11-01_18:00:00) has no file extension, can't determine type of file to open
fatal:(/nuwa_cluster/home/rcecstu03/RunLiu/WRF/run/PRD/wrfout_d03_2008-11-01_17:00:00) has no file extension, can't determine type of file to open
fatal:(/nuwa_cluster/home/rcecstu03/RunLiu/WRF/run/PRD/wrfout_d03_2008-11-01_16:00:00) has no file extension, can't determine type of file to open
fatal:(/nuwa_cluster/home/rcecstu03/RunLiu/WRF/run/PRD/wrfout_d03_2008-11-01_15:00:00) has no file extension, can't determine type of file to open
fatal:(/nuwa_cluster/home/rcecstu03/RunLiu/WRF/run/PRD/wrfout_d03_2008-11-01_14:00:00) has no file extension, can't determine type of file to open
fatal:(/nuwa_cluster/home/rcecstu03/RunLiu/WRF/run/PRD/wrfout_d03_2008-11-01_13:00:00) has no file extension, can't determine type of file to open
fatal:(/nuwa_cluster/home/rcecstu03/RunLiu/WRF/run/PRD/wrfout_d03_2008-11-01_12:00:00) has no file extension, can't determine type of file to open
fatal:(/nuwa_cluster/home/rcecstu03/RunLiu/WRF/run/PRD/wrfout_d03_2008-11-01_11:00:00) has no file extension, can't determine type of file to open
fatal:(/nuwa_cluster/home/rcecstu03/RunLiu/WRF/run/PRD/wrfout_d03_2008-11-01_10:00:00) has no file extension, can't determine type of file to open
fatal:(f) does not reference a file
fatal:Execute: Error occurred at or near line 13 in file file.ncl

我要怎么办呢?那些文件加上后缀说没有该文件,不加后缀又说没有扩展名,我究竟如何解决这个问题呢?
谢谢你们啊。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2012-12-4 14:42:33 | 显示全部楼层

T = n[:]->T
就这个冒号~加了才行
密码修改失败请联系微信:mofangbao
回复 支持 1 反对 0

使用道具 举报

新浪微博达人勋

 成长值: 0
发表于 2011-11-30 21:33:15 | 显示全部楼层
好吧,看起来有点儿复制,深深也不懂
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 成长值: 19710
发表于 2011-12-1 00:26:08 | 显示全部楼层
①把你的wrfout文件后面都加上.nc,然后
fils = systemfunc ("ls /nuwa_cluster/home/rcecstu03/RunLiu/WRF/run/PRD/wrfout*.nc")
   f    = addfiles (fils, "r")  
或者
②循环读取处理
fs = systemfunc("ls /nuwa_cluster/home/rcecstu03/RunLiu/WRF/run/PRD/wrfout*00")
  nfs= dimsizes(fs)  
  do ifs=0,nfs-1
    f= addfile
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 成长值: 19710
发表于 2011-12-1 00:26:35 | 显示全部楼层
①把你的wrfout文件后面都加上.nc,然后
fils = systemfunc ("ls /nuwa_cluster/home/rcecstu03/RunLiu/WRF/run/PRD/wrfout*.nc")
   f    = addfiles (fils, "r")  
或者
②循环读取处理
fs = systemfunc("ls /nuwa_cluster/home/rcecstu03/RunLiu/WRF/run/PRD/wrfout*00")
  nfs= dimsizes(fs)  
  do ifs=0,nfs-1
    f= addfile(fs(ifs)+".nc","r")
  end do

评分

参与人数 2金钱 +15 收起 理由
妞胖胖 + 10 真的谢谢兰溪
mofangbao + 5 这么晚该睡觉了。。。

查看全部评分

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

新浪微博达人勋

 楼主| 发表于 2011-12-1 09:28:39 | 显示全部楼层
兰溪之水 发表于 2011-12-1 00:26
①把你的wrfout文件后面都加上.nc,然后
fils = systemfunc ("ls /nuwa_cluster/home/rcecstu03/RunLiu/W ...

谢谢兰溪。我按照你的第一个方法做了,加上了.nc之后,会有另外的一个提示:(f)does not prefer to a file,后来我又修改了一下,就可以了。
diri = "/nuwa_cluster/home/rcecstu03/RunLiu/WRF/run/PRD/"
   fils = systemfunc("ls "+diri+"wrfout_d03_2008-11-01_0*") + ".nc"
   print(fils)
   n = addfiles(fils,"r")
   T = n[:]->T
   printVarSummary(T)
这样就可以了。不用把wrfout都加上nc了。
谢谢你啊,大半夜的给我解答疑惑。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 成长值: 19710
发表于 2011-12-1 09:35:19 | 显示全部楼层
妞胖胖 发表于 2011-12-1 09:28
谢谢兰溪。我按照你的第一个方法做了,加上了.nc之后,会有另外的一个提示:(f)does not prefer to a fil ...

哦,解决就好~
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2011-12-1 10:13:51 | 显示全部楼层
兰溪之水 发表于 2011-12-1 09:35
哦,解决就好~

{:2_25:}哈哈,谢谢。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-8-22 18:16:39 | 显示全部楼层
蓝溪之水。。。大神啊!
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-11-7 20:39:26 | 显示全部楼层
{:5_213:}{:5_213:}{:5_213:}
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

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

本版积分规则

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

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

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