Re: Array Error

From: Dave Allured <dave.allured_at_nyahnyahspammersnyahnyah>
Date: Wed, 09 Sep 2009 17:40:13 -0600

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
Received on Wed Sep 09 2009 - 17:40:13 MDT

This archive was generated by hypermail 2.2.0 : Tue Sep 15 2009 - 16:03:21 MDT