Hello:
There is some trouble when I get the "time" coordinate variable of the two output nc data which is writtend by the following script. When I use the NCL to print the variable "time",the print results are same. But when I run Grads to plot figures using the two output data, the time of "u2.nc" can be correctly displayed on the plot coordinate,namely,May1 1991,..., that of the "uabnormal.nc" displayed differently,such as 4776,..... I have checked the scripts for several times and still didn't find what is the problem.
Thanks for any help or suggestion!
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
begin
fils=systemfunc("ls uwnd.*.nc")
f=addfiles(fils,"r")
ListSetType (f, "cat")
uwnd1=f[0]->uwnd(120:272,2:2,12:44,120:120)
uwnd2=f[1]->uwnd(121:273,2:2,12:44,120:120)
uwnd3=f[2]->uwnd(120:272,2:2,12:44,120:120)
uwnd4=f[3]->uwnd(120:272,2:2,12:44,120:120)
uwnd5=f[4]->uwnd(120:272,2:2,12:44,120:120)
uwnd6=f[5]->uwnd(121:273,2:2,12:44,120:120)
uwnd7=f[6]->uwnd(120:272,2:2,12:44,120:120)
uwnd8=f[7]->uwnd(120:272,2:2,12:44,120:120)
uwnd9=f[8]->uwnd(120:272,2:2,12:44,120:120)
uwnd10=f[9]->uwnd(121:273,2:2,12:44,120:120)
scale=f[0]->uwnd_at_scale_factor
offset=f[0]->uwnd_at_add_offset
uwnd=((uwnd1+uwnd2+uwnd3+uwnd4+uwnd5+uwnd6+uwnd7+uwnd8+uwnd9+uwnd10)*scale+offset)/10.0
uwnd!0="time"
uwnd!1="level"
uwnd!2="lat"
uwnd!3="lon"
uwnd&time=f[0]->time(120:272)
uwnd&level=f[0]->level(2:2)
uwnd&lat=f[0]->lat(12:44)
uwnd&lon=f[0]->lon(120:120)
printVarSummary(uwnd)
uave=dim_avg(uwnd(level|:,lat|:,lon|:,time|:))
print(uave)
uabnor=uwnd-conform(uwnd,uave,(/1,2,3/))
ff=addfile("uabnormal.nc","c")
f2=addfile("u2.nc","c")
;create global attributes
fileAtt=True
fileAtt_at_title="the abnormal u wind at 850hpa over 120 degree East"
fileAtt_at_conventions="None"
fileAtt_at_creation_date=systemfunc("date")
fileAtt_at_Author="Fu jiaolan"
fileattdef(ff,fileAtt)
fileattdef(f2,fileAtt)
;predefine coordinate variables
dimNames=(/"time","level","lat","lon"/)
dimSizes=(/153,1,33,1/)
dimUnlim=(/False,False,False,False/)
time=f[0]->time(120:272)
lat=f[0]->lat(12:44)
level=f[0]->level(2:2)
lon=f[0]->lon(120:120)
;predefine name,type,dimensions
filedimdef(ff,dimNames,dimSizes,dimUnlim)
filevardef(ff,"time",typeof(time),"time")
filevardef(ff,"level",typeof(level),"level")
filevardef(ff,"lat",typeof(lat),"lat")
filevardef(ff,"lon",typeof(lon),"lon")
filevardef(ff,"uabnor","float",(/"time","level","lat","lon"/))
;create variable atributes
time_at_units="day"
time_at_long_name="time"
level_at_units="millibar"
level_at_long_name="Level"
level_at_positive="down"
level_at_GRIB_name="hpa"
lon_at_units="degrees_east"
lon_at_long_name="longitude"
lat_at_units="degrees_north"
lat_at_long_name="latitude"
uabnor_at_long_name="abnormal u wind"
uabnor_at_units="m/s"
filevarattdef(ff,"time",time)
filevarattdef(ff,"level",level)
filevarattdef(ff,"lat",lat)
filevarattdef(ff,"lon",lon)
filevarattdef(ff,"uabnor",uabnor)
ff->time=(/time/)
ff->level=(/level/)
ff->lat=(/lat/)
ff->lon=(/lon/)
ff->uabnor=(/uabnor/)
print(time)
;predefine name,type,dimensions
filedimdef(f2,dimNames,dimSizes,dimUnlim)
filevardef(f2,"time",typeof(time),"time")
filevardef(f2,"level",typeof(level),"level")
filevardef(f2,"lat",typeof(lat),"lat")
filevardef(f2,"lon",typeof(lon),"lon")
filevardef(f2,"u2","float",(/"time","level","lat","lon"/))
u2=uabnor^2
u2_at_long_name="square abnormal u wind"
u2_at_units="m/s"
filevarattdef(f2,"time",time)
filevarattdef(f2,"level",level)
filevarattdef(f2,"lat",lat)
filevarattdef(f2,"lon",lon)
filevarattdef(f2,"u2",u2)
f2->time=(/time/)
f2->level=(/level/)
f2->lat=(/lat/)
f2->lon=(/lon/)
f2->u2=u2
print(time)
end
Yours,
Alice
2006-03-21
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
This archive was generated by hypermail 2.2.0 : Wed Mar 29 2006 - 11:52:49 MST