爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 8328|回复: 0

[作图] 无法获取坐标索引

[复制链接]
发表于 2020-4-12 19:28:24 | 显示全部楼层 |阅读模式

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

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

x
纯新手求各位前辈指点。
无法获取坐标索引,无法执行下标。这该怎样修改呢?报错如下。如图一
fatal:NclOneDValGetRangeIndex: Non-monotonic coordinate value being used, can't complete coordinate subscript
fatal:Could not obtain coordinate indexes, unable to perform subscript
fatal:["Execute.c":8640]:Execute: Error occurred at or near line 30 in file /cygdrive/d/jiaoben/fw_lai.ncl
这个脚本是老师给的,纯新手看不太懂。另外,如果我修改了原脚本中的东西后就会提示我第一行有错。如图二。

附上完整的脚本,如下:
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
begin
f=addfile("D:/shuju/lai3g.0.5d.198201-201112.globe.nc","r")
fn="lai3g.0.5d.198201-201112.globe.nc"
;f=addfile("D:/shuju/lai3g.0.5d.198201-201112.globe.nc","r")
;NW
lat_nw_0=30.
lat_nw_1=50.
lon_nw_0=73.
lon_nw_1=113.
;Xinjiang
lat_xj_0=35.
lat_xj_1=50.
lon_xj_0=75.
lon_xj_1=95.

lai=f->lai           ;1982-2011新疆
llat=f->lat;(:,{35:50},{73:123})           ;1982-2011新疆
llon=f->lon;(:,{35:50},{73:123})           ;1982-2011新疆
ttime=f->time
lai@missing_Value =-32767.
lai@__FillValue= lai@missing_Value
lai_nw=lai(:,{lat_nw_0:lat_nw_1},{lon_nw_0:lon_nw_1})
lai_xj=lai(:,{lat_xj_0:lat_xj_1},{lon_xj_0:lon_xj_1})
lai1=dim_avg_n_Wrap(lai,(/1,2/))
lai2=reshape(lai1,(/30,12/))
lai_t0=dim_avg_n_Wrap(lai2,1) ;30yr
lai_t1=dim_avg_n_Wrap(lai2(0:4,:),1) ;1982-1986
lai_t2=dim_avg_n_Wrap(lai2(5:29,:),1) ;1987-2011(第30行应该在这附近,可能有差错,不知道前三行该不该数)
dimL =dimsizes(lai)
nm   =dimL(0)
nlat =dimL(1)
nlon =dimL(2)
nyr  =nm/12
lai_gs=new((/nyr,5,nlat,nlon/),float,-32767.)
lai_jja=new((/nyr,3,nlat,nlon/),float,-32767.)
lai_yr =new((/nyr,12,nlat,nlon/),float,-32767.)
ms=4
me=8
;nprint(nyr)
do iy =0,nyr-1
strM=iy*12+ms
endM=iy*12+me
;printVarSummary(lai_gs(iy,0:4,:,:))
;printVarSummary(lai(strM:endM,:,:))
lai_gs(iy,0:4,:,:) = lai(strM:endM,:,:)
end do
ms=0
me=11
do iy =0,nyr-1
strM=iy*12+ms
endM=iy*12+me
lai_yr(iy,0:11,:,:) = lai(strM:endM,:,:)
end do
ms=5
me=7
do iy =0,nyr-1
strM=iy*12+ms
endM=iy*12+me
lai_gs(iy,0:2,:,:) = lai(strM:endM,:,:)
end do
lai_gs_yr =dim_avg_n(lai_gs,1)
lai_jja_yr=dim_avg_n(lai_jja,1)
lai_yr_yr =dim_avg_n(lai_yr,1)
;printVarSummary(lai_gs)
;printVarSummary(lai_gs_yr)
lai_gs_yr!0="year"
lai_gs_yr!1="lat"
lai_gs_yr!2="lon"
copy_VarCoords(lai_gs(:,0,:,:),lai_gs_yr(:,:,:))
copy_VarCoords(lai_gs_yr,lai_jja_yr)
copy_VarCoords(lai_gs_yr,lai_yr_yr)
lai_gs_yr_nw= lai_gs_yr(:,{lat_nw_0:lat_nw_1},{lon_nw_0:lon_nw_1})
lai_jja_yr_nw= lai_jja_yr(:,{lat_nw_0:lat_nw_1},{lon_nw_0:lon_nw_1})
lai_yr_yr_nw= lai_yr_yr(:,{lat_nw_0:lat_nw_1},{lon_nw_0:lon_nw_1})
lai_gs_yr_xj= lai_gs_yr(:,{lat_xj_0:lat_xj_1},{lon_xj_0:lon_xj_1})
lai_jja_yr_xj= lai_jja_yr(:,{lat_xj_0:lat_xj_1},{lon_xj_0:lon_xj_1})
lai_yr_yr_xj= lai_yr_yr(:,{lat_xj_0:lat_xj_1},{lon_xj_0:lon_xj_1})
dimNW=dimsizes(lai_gs_yr_nw)
dimXJ=dimsizes(lai_gs_yr_xj)
nlat_nw=dimNW(1)
nlon_nw=dimNW(2)
nlat_xj=dimXJ(1)
nlon_xj=dimXJ(2)
asciiwrite("lai_nw_1982-2011.dat",lai_yr_yr_nw)
asciiwrite("lai_nw_1982-2011_jja.dat",lai_jja_yr_nw)
asciiwrite("lai_xj_1982-2011.dat",lai_yr_yr_xj)
asciiwrite("lai_xj_1982-2011_jja.dat",lai_jja_yr_xj)
wgt=new((/nlat,nlon/),float)
;lai_nw_time =wgt_areaave2(;lai_yr_yr_nw,wgt,opt)
;lai_nw_gs_time =wgt_areaave2(;lai_yr_yr_nw,wgt,opt)
;lai_nw_time =wgt_areaave2(;lai_yr_yr_nw,wgt,opt)
;lai_nw_time =wgt_areaave2(;lai_yr_yr_nw,wgt,opt)
;lai_xj_time =wgt_areaave2(;lai_yr_yr_xj,wgt,opt)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;output
   outDIR="./"
   fout  = "lai_post.nc"
   system("rm -f "+outDIR+fout)
