As noted in the documentation, addfiles_GetVar has been deprecated:
http://www.ncl.ucar.edu/Document/Functions/Contributed/addfiles_GetVar.shtml
ie: don't use it
addfiles is more verstile.
---- If you are trying to compute the temporal mean of the wind speed at each grid point: f = addfiles (fils, "r") U_GRD_221 = f[:]->U_GRD_221_HTGL_113(:,0,:,:) ; (time,lat,lon) V_GRD_221 = f[:]->V_GRD_221_HTGL_113(:,0,:,:) WSPD = sqrt(U_GRD_221^2 + V_GRD_221^2) copy_VarMeta(U_GRD_221, WSPD) WSPD_at_long_name = "wind speed" printVarSummary(WSPD) WSPD_AVG = dim_avg_n_Wrap(WSPD,0) ; (lat,lon) WSPD_AVG_at_long_name = "mean wind speed" printVarSummary(WSPD_AVG) Dave Allured wrote: > store = new((/wind_data,gridx_221,gridy_221/), "float") > > This line makes a 3-D array of dimensions nx*ny, nx, ny. The first > dimension does not seem right to me. Should this be the time > dimension or the level dimension instead? > > Dave Allured > CU/CIRES Climate Diagnostics Center (CDC) > http://cires.colorado.edu/science/centers/cdc/ > NOAA/ESRL/PSD, Climate Analysis Branch (CAB) > http://www.cdc.noaa.gov/psd1/ > > DJ Rasmussen wrote: >> Hi NCL users, >> >> I am attempting to make an NCL script that reads in multiple monthly >> NARR files with wind data and then averages them all and, finally >> outputs the averages to a netCDF file that I can use to make a contour >> plot with. To do the averages, however, I need to create an array. For >> some reason, NCL will not allow me to do it the way I am trying to: by >> multiplying lat and lon dimensions to get the number of data points for >> wind values at every lat/lon on the NARR grid. >> >> As always, your assistance is appreciated. >> >> Cheers >> >> >> >> >> >> Using NCL version 5.1.1 >> ;************************************************* >> ; NARRAVG.ncl >> ; >> ;************************************************ >> 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 >> >> ;************************************************ >> ; read in multiple grib files >> ;************************************************ >> diri = "./" ; directory where files reside >> fils = systemfunc("ls "+diri+"narr*.grb") >> >> setfileoption("grb","SingleElementDimensions","initial_time") >> >> f = addfiles(fils,"r"); read in all files in the folder >> >> ;*************************Get Variables to Average********** >> U_GRD_221 = addfiles_GetVar(f, fils, "U_GRD_221_HTGL_113") ;Get these >> variables from all files >> V_GRD_221 = addfiles_GetVar(f, fils, "V_GRD_221_HTGL_113") >> >> printVarSummary(U_GRD_221) >> printVarSummary(V_GRD_221) >> >> dimU_GRD = dimsizes(U_GRD_221) >> >> gridx_221 = dimU_GRD(2) ; get dimensions of lat >> gridy_221 = dimU_GRD(3) >> wind_data = dimU_GRD(2)*dimU_GRD(3) ; multiply lat and lon >> dimensions to get wind data points needed >> >> store = new((/wind_data,gridx_221,gridy_221/), "float") ; create a new >> array for new netCDF file. >> >> >> ;*************************Calculate Average****** >> >> U_GRD_221_AVG = dim_avg_n_Wrap(U_GRD_221(:,0,:,:),0) ; calculate >> average of zonal wind at level 0 for all grid points >> V_GRD_221_AVG = dim_avg_n_Wrap(V_GRD_221(:,0,:,:),0) >> >> >> wspd = sqrt( U_GRD_221_AVG2 + V_GRD_221_AVG2 ) ; calculate wind speed >> magnitude >> >> >> ;*************create NetCDF output******************* >> store!0 = "wspd" ; assign named dimensions >> store!1 = "gridx_221" >> store!2 = "gridy_221" >> >> store_at_long_name = "Avg Wind Speed" >> store_at_units = "m/s" >> >> system("/bin/rm -f dailyAvg.WSPD10_NARR.nc") ; remove any pre-existing >> file >> ncdf = addfile("dailyAvg.WSPD10_NARR.nc","c") >> filedimdef(ncdf,"initial_time0_hours",-1,True) >> fileattdef (ncdf, f) >> >> ncdf->U_GRD_221_HTGL_113 = store >> >> end >> >> >> > _______________________________________________ > ncl-talk mailing list > List instructions, subscriber options, unsubscribe: > http://mailman.ucar.edu/mailman/listinfo/ncl-talk _______________________________________________ ncl-talk mailing list List instructions, subscriber options, unsubscribe: http://mailman.ucar.edu/mailman/listinfo/ncl-talkReceived on Wed Sep 09 2009 - 22:20:46 MDT
This archive was generated by hypermail 2.2.0 : Tue Sep 15 2009 - 16:03:21 MDT