爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

【已解决】grd用cdo转成nc格式,但是grd有pdef参数

[复制链接]
 楼主| 发表于 2016-1-28 11:01:03 | 显示全部楼层
东风急流 发表于 2016-1-27 09:18
楼主,看了这个帖子有些困惑。
1、如果你的原始数据是1度乘以1度的,为什么ctl不直接写成
xdef  180 line ...

1. 我后来用的ctl就是改成
xdef  180 linear   1  1.
ydef  170 linear   1  1.
我改了ctl,是为了用cdo转成nc,比较方便。所以没有试过grads画图
2. 我一直不大理解
pdef 180 170 lcc 24.000 106.000 91.500 86.500 44.00000 4.00000 106.00000 45000.000 45000.000
这句话每个参数的意思,你能帮我解答一下吗?这个是模式转出来的,是王自发老师的NAQPMS模式
密码修改失败请联系微信:mofangbao
发表于 2016-1-28 11:04:40 | 显示全部楼层
心如止水的饭团 发表于 2016-1-28 11:01
1. 我后来用的ctl就是改成
xdef  180 linear   1  1.
ydef  170 linear   1  1.

我也是刚弄明白发了个帖子~
http://bbs.06climate.com/forum.p ... mp;page=1#pid606878
大家交流下
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2016-1-28 15:33:59 | 显示全部楼层
东风急流 发表于 2016-1-28 11:04
我也是刚弄明白发了个帖子~
http://bbs.06climate.com/forum.php?mod=viewthread&tid=41836&page=1#pid6 ...

突然想起来,我有用改过的ctl用grads画图的,主要是拿来和ncl画的图对比,两者之间没有差异
而ncl画图需要设置,下面这三个参数。我发现不管是在哪一块地区,那三个数字都是固定的,这是我一直没有搞明白的事情。
res@mpLambertParallel1F = 25
res@mpLambertParallel2F = 24
res@mpLambertMeridianF  = 106
密码修改失败请联系微信:mofangbao
发表于 2016-3-6 10:51:36 | 显示全部楼层
心如止水的饭团 发表于 2015-9-15 14:43
输入    cdo -f nc import_binary inputfile.ctl outputfile.nc   
inputfile.ctl 是你需要转格式的grd  ...

-sh: cdo: command not found
我用这个命令结果。。。
这个cdo 不是ncl自带的吗?是还要安装什么吗
密码修改失败请联系微信:mofangbao
发表于 2016-3-6 15:53:22 | 显示全部楼层
subtropical 发表于 2016-3-6 10:51
-sh: cdo: command not found
我用这个命令结果。。。
这个cdo 不是ncl自带的吗?是还要安装什么吗

cdo不是ncl自带的  是另外一个软件
密码修改失败请联系微信:mofangbao
发表于 2016-3-6 16:25:38 | 显示全部楼层
xiaocaoqiqiao 发表于 2016-3-6 15:53
cdo不是ncl自带的  是另外一个软件

哦,没用过。。。我在将grd转nc,结果老提示一个错误,可不可以麻烦你帮忙看下
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"
begin
   
   PLOT  = True
  NC    = True

  diri  = "./"
   fili  = "snow.grd"                      ; DSET
   fName = diri+fili      

  nlat  = 8                               ; YDEF
   mlon  = 29                              ; XDEF

  year  = 1936                            ; TDEF
   ntim  = 60                              ; time steps
   nmos  = 12
                                           ; not required
   time  = new (ntim, float  ,"No_FillValue") ; generate a "time" variable
   date  = new (ntim, integer,"No_FillValue") ; generate a "date" variable
   
   n     = -1
   do nmo=1,nmos
      YRM= year*10000 + nmo*100
      ndm= days_in_month(year, nmo)  
     do ndy=1,ndm  
        n = n+1
        time(n) = n     
        date(n) = YRM + ndy                ; YYYYMMDD
     end do
   end do
   time!0         = "time"
   time@long_name = "time"
   time@units     = "???"           ; "yyyy.fraction_of_year"
   time&time      = time

  date!0         = "time"
   date@long_name = "date"
   date@units     = "??????"
   date&time      = time
                                           ; generate lat/lon
   lon = ispan(0,mlon-1,1)*5. + 20.
   lon!0 = "lon"
   lon@long_name = "longitude"
   lon@units     = "degrees_east"

  lat = ispan(0,nlat-1,1)*5. +  5.
   lat!0 = "lat"
   lat@long_name = "latitude"
   lat@units     = "degrees_north"