;f1 = systemfunc("ls icbc.nc")
   outf = addfile(outDIR+fout,"c")
   setfileoption(outf, "DefineMode", True)
    ;***********************************************
; assign file attributes
;***********************************************                     
    fAtt               = True                        
    fAtt@Conventions   = "None"                                       
;   fAtt@cell_methods  = "monthly mean"
;   fAtt@units         = "C"
;    fAtt@creation_date = systemfunc("date")  
;    fileattdef(outf, fAtt)         
;***********************************************
   mtt=ispan(1982,2011,1)
; predefine coordinate information               
;***********************************************
    dimNames = (/"time", "lat", "lon" /)                        
    dimSizes = (/ nyr , nlat,  nlon /)                        
    dimUnlim = (/ True , False, False /)                        
    filedimdef(outf, dimNames  , dimSizes,  dimUnlim )                  
;   print(getvardims(llat))
    filevardef(outf, "time"  , typeof(ttime), getvardims(ttime) )            
    filevarattdef(outf, "time", mtt)                        
    filevardef(outf, "lat", typeof(llat), getvardims(llat) )
    filevarattdef(outf, "lat", llat)
    filevardef(outf, "lon", typeof(llon), getvardims(llon) )
    filevarattdef(outf, "lon", llon)      
; predefine var2iable sizes
;***********************************************
    filevardef(outf,"lai",typeof(lai), getvardims(lai) )
    filevarattdef(outf,"lai",lai_yr_yr)
    ;***********************************************
    filevardef(outf,"lai_jja",typeof(lai), getvardims(lai) )
    filevarattdef(outf,"lai_jja",lai_jja_yr)
;***********************************************
    setfileoption(outf, "DefineMode", False)
;***********************************************
    outf->time   = (/ mtt/)   
    outf->lat    = (/ llat /)                                             
    outf->lon    = (/ llon /)                                             
    outf->lai    = (/lai_yr_yr  /)
    outf->lai_jja= (/lai_jja_yr  /)
    copy_VarAtts(fn,outf)
;**********************************************
end

图一

图一

图二

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

本版积分规则

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

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

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