Re: variable average

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Tue, 22 Nov 2005 12:22:13 -0700

Hi Chao,

First, I strongly urge you to read the mini-language documentation .pdf
on NCL's web page: http://www.ncl.ucar.edu/Document/Manuals/

There are a few errors in your script, for one,
clmMonTLL requires the time dimension to be a multiple of 12:
http://www.ncl.ucar.edu/Document/Functions/Contributed/clmMonTLL.shtml

Also, your syntax "$nm" is incorrect for both instances where you use it:
fl_in=addfile("June$nm_soil_moisture.hdf","r")
should be
fl_in=addfile("June"+nm+"_soil_moisture.hdf","r")

and

vwc_sfc_$nm=fl_in->mv
should be
vwc_sfc_(nm,:,:)=(/ fl_in->mv /)

The (/ /) keeps the coordinate variable information from the right hand
side from overwriting the coordinate variable information on the left
hand side. (In this case you don't have any coord. variables on the left
hand side but this will stop any error messages from appearing.)

If you want a straight average of your 10 .hdf files, the following code
will work. Good luck.
Adam

nfiles = systemfunc("ls June*_soil_moisture.hdf")
lat_nbr=64
lon_nbr=128
vwc_sfc_tot = new (/dimsizes(nfiles),lat_nbr,lon_nbr/)
do nm=0,9
    fl_in=addfile(nfiles(nm),"r")
    vwc_sfc_tot(nm,:,:) = (/ fl_in->mv /)
end do
vwc_sfc_tot!0 = "time"
vwc_sfc_tot!1 = "lat"
vwc_sfc_tot!2 = "lon"
finarr = fl_in->mv ; prepare new array with same coordinate
                        ; variables (lat,lon) for overall average
finarr = (/ dim_avg(vwc_sfc_tot(lat|:,lon|:,time|:)) /)

Chao Luo wrote:
> Hi,
>
> I try to read a couple of files and average the variable. Following is
> code I used, but it dosn't work.
>
>
> time_nbr=10
> lat_nbr=64
> lon_nbr=128
> vwc_sfc_tot = new (/time_nbr,lat_nbr,lon_nbr/)
> do nm=1,10
> fl_in=addfile("June$nm_soil_moisture.hdf","r")
> vwc_sfc_$nm=fl_in->mv
> vwc_sfc_tot = vwc_sfc_$nm
> end do
> vwc_sfc_avg =clmMonTLL(vwc_sfc_tot)
>
> Thanks much for any helps!
>
> Chao
>
>
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
--------------------------------------------------------------
Adam Phillips			             asphilli_at_ucar.edu
National Center for Atmospheric Research   tel: (303) 497-1726
ESSL/CGD/CAS                               fax: (303) 497-1333
P.O. Box 3000				
Boulder, CO 80307-3000	  http://www.cgd.ucar.edu/cas/asphilli
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Nov 22 2005 - 12:22:13 MST

This archive was generated by hypermail 2.2.0 : Wed Nov 23 2005 - 08:30:24 MST