Hi Dave,
Thanks. That solved my problem.
Regards,
Yuqiang
From: David Brown [mailto:dbrown@ucar.edu]
Sent: Friday, June 21, 2013 6:44 PM
To: Yuqiang Zhang
Cc: ncl-talk@ucar.edu
Subject: Re: Save results to netcdf in NCL
Hi Yuqiang,
What you did not do is assign only the data from your variables into the
file using the "(/" , "/)" syntax, as described in the last section of the
"Method 2" doc. Your variables probably do not have any assigned dimension
names. When you assign the variable (as opposed to just the data values in
the variable) it creates dimension names in the file (even though you are
assigning to a variable you have already created in the file).
If you replace lines like
outf->ene = var_regrid_ene
with
outf->ene = (/ var_regrid_ene/)
the extra dimensions should go away.
-dave
On Jun 21, 2013, at 4:29 PM, "Yuqiang Zhang" <yuqiangzhang.thu@gmail.com>
wrote:
Hi Everyone,
I am a new guy with NCL. Recently I wrote a code to save the outputs into
netcdf with NCL. However when the code was done, I used the "ncdump -h" to
check the header information of the new netcdfs, it gave me more dimensions
than I defined (see the yellow lines). However in the code, I only defined
these dimensions as (time, south_north, west_east). In the new netcdfs, I
have saved 8 variables with the same dimension of (south_north, west_east).
Not sure why there are so many "ncl*" variables.
The red ones are my codes. It is also attached.
"dimensions:
time = UNLIMITED ; // (1 currently)
south_north = 128 ;
west_east = 164 ;
ncl3 = 1 ;
ncl4 = 128 ;
ncl5 = 164 ;
ncl6 = 128 ;
ncl7 = 164 ;
ncl8 = 128 ;
ncl9 = 164 ;
ncl10 = 128 ;
ncl11 = 164 ;
ncl12 = 128 ;
ncl13 = 164 ;
ncl14 = 128 ;
ncl15 = 164 ;
ncl16 = 128 ;
ncl17 = 164 ;
ncl18 = 128 ;
ncl19 = 164 ;"
fAtt = True ; assign file attributes
fAtt@title = "NCL Efficient Approach to netCDF Creation"
fAtt@units = "kg/m2/s"
fAtt@source_file = src_file
fAtt@Conventions = "Conserve from RCP"
fAtt@creation_date = systemfunc ("date")
fileattdef(outf, fAtt ) ; copy file attributes
;Define dimensions:
dim_names = (/"time", "south_north","west_east"/)
dim_sizes = (/-1, nlat(0),nlon(1)/)
dim_unlimited = (/True, False,False/)
print("Defining dimension sizes to be " + dim_sizes)
filedimdef(outf,dim_names,dim_sizes,dim_unlimited)
;Define file variables
filevardef(outf,"ROW","float",(/"south_north","west_east"/))
filevardef(outf,"COL","float",(/"south_north","west_east"/))
filevardef(outf,"time","float","time")
filevardef(outf,"ind","float",(/"south_north","west_east"/))
filevardef(outf,"ene","float",(/"south_north","west_east"/))
filevardef(outf,"dom","float",(/"south_north","west_east"/))
filevardef(outf,"tra","float",(/"south_north","west_east"/))
filevardef(outf,"wst","float",(/"south_north","west_east"/))
filevardef(outf,"agr","float",(/"south_north","west_east"/))
filevardef(outf,"slv","float",(/"south_north","west_east"/))
filevardef(outf,"awb","float",(/"south_north","west_east"/))
;Define file attributes
print("Defining file variable attributes")
tatts = True
tatts@long_name = "elapsed time"
tatts@format = "YYYYMMDD"
filevarattdef(outf,"time",tatts)
;create arrays
;filedimdef(outf,"time",ntime,True)
outf->ROW = dst_lat
outf->COL = dst_lon
outf->time = times(0)
outf->ene = var_regrid_ene
outf->dom = var_regrid_dom
outf->ind = var_regrid_ind
outf->tra = var_regrid_tra
outf->wst = var_regrid_wst
outf->agr = var_regrid_agr
outf->slv = var_regrid_slv
outf->awb = var_regrid_awb
I used the example from NCL website:
"Method 2: netCDF output with file predefinition"
<http://www.ncl.ucar.edu/Applications/method_2.shtml>
http://www.ncl.ucar.edu/Applications/method_2.shtml
-----------------------------------------------------------------
-----------------------------------------------------------------
Yuqiang Zhang
PhD student
Environmental Science and Engineering Department
Univerisyt of North Carolina at Chapel Hill
<zyq_ESMF_regrid_RCP_SMOKE.ncl>_____________________________________________
__
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
<http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
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 Fri Jun 21 21:06:38 2013
This archive was generated by hypermail 2.1.8 : Mon Jun 24 2013 - 11:46:47 MDT