>
>I have used another computer with
>large memory to calculate the 4D climatology. Now I have another question. I
>have done many experiments. Now I have the files 1978-01.nc through 1997-12.nc.
>All of these files have the same variables and attributes. I want to calculate
>the climatologies(monthly, seasonal and annual) of all these same variables in
>these files and write the climatologies of these variables into a single file.
>Is there a method to do this without specifying each variable name, without any
>other indirect outputs? Thanks.
Yes there is. Use "getfilevarnames" and use the $...$ syntax
to substitute a string where a variable name is expected..
An outline follows. I'm assuming u want climatologies
for 3D and 4D variables.
This uses what I call the 'simple but inefficient method'
of creating netCDF files. Note: depending of the number
of variables and the size of the input files
this can be very inefficient for writing netCDF. There are faster
ways but for now try this approach.
untested!!
load "/fs/cgd/data0/shea/nclGSUN/contributed.ncl"
begin
diri = "..." ; input directory
diro = diri ; output directory
filo = "CLM.nc" ; output file name
fili = systemfunc("cd "+diri+" ; ls 19*nc")
pathi = diri+fili
fi = addfiles (pathi, "r") ; establish list of files
f = addfile (pathi(0), "r") ; read the 1st file to get info
varName = getfilevarnames(f) ; list of variables on the file
print (varName)
nvar= dimsizes(varName) ; # of variables
lat = f->lat
lon = f->lon
lev = f->lev
nlat= dimsizes(lat)
mlon= dimsizes(lon)
klev= dimsizes(lev)
NCFILE = diro+filo
system ("/usr/bin/rm "+ NCFILE) ; remove any pre-exist clm
ncdf = addfile(NCFILE,"c") ; create the file reference
nmos = 12
month = ispan(1,nmos,1)
month!0 = "month"
month@long_name = "month"
month&month = month
ncdf->month = month
ncdf->lev = lev
ncdf->lat = lat
ncdf->lon = lon
do nv=0,nvar-1
x = addfiles_GetVar (fi, pathi, varName(nv))
rank = dimsizes(dimsizes(x)) ; # of dimensions
if (rank.eq.3 .or. rank.eq.4) then
xClm = clmMonTLL(x) ; contributed.ncl
ncdf->$varName(nv)$ = xClm ; write to file
print ("Climatology: "+varName(nv)+" "+systemfunc("date"))
end if
delete(x)
end do
end
_______________________________________________
ncl-talk mailing list
ncl-talk AT ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
This archive was generated by hypermail 2b29 : Fri Apr 26 2002 - 18:54:53 MDT