- 积分
- 15726
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2015-3-8
- 最后登录
- 1970-1-1
|
发表于 2016-3-6 10:38:21
|
显示全部楼层
你好,我看了这个脚本,我想问一下
; 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
谢谢您了,我找了半天也不知道哪错了 |
|