Re: subscripting error: wrf_user_ll_to_ij

From: Rick Brownrigg <brownrig_at_nyahnyahspammersnyahnyah>
Date: Mon Dec 07 2009 - 20:27:24 MST

Hi Erik,

The docs for the function wrf_user_ll_to_ij() indicate that floats or
doubles are returned.
Thus your index variables locL_X, locR_X, etc., would be non-integer
as well, which is consistent
with the error message. Maybe wrap them in float2int()?

Rick

On Mon, 7 Dec 2009 19:19:19 -0500
  Erik Noble <enoble@giss.nasa.gov> wrote:
> Hi. Could I have some help getting past a subscript indexing error?
> Although I am dealing with WRF, this is ncl-talk type question.
> I use the wrf_user_ll_to_ij function to get indices for
>subscripting.
> But keep getting this error.
>
> Any help would be appreciated.
> -Erik
>
> fatal:Illegal subscript. Subscripts must be integer when not using
> coordinate indexing
> fatal:Execute: Error occurred at or near line 64 in file
> wrf_level_winds-Regions.ncl
>
>
> be1005en% ncl wrf_level_winds-Regions.ncl
> Copyright (C) 1995-2009 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 5.1.1
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
>
>
> 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/wrf/WRFUserARW.ncl"
>
> ; Read in the wrf file
> diri = "./"
> fili = "wrfout_NCEP2_0820_1001_default_PleimXiu"
> a = addfile(diri+fili+".nc","r")
> ; What times and how many time steps are in the data set?
> times = wrf_user_list_times(a)
> tm = "96:336" ; September
> ; get the variables we need
> u = wrf_user_getvar(a, "ua",-1) ; u averaged to mass
>points
> v = wrf_user_getvar(a, "va",-1) ; v averaged to mass
>points
> p = wrf_user_getvar(a, "pressure",-1) ; pressure is our
>vertical
> coordinate
>
> regions = (/"R1","R2","R3","R4"/) ; Sub_regions of interest ; think
>
> "boxes"
> ip_latsL = (/12.5, 10, 5., 7. /) ; left-hand corner lats
> ip_lonsL = (/ -15., -15., -7., -30. /) ; left-hand corner lons
> ip_latsR = (/17.5, 12.5, 10., 17.5/) ; right-hand corner lats
> ip_lonsR = (/30., 30., 7., -15./) ; left-hand corner lons
> locs = dimsizes(ip_latsL)
> do j = 0,locs-1
> locLHS_R = wrf_user_ll_to_ij(a, ip_lonsL(j), ip_latsL(j),
>True)
> locRHS_R = wrf_user_ll_to_ij(a, ip_lonsR(j), ip_latsR(j),
>True)
> locL_X = locLHS_R(0)
> locL_Y = locLHS_R(1)
> locR_X = locRHS_R(0)
> locR_Y = locRHS_R(1)
> Rlats = locL_Y+":"+locR_Y
> Rlons = locL_X+":"+locR_X
> ; Variable (time, Rlats, Rlons)
>
> ;************************************
> ; Get WRF 1D coordinates
> ;************************************
> lat = a->XLAT(0,:,0)
> lon = a->XLONG(0,0,:)
> ; The specific pressure levels that we want the data
> interpolated to.
> pressure_levels = (/ 925., 700./) ; pressure levels to
>plot
> nlevels = dimsizes(pressure_levels) ; number of
>
> pressure levels
> ; LOOP OVER LEVELS
> do level = 0,nlevels-1
> pressure = pressure_levels(level)
> u_plane = wrf_user_intrp3d(
>u,p,"h",pressure,0.,False)
> v_plane = wrf_user_intrp3d(
>v,p,"h",pressure,0.,False)
> u_plane!1 = "lat"
> u_plane!2 = "lon"
> u_plane&lat = lat
> u_plane&lon = lon
> v_plane!1 = "lat"
> v_plane!2 = "lon"
> v_plane&lat = lat
> v_plane&lon = lon
>
> spd = (u_plane*u_plane + v_plane*v_plane)^(0.5)
>;
> m/sec
> spd@description = "Wind Speed"
> spd@units = "m/s"
> spd!1 = "lat"
> spd!2 = "lon"
> spd&lat = lat
> spd&lon = lon
>
> U = u_plane(tm,locL_Y:locR_Y,locL_X:locR_X) ; ERROR
>
> keeps happening here
> V = v_plane(tm,locL_Y:locR_Y,locL_X:locR_X)
> S = spd(tm,locL_Y:locR_Y,locL_X:locR_X)
>
> if ( pressure .eq. 925 ) then
> NCFILE = fili+"_"+regions(j)+"_925mb-winds.nc"
> system ("/bin/rm -f " + NCFILE) ; remove any
>pre-
> exist file time
> ncdf = addfile(NCFILE ,"c") ; open output
>netCDF
> file
> ; make time and UNLIMITED dimension ;
> recommended for most applications
> filedimdef(ncdf,"Time",-1,True)
> ncdf->lat=lat
> ncdf->lon=lon
> ncdf->u925=U
> ncdf->v925=V
> ncdf->wspd925=S
> delete(NCFILE) ; free memory
> delete(ncdf)
> end if
>
> if ( pressure .eq. 700 ) then ; plot temp, height,
>
> wind barbs
> NCFILE = fili+"_"+regions(j)+"_700mb-winds.nc"
> system ("/bin/rm -f " + NCFILE) ; remove any
>pre-
> exist file time
> ncdf = addfile(NCFILE ,"c") ; open output
>netCDF
> file
> ; make time and UNLIMITED dimension ;
> recommended for most applications
> filedimdef(ncdf,"Time",-1,True)
> ncdf->lat=lat
> ncdf->lon=lon
> ncdf->u700=U
> ncdf->v700=V
> ncdf->wspd700=spd
> delete(NCFILE) ; free memory
> delete(ncdf)
> end if
> end do
> end do
>
>
> _______________________________________________
> 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-talk
Received on Mon Dec 7 20:27:29 2009

This archive was generated by hypermail 2.1.8 : Thu Dec 10 2009 - 11:30:59 MST