回复: avg function-Number of subscripts do not match number of dimensions of variable

From: Guo Zhang <wswzg6666_at_nyahnyahspammersnyahnyah>
Date: Wed Feb 29 2012 - 13:26:49 MST

Thanks Dave. I have changed lines to S_CTL  = new(nfl,float) S_BT  = new(nfl,float) But I don't know why I got the same average values. The output is as below: Variable: m Type: float Total Size: 96 bytes             24 values Number of Dimensions: 1 Dimensions and sizes: [24] Coordinates: Number Of Attributes: 1   _FillValue : -999 (0) -10.62389 (1) -10.62389 (2) -10.62389 (3) -10.62389 (4) -10.62389 (5) -10.62389 (6) -10.62389 (7) -10.62389 (8) -10.62389 (9) -10.62389 (10) -10.62389 (11) -10.62389 (12) -10.62389 (13) -10.62389 (14) -10.62389 (15) -10.62389 (16) -10.62389 (17) -10.62389 (18) -10.62389 (19) -10.62389 (20) -10.62389 (21) -10.62389 (22) -10.62389 (23) -10.62389 Variable: n Type: float Total Size: 96 bytes             24 values Number of Dimensions: 1 Dimensions and sizes: [24] Coordinates: Number Of Attributes: 1   _FillValue : -999 (0) -54.13034 (1) -54.13034 (2) -54.13034 (3) -54.13034 (4) -54.13034 (5) -54.13034 (6) -54.13034 (7) -54.13034 (8) -54.13034 (9) -54.13034 (10) -54.13034 (11) -54.13034 (12) -54.13034 (13) -54.13034 (14) -54.13034 (15) -54.13034 (16) -54.13034 (17) -54.13034 (18) -54.13034 (19) -54.13034 (20) -54.13034 (21) -54.13034 (22) -54.13034 (23) -54.13034 ________________________________ 发件人: David Brown <dbrown_at_ucar.edu> 收件人: Guo Zhang <wswzg6666_at_yahoo.com.cn> 抄送: "ncl-talk_at_ucar.edu" <ncl-talk_at_ucar.edu> 发送日期: 2012年2月29日, 星期三, 下午 12:56 主题: Re: [ncl-talk] avg function-Number of subscripts do not match number of dimensions of variable The error message is describing the problem. In your code you create the variables S_CTL and S_BT with 2 dimensions, the second being a single element dimension. I think you simply need to change the lines S_CTL  = new((/nfl,1/),float) S_BT  = new((/nfl,1/),float) to S_CTL  = new(nfl,float) ; the (/ .. /) enclosure is not needed if you have only 1 dimension S_BT  = new(nfl,float) unless you really have a use for that single element dimension. If so you would need to reference it in the avg call, e.g.: m(i)= avg(S_CTL(i::24,0)) -dave On Feb 29, 2012, at 12:31 PM, Guo Zhang wrote: >  Hi, >  > I want to calculate monthly mean daily variation. The files are splited every hour. When I use avg function, I have this error 'Number of subscripts do not match number of dimensions of variable,(1) Subscripts used, (2) Subscripts expected'. > Can anyone help me?Thanks. > The script and error are as below. >  > Best, > Guo >  > begin >  fil0 = systemfunc("ls /d1/model/guoz/CTL/HRLDAS_MP/Run/Glees/200907*.LDASOUT_DOMAIN1")+".nc" >  fil1 = systemfunc("ls /d1/model/guoz/BT/HRLDAS_MP/Run/Glees/200907*.LDASOUT_DOMAIN1")+".nc" >  nfl = dimsizes(fil0) >  S_CTL  = new((/nfl,1/),float) >  S_BT  = new((/nfl,1/),float) >  do ifl = 0,nfl-1 >      f = addfile(fil0(ifl),"r") >      f1 = addfile(fil1(ifl),"r") >      S_CTL = f->SSOIL(:,0,0) >      S_BT = f1->SSOIL(:,0,0) >  end do > ;  ListSetType (f,"cat") >  print(dimsizes(fil0)) >  printVarSummary(S_CTL) >  printVarSummary(S_BT) >  nhour = 24 >  t=ispan(0,nhour-1,1) >  m=new(nhour,float) >  n=new(nhour,float) > ;  p=new(nhour,float) >  do i=0,nhour-1 >  m(i)= avg(S_CTL(i::24)) >  n(i)= avg(S_BT(i::24)) > ;  p(i)= avg(SOBS(i::24)) >  end do >  print(m) >  print(n) >  >  > Copyright (C) 1995-2009 - All Rights Reserved >  University Corporation for Atmospheric Research >  NCAR Command Language Version 5.1.0 >  The use of this software is governed by a License Agreement. >  See http://www.ncl.ucar.edu/ for more details. > (0) 744 > > Variable: S_CTL > Type: float > Total Size: 2976 bytes >            744 values > Number of Dimensions: 2 > Dimensions and sizes: [744] x [1] > Coordinates: > Number Of Attributes: 5 >  stagger : - >  units : W m{-2} >  description : Heat flux into the soil >  MemoryOrder : XY >  _FillValue : -999 > > Variable: S_BT > Type: float > Total Size: 2976 bytes >            744 values > Number of Dimensions: 2 > Dimensions and sizes: [744] x [1] > Coordinates: > Number Of Attributes: 5 >  stagger : - >  units : W m{-2} >  description : Heat flux into the soil >  MemoryOrder : XY >  _FillValue : -999 > fatal:Number of subscripts do not match number of dimensions of variable,(1) Subscripts used, (2) Subscripts expected > fatal:Execute: Error occurred at or near line 30 in file 200907_H.ncl > _______________________________________________ > ncl-talk mailing list > List instructions, subscriber options, unsubscribe: > http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Feb 29 13:27:02 2012

This archive was generated by hypermail 2.1.8 : Mon Mar 05 2012 - 14:12:07 MST