Hello,
I am trying to be able to read in a netCDF file with 3 hour data for an
entire year, and then export a netCDF file with daily averages computed
from the 3 hour data. So far I have created a variety of loops to run,
but I get an error:
fatal: Subscript out of range, error in subscript #0
fatal:An error occured reading y
fatal:An error occured reading y
fatal:Execute: Error occurred at or near line 43 in file
DMR_avgDaily_WSP10.ncl
Regards,
DJ Rasmussen
;*********************************************************************
; Calculate the Daily Average
;*********************************************************************
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
;************************************************************
; open files and read in desired variables
;************************************************************
CtmDir = "/home/rasmussen/NARCCAP/"
appl = "uas_CRCM_2038010103"
f = addfile(CtmDir+appl+".nc","r")
y = f->uas(:,:,:)
dimy = dimsizes(y)
time = dimy(0)
xc = dimy(1)
yc = dimy(2)
tstep = (time)
store = new((/tstep,xc,yc/), "float")
m = new(1,float)
;************************************************************
; location loop
;*************************************************************
do i=0,(xc-1)
do j=0,(yc-1)
;************************************************************
; day loop
;*************************************************************
a = 0
b = 7
do l=0,(tstep-1)
z = y(a:b,i,j)
m = 0
;************************************************************
; calculate average and average hours
;*************************************************************
do k=0,7
n = z(k)
m = m + n
end do ; calculate average
mean = m/8
store(l,i,j) = mean
m = 0
a = a+8
b = b+8
end do ; day loop
end do ; col loop
end do ; row loop
;************************************************************
; output
;*************************************************************
store!0 = "TSTEP"
store!1 = "ROW"
store!2 = "COL"
store_at_long_name = "Daily Avg Wind Speed"
store_at_units = "m/s"
ncdf = addfile("dailyAvguas_CRCM_2038010103.nc","c")
filedimdef(ncdf,"TSTEP",-1,True)
fileattdef (ncdf, f)
ncdf->uas = store
end
-- DJ Rasmussen Antarctic Meteorological Research Center University of Wisconsin - Madison Space Science and Engineering Center 1225 W. Dayton St., Rm 947, Madison, WI 53706 Email: dj.rasmussen_at_ssec.wisc.edu http://amrc.ssec.wisc.edu _______________________________________________ ncl-talk mailing list List instructions, subscriber options, unsubscribe: http://mailman.ucar.edu/mailman/listinfo/ncl-talkReceived on Wed Jul 01 2009 - 08:19:55 MDT
This archive was generated by hypermail 2.2.0 : Thu Jul 02 2009 - 11:39:37 MDT