Re: Number of subscripts do not match number of dimensions of variable

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Fri Feb 04 2011 - 11:52:37 MST

HI Wei,

The error is telling you exactly what's wrong. You are treating a variable as if it had 3 dimensions, when it really has 4 dimensions.

You should use "printVarSummary" in cases like this, to see what your variable looks like:

   printVarSummary(zz)

Also, you probably don't need to loop calculate zmax. If you really did have just three dimensions, you could use:

   zmax = max(zz(:,1,1))

Also, don't forget that NCL array indexing is 0-based. If you want the first elements of the rightmost two dimensions, you would use:

   zmax = max(zz(:,0,0))

It looks like "zz" is 4D, so please correct the subscripting appropriately.

--Mary

On Feb 4, 2011, at 9:37 AM, wei huang wrote:

> Dear NCL users,
> I got an error during the panel plot: fatal:Number of subscripts do not match number of dimensions of variable,(3) Subscripts used, (4) Subscripts expected
> fatal:Execute: Error occurred at or near line 16 in file
> Any help will be appreciated about fixing the problem
> Thanks in advance
> wei
> *********************************
> = = = = = = =
> = = = = = = =
>
> = = = = = =
> times = wrf_user_list_times (a); get times in the file
> ntimes = dimsizes(times) ; number of times in the file
> FirstTime = res
> mdims = getfilevardimsizes(a,"P") ; get some dimension sizes for the file
> nd = dimsizes(mdims)
> plots = new (4 , graphic )
> ; Get the data
> z = wrf_user_getvar(a, "z",-1) ; grid point height
> p = wrf_user_getvar(a,"pressure",-1)
> ; Interpolate to pressure
> if (FirstTime) then
> zz = z/100.
> dims = dimsizes(zz)
> zmax = -999.
> do imax = 1,dims(0)-1
> if ( .not.ismissing(zz(imax,1,1)) .and. zz(imax,1,1) .gt. zmax ) then
> zmax = zz(imax,1,1)
> end if
> end do
> imax = floattoint(zmax)
> zmax = imax/10.
> print("Y labels set to: 0 - " + zmax + " km")
> FirstTime = False
> end if
>
> ; Interpolate data vertically
> mpv_plane = wrf_user_intrp3d(mpv,p,"v",plane,0.,opts)
> eth_plane = wrf_user_intrp3d(eth,p,"v",plane,0.,opts)
> ;
> gmpv_plane = wrf_user_intrp3d(gmpv,p,"v",plane,0.,opts)
> ths_plane = wrf_user_intrp3d(ths,p,"v",plane,0.,opts)
>
> ; Options for XY Plots
> opts_xy = res
> opts_xy@tiYAxisString = "Pressure (hPa)"
> opts_xy@AspectRatio = 0.75
> opts_xy@cnMissingValPerimOn = True
> opts_xy@cnMissingValFillColor = 0
> opts_xy@cnMissingValFillPattern = 11
> opts_xy@tmYLMode = "Explicit"
> opts_xy@tmYLValues = fspan(0,100,10) ; over the 0-100 span of the Y label
> opts_xy@tmYLLabels = fspan(1000,100,10); Corresponding 11 labels
> opts_xy@PlotOrientation = ths_plane@Orientation
>
> ; Plotting options for gmpv
> opts_gmpv = opts_xy
> opts_gmpv@ContourParameters = (/ - 4., 5., 1. /)
> opts_gmpv@cnFillOn = True
> opts_gmpv@lbLabelBarOn = False
> opts_gmpv@gsnSpreadColors = True
>
>
> ; Plotting options for Temperature
> opts_eth = opts_xy
> opts_eth@ContourParameters = (/ 270., 450., 4. /)
> opts_eth@cnInfoLabelOn = False ; Turn off individual label bars so we can
>
> ; Plotting options for Equivalent Potential Temperature
> opts_ths = opts_xy
> opts_ths@ContourParameters = (/ 220., 330., 4. /)
>
> ; Get the contour info for the mpv and theta_e
> opts_xy@PlotOrientation = eth_plane@Orientation
> contour_eth = wrf_contour(a,wks,eth_plane(7,:,:),opts_eth)
> contour_mpv = wrf_contour(a,wks,mpv_plane(7,:,:),opts_gmpv)
> contour_eth1 = wrf_contour(a,wks,eth_plane(8,:,:),opts_eth)
> contour_mpv1 = wrf_contour(a,wks,mpv_plane(8,:,:),opts_gmpv)
> ; Get the contour info for the gmpv and ths
> opts_xy@PlotOrientation = ths_plane@Orientation
> contour_ths = wrf_contour(a,wks,ths_plane(7,:,:),opts_ths)
> contour_gmpv = wrf_contour(a,wks,gmpv_plane(7,:,:),opts_gmpv)
> contour_ths1 = wrf_contour(a,wks,ths_plane(8,:,:),opts_ths)
> contour_gmpv1 = wrf_contour(a,wks,gmpv_plane(8,:,:),opts_gmpv)
>
> ; MAKE PLOTS
> plots(0) = wrf_overlays(a,wks,(/contour_mpv,contour_eth/),pltres)
> plots(1) = wrf_overlays(a,wks,(/contour_gmpv,contour_ths/),pltres)
> plots(2) = wrf_overlays(a,wks,(/contour_mpv1,contour_eth1/),pltres)
> plots(3) = wrf_overlays(a,wks,(/contour_gmpv1,contour_ths1/),pltres)
>
> ; Delete options and fields, so we don't have carry over
> delete(opts_eth)
> delete(opts_ths)
> delete(opts_gmpv)
> delete(eth_plane)
> delete(mpv_plane)
> delete(ths_plane)
> delete(gmpv_plane)
> ; create panel
> ;************************************************
> ;Panel the WRF plots
> resP = True ; modify the panel plot
> resP@gsnFrame = False ; don't advance panel plot
> resP@gsnPanelLabelBar = True ; add common colorbar
> resP@gsnPanelScalePlotIndex = 1
> resP@gsnPanelBottom = 0.2 ; shrink panel plot by setting bottom edge of plot
> resP@gsnPanelTop = 0.9
> gsn_panel(wks,(/plots/),(/2,2/),resP) ; now draw as one plot
> frame(wks)
> 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-talk
Received on Fri Feb 4 11:52:45 2011

This archive was generated by hypermail 2.1.8 : Fri Feb 11 2011 - 16:11:42 MST