请选择 进入手机版 | 继续访问电脑版
爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 8093|回复: 8

[其他] 将grd数据转为nc文件的难题

[复制链接]

新浪微博达人勋

发表于 2015-12-2 19:23:07 | 显示全部楼层 |阅读模式

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

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

x
grd转nc:我现在用ctl2ncl.rb将ctl文件转成了ncl脚本文件,官网说根据这个ncl脚本可以生成对应的nc文件,请问怎么生成?
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-12-5 14:18:36 | 显示全部楼层
怎么回事呀?楼主怎么解决的
密码修改失败请联系微信:mofangbao
回复 支持 1 反对 0

使用道具 举报

新浪微博达人勋

 成长值: 19710
发表于 2015-12-2 21:35:31 | 显示全部楼层
都能用NCL读了,输出netcdf文件还会困难吗。。。
http://www.ncl.ucar.edu/Applications/grads.shtml#examples
参考例子2
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2015-12-3 08:48:16 | 显示全部楼层
兰溪之水 发表于 2015-12-2 21:35
都能用NCL读了,输出netcdf文件还会困难吗。。。
http://www.ncl.ucar.edu/Applications/grads.shtml#exam ...

不好意思,我已经知道怎么回事了,谢谢
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-3-6 10:38:21 | 显示全部楼层
兰溪之水 发表于 2015-12-2 21:35
都能用NCL读了,输出netcdf文件还会困难吗。。。
http://www.ncl.ucar.edu/Applications/grads.shtml#exam ...

你好,我看了这个脚本,我想问一下
;  Grads control file
; ---------------
; dset snow.grd
; title snow depth  winter
; options sequential big_endian
; undef -9999.00               
; xdef 29 linear 20. 5.
; ydef 8 linear 35.  5.
; zdef 1 linear 1 1
; tdef 60 linear jan1936 1yr
; vars 1
; p 0 0 precipitation
; endvars
; ---------------

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-12-5 19:31:16 | 显示全部楼层
cdo可以转呀
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-12-7 22:17:21 | 显示全部楼层
咋回事啊!
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

发表于 2016-12-9 17:06:38 | 显示全部楼层
CDO可以转 很简单
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-1-21 17:08:07 | 显示全部楼层

请问cdo怎么转化
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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