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
-- DJ Rasmussen Antarctic Meteorological Research Center University of Wisconsin - Madison Space Science and Engineering Center 1225 W. Dayton St., Rm 947, Madison, WI 53706 Email: dj.rasmussen_at_ssec.wisc.edu http://amrc.ssec.wisc.edu _______________________________________________ ncl-talk mailing list List instructions, subscriber options, unsubscribe: http://mailman.ucar.edu/mailman/listinfo/ncl-talkReceived on Wed Sep 09 2009 - 16:57:45 MDT
This archive was generated by hypermail 2.2.0 : Tue Sep 15 2009 - 16:03:21 MDT