倒数第四行lat = ispan(0,nlat-1,1)*5. + 35.吧?因为ctl描述文件是从35开始的。。
然后我自己用自己写的的grd资料带进去发现有错,想请教兰溪大神指教一下
1.这是ctl 文件
dset h:\twentyc\uchunelnino.grd
options sequential
title uwnd
undef -9.99e+08
xdef  180 linear   0.0 2.0
ydef  91  linear -90.0 2.0
zdef    1  linear   850 1
tdef 29 linear Mar1878 1yr
vars 1
uwnd    1 99 37 zonal wind[m/s]
endvars
2.脚本
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"
begin
   
   PLOT  = True
  NC    = True

  diri  = "H:/twentyc/"
   fili  = "uchunelnino.grd"                      ; DSET
   fName = diri+fili      

  nlat  = 91                               ; YDEF
   mlon  = 180                              ; XDEF

  year  = 1878                            ; TDEF
   ntim  = 29                              ; time steps
   nmos  = 1
                                           ; not required
   time  = new (ntim, float  ,"No_FillValue") ; generate a "time" variable
;date  = new (ntim, integer,"No_FillValue") ; generate a "date" variable
   
   n     = -1
   do nmo=1,nmos
      YRM= year*10000 + nmo*100
      ;ndm= days_in_month(year, nmo)  
     ;do ndy=1,ndm  
       ;n = n+1
        ;time(n) = n     
        ;date(n) = YRM + ndy                ; YYYYMMDD
     ;end do
   end do
   time!0         = "time"
   time@long_name = "time"
   time@units     = "yr"           ; "yyyy.fraction_of_year"
   time&time      = time

  date!0         = "time"
   date@long_name = "date"
   date@units     = "dy"
   date&time      = time
                                           ; generate lat/lon
   lon = ispan(0,mlon-1,1)*2. + 0.
   lon!0 = "lon"
   lon@long_name = "longitude"
   lon@units     = "degrees_east"

  lat = ispan(0,nlat-1,1)*2. -90.
   lat!0 = "lat"
   lat@long_name = "latitude"
   lat@units     = "degrees_north"

                                           ; create an array to contain data
   UNDEF = -9.99e+08                           ; UNDEF
   x     = new ( (/ntim,nlat,mlon/), float, UNDEF)
   x!0   = "time"
   x!1   = "lat"
   x!2   = "lon"
   x&time=  time
   x&lat =  lat
   x&lon =  lon

  x@long_name = "u wind"         ; VARS
   x@units     = "m/s"                 
               
   setfileoption("bin","ReadByteOrder","BigEndian")
                                           ; read each record: store in x
   do nt=0,ntim-1                         ; the ::-1 changes the latitude order
      x(nt,:,:) = fbinrecread(fName, nt, (/nlat,mlon/), "float")
   end do
3,错误是脚本倒数第二行:
warning:fbinrecread: size specified is greater than record size, filling with missing values
fatal:fbinrecread: an error occurred reading the requested record. Something is wrong with the FORTRAN binary file.
fatal:["Execute.c":8578]:Execute: Error occurred at or near line 86 in file grd2nc.ncl
谢谢您了,我找了半天也不知道哪错了
密码修改失败请联系微信:mofangbao
发表于 2016-3-6 16:52:55 | 显示全部楼层
subtropical 发表于 2016-3-6 16:25
哦,没用过。。。我在将grd转nc,结果老提示一个错误,可不可以麻烦你帮忙看下
load "$NCARG_ROOT/lib/nc ...

太复杂了,看不下去了。如果是我用NCL读grd的话我一般这样:
1.png
2.png
3.png
密码修改失败请联系微信:mofangbao
发表于 2016-3-6 17:01:32 | 显示全部楼层
xiaocaoqiqiao 发表于 2016-3-6 16:52
太复杂了,看不下去了。如果是我用NCL读grd的话我一般这样:

谢谢您,我的脚本是在ncl官网上下的,我会借鉴你的,谢谢
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2016-3-10 10:00:42 | 显示全部楼层
subtropical 发表于 2016-3-6 17:01
谢谢您,我的脚本是在ncl官网上下的,我会借鉴你的,谢谢

楼上师姐很棒哦,我默默的还是推荐你用cdo。如果是大型机上面有自带的,如果是自己的虚拟机,可能装起来有点麻烦
密码修改失败请联系微信:mofangbao
发表于 2016-3-10 16:06:20 | 显示全部楼层
心如止水的饭团 发表于 2016-3-10 10:00
楼上师姐很棒哦,我默默的还是推荐你用cdo。如果是大型机上面有自带的,如果是自己的虚拟机,可能装起来 ...

谢谢您哦
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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