Dear Dennis Shea,
According to your valuable suggestion I modified my code and got the error given below. My NCL version is 5.1.0, ., I don’t know this will be handle it or not. Furthermore, I want to calculate only pentad (means five days sum of every one ( i.e. u0,u1,…. u5) and then add together to all (u = u0+u1+u2+u3+u4+u5) not average. Thank you in advance and your guidance will be appreciated.
regards,
kim
**************************************
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
f = addfile("lhtfl.sfc.gauss.2000.nc","r")
u0 = short2flt(f->lhtfl(120:124,:,:))
u1 = short2flt(f->lhtfl(125:129,:,:))
u2 = short2flt(f->lhtfl(133:137,:,:))
u3 = short2flt(f->lhtfl(138:142,:,:))
u4 = short2flt(f->lhtfl(143:147,:,:))
u5 = short2flt(f->lhtfl(148:152,:,:))
nlat = 94
mlon = 192
nPentad = 6
u = new ( (/nPentad,nlat,mlon/), "float", "No_FillValue")
nStrt = 120
nLast = 124
do n=0,nPentad-1
x = short2flt(f->lhtfl(nStrt:nLast,:,:))
u(n,:,:) = dim_avg_n(x, 0)
nStrt = nStrt+5
nLast = nLast+5
end do
u!0 = "time"
u!1 = "lat"
u!2 = "lon"
u&time = f->time(122:150:5) ; middle time of each pentad
u&lat = f->lat
u&lon = f->lon
printVarSummary(u)
time = u&time
uRegion = wgt_areaave_Wrap(u(:,{0:40},{40:120}),1.0,1.0,0)
wks = gsn_open_wks ("x11","CLH")
res = True
res@xyLineColors =(/"red"/)
res@xyLineThicknesses = 2.0
res@tiYAxisString = "W/m2"
plot = gsn_csm_xy(wks,time,uRegion,res)
end
**************************
Error
fatal:Undefined identifier: (dim_avg_n) is undefined, can't continue
fatal:Execute: Error occurred at or near line 21 in file tes1.ncl
--- On Mon, 3/8/10, Dennis Shea <shea@ucar.edu> wrote:
From: Dennis Shea <shea@ucar.edu>
Subject: Re: help
To: r4rid@yahoo.com
Cc: "ncl-talk@ucar.edu" <ncl-talk@ucar.edu>
Date: Monday, March 8, 2010, 8:51 PM
[1]
Please make the Subject better reflect the problem.
Just "help" is *not* useful.
[2]
> Dear Ncl users, I want to plot pentad bases LH for the month of May.
> When I got the printVarSummary (u) it indicates only fist pentad but I
> don't know how to confirm the other pentad? Could anyone check my code
> where I did the mistake?
> u0 = short2flt(f->lhtfl(120:124,:,:))
> u1 = short2flt(f->lhtfl(125:129,:,:))
> u2 = short2flt(f->lhtfl(133:137,:,:))
> u3 = short2flt(f->lhtfl(138:142,:,:))
> u4 = short2flt(f->lhtfl(143:147,:,:))
> u5 = short2flt(f->lhtfl(148:152,:,:))
> u = u0
> u = (u0+u1+u2+u3+u4+u5)
This computes the average for days
(0) 120,125,133,138,143,148
(1) 121,126,134,139,144,149
:
(5) 124,129,137,142,147,152
============
If you want the five separate pentad averages,
the following untested code should do it
nlat = 94
mlon = 192
nPentad = 6
u = new ( (/nPentad,nlat,mlon/), "float", "No_FillValue")
nStrt = 120
nLast = 124
do n=0,nPentad-1
x = short2flt(f->lhtfl(nStrt:nLast,:,:))
u(n,:,:) = dim_avg_n(x, 0)
nStrt = nStrt+5
nLast = nLast+5
end do
u!0 = "time"
u!1 = "lat"
u!2 = "lon"
u&time = f->time(122:150:5) ; middle time of each pentad
u&lat = f->lat
u&lon = f->lon
printVarSummary(u)
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Mar 10 21:05:42 2010
This archive was generated by hypermail 2.1.8 : Thu Mar 11 2010 - 11:17:07 MST