Array Error

From: DJ Rasmussen <dj.rasmussen_at_nyahnyahspammersnyahnyah>
Date: Wed, 09 Sep 2009 17:57:45 -0500

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.


Using NCL version 5.1.1
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"


; read in multiple grib files
diri = "./" ; directory where files reside
fils = systemfunc("ls "+diri+"narr*.grb")


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")


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

;*************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") ; remove any pre-existing
ncdf = addfile("","c")
fileattdef (ncdf, f)

ncdf->U_GRD_221_HTGL_113 = store


DJ Rasmussen
Antarctic Meteorological Research Center
University of Wisconsin - Madison Space Science and Engineering Center
1225 W. Dayton St., Rm 947, Madison, WI 53706
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
Received 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