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

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Thu Aug 04 2011 - 10:40:54 MDT

Wei,

You are passing a 2D array to an XY plotting routine, so you are going to get NY curves, where NY is the size of your leftmost dimension.

I'm not sure how you expect to get a single line out of 2D array. If you send a (say) 4 x 10 array to gsn_csm_xy, you will get four lines each with 10 points.

If you just want one line, you will need to subscript your arrays, but you also have to decide which part of the array you want to see. For example:

plt = gsn_csm_xy (wks,x(0,:),y(0,:),resxy)

will plot just one line. You need to be clear about what you are trying to plot. Are you sure you want to plot a line? Perhaps you want to do contours instead, gsn_csm_contour.

--Mary

On Aug 4, 2011, at 10:31 AM, wei huang wrote:

>
>
> ---------- Forwarded message ----------
> From: wei huang <whua27@gmail.com>
> Date: Fri, Aug 5, 2011 at 12:29 AM
> Subject: Re: Number of subscripts do not match number of dimensions of variable
> To: Mary Haley <haley@ucar.edu>
>
>
> Hi, thanks again for your kind help, however, the script is working now, but unfortunately the plot is very strange (attached) it is not a simple line. I just include in your previous response, then it was working:
>
> dimwx = dimsizes(wx)
> nsn = dimwx(0)
> nwe = dimwx(1)
> np = dimwx(2)
> x = onedtond(ndtooned(wx), (/ nsn*nwe, np/))
> y = onedtond(ndtooned(py), (/ nsn*nwe, np/))
>
> Because the error was appeared np is not defined
>
> Regarding Mary response, this is already staggered as indicated in the printVarSummary.any further suggestion will be highly appreciated.
> Thanks again for your help and time
> wei
> ****************************************
> Variable: w
>
> Type: float
>
> Total Size: 127307700 bytes
>
> 31826925 values
>
> Number of Dimensions: 4
>
> Dimensions and sizes: [Time | 31] x [bottom_top_stag | 27] x [south_north | 195] x [west_east | 135]
>
> Coordinates:
>
> Number Of Attributes: 6
>
> FieldType : 104
>
> MemoryOrder : XYZ
>
> description : z-wind component
>
> units : m s-1
>
> stagger : Z
>
> coordinates : XLONG XLAT
>
>
>
> Variable: p
>
> Type: float
>
> Total Size: 127307700 bytes
>
> 31826925 values
>
> Number of Dimensions: 4
>
> Dimensions and sizes: [Time | 31] x [bottom_top | 27] x [south_north | 195] x [west_east | 135]
>
> Coordinates:
>
> Number Of Attributes: 6
>
> coordinates : XLONG XLAT
>
> stagger :
>
> units : hPa
>
> description : Pressure
>
> MemoryOrder : XYZ
>
> FieldType : 104
>
>
>
> Variable: wx
>
> Type: float
>
> Total Size: 4106700 bytes
>
> 1026675 values
>
> Number of Dimensions: 3
>
> Dimensions and sizes: [south_north | 195] x [west_east | 135] x [bottom_top_stag | 27]
>
> Coordinates:
>
> Number Of Attributes: 6
>
> coordinates : XLONG XLAT
>
> stagger : Z
>
> units : m s-1
>
> description : z-wind component
>
> MemoryOrder : XYZ
>
> FieldType : 104
>
>
>
> Variable: py
>
> Type: float
>
> Total Size: 4106700 bytes
>
> 1026675 values
>
> Number of Dimensions: 3
>
> Dimensions and sizes: [south_north | 195] x [west_east | 135] x [bottom_top | 27]
>
> Coordinates:
>
> Number Of Attributes: 6
>
> FieldType : 104
>
> MemoryOrder : XYZ
>
> description : Pressure
>
> units : hPa
>
> stagger :
>
> coordinates : XLONG XLAT
>
>
>
> Variable: x
>
> Type: float
>
> Total Size: 4106700 bytes
>
> 1026675 values
>
> Number of Dimensions: 2
>
> Dimensions and sizes: [26325] x [27]
>
> Coordinates:
>
>
>
> Variable: y
>
> Type: float
>
> Total Size: 4106700 bytes
>
> 1026675 values
>
> Number of Dimensions: 2
>
> Dimensions and sizes: [26325] x [27]
>
> Coordinates:
>
> *************************************************
>
> warning:LegendInitialize: lgItemTypes exceeds maximum number of elements, 256: ignoring
>
> warning:LegendSetValues: lgItemTypes exceeds maximum number of elements, 256: ignoring
>
> warning:LegendSetValues: lgDashIndexes exceeds maximum number of elements, 256: ignoring
>
> warning:LegendSetValues: lgMarkerIndexes exceeds maximum number of elements, 256: ignoring
>
> warning:LegendSetValues: lgLineLabelStrings exceeds maximum number of elements, 256: ignoring
>
> warning:LegendSetValues: lgLineColors exceeds maximum number of elements, 256: ignoring
>
> warning:LegendSetValues: lgMarkerColors exceeds maximum number of elements, 256: ignoring
>
> warning:LegendSetValues: lgLineDashSegLens exceeds maximum number of elements, 256: ignoring
>
> warning:LegendSetValues: lgLineThicknesses exceeds maximum number of elements, 256: ignoring
>
> warning:LegendSetValues: lgMarkerThicknesses exceed
>
> ******************************************
>
> On Fri, Aug 5, 2011 at 12:20 AM, wei huang <whua27@gmail.com> wrote:
> Hi, thanks again for your kind help, however, the script is working now, but unfortunately the plot is very strange (attached) it is not a simple line. I just include in your previous response, then it was working:
>
> dimwx = dimsizes(wx)
> nsn = dimwx(0)
> nwe = dimwx(1)
> np = dimwx(2)
> x = onedtond(ndtooned(wx), (/ nsn*nwe, np/))
> y = onedtond(ndtooned(py), (/ nsn*nwe, np/))
>
> Because the error was appeared np is not defined
>
> Regarding Mary response, this is already staggered as indicated in the printVarSummary.any further suggestion will be highly appreciated.
> Thanks again for your help and time
> wei
> ***********************************************
> Variable: w
>
> Type: float
>
> Total Size: 127307700 bytes
>
> 31826925 values
>
> Number of Dimensions: 4
>
> Dimensions and sizes: [Time | 31] x [bottom_top_stag | 27] x [south_north | 195] x [west_east | 135]
>
> Coordinates:
>
> Number Of Attributes: 6
>
> FieldType : 104
>
> MemoryOrder : XYZ
>
> description : z-wind component
>
> units : m s-1
>
> stagger : Z
>
> coordinates : XLONG XLAT
>
>
>
> Variable: p
>
> Type: float
>
> Total Size: 127307700 bytes
>
> 31826925 values
>
> Number of Dimensions: 4
>
> Dimensions and sizes: [Time | 31] x [bottom_top | 27] x [south_north | 195] x [west_east | 135]
>
> Coordinates:
>
> Number Of Attributes: 6
>
> coordinates : XLONG XLAT
>
> stagger :
>
> units : hPa
>
> description : Pressure
>
> MemoryOrder : XYZ
>
> FieldType : 104
>
>
>
> Variable: wx
>
> Type: float
>
> Total Size: 4106700 bytes
>
> 1026675 values
>
> Number of Dimensions: 3
>
> Dimensions and sizes: [south_north | 195] x [west_east | 135] x [bottom_top_stag | 27]
>
> Coordinates:
>
> Number Of Attributes: 6
>
> coordinates : XLONG XLAT
>
> stagger : Z
>
> units : m s-1
>
> description : z-wind component
>
> MemoryOrder : XYZ
>
> FieldType : 104
>
>
>
> Variable: py
>
> Type: float
>
> Total Size: 4106700 bytes
>
> 1026675 values
>
> Number of Dimensions: 3
>
> Dimensions and sizes: [south_north | 195] x [west_east | 135] x [bottom_top | 27]
>
> Coordinates:
>
> Number Of Attributes: 6
>
> FieldType : 104
>
> MemoryOrder : XYZ
>
> description : Pressure
>
> units : hPa
>
> stagger :
>
> coordinates : XLONG XLAT
>
>
>
> Variable: x
>
> Type: float
>
> Total Size: 4106700 bytes
>
> 1026675 values
>
> Number of Dimensions: 2
>
> Dimensions and sizes: [26325] x [27]
>
> Coordinates:
>
>
>
> Variable: y
>
> Type: float
>
> Total Size: 4106700 bytes
>
> 1026675 values
>
> Number of Dimensions: 2
>
> Dimensions and sizes: [26325] x [27]
>
> Coordinates:
>
> *************************************************
>
> warning:LegendInitialize: lgItemTypes exceeds maximum number of elements, 256: ignoring
>
> warning:LegendSetValues: lgItemTypes exceeds maximum number of elements, 256: ignoring
>
> warning:LegendSetValues: lgDashIndexes exceeds maximum number of elements, 256: ignoring
>
> warning:LegendSetValues: lgMarkerIndexes exceeds maximum number of elements, 256: ignoring
>
> warning:LegendSetValues: lgLineLabelStrings exceeds maximum number of elements, 256: ignoring
>
> warning:LegendSetValues: lgLineColors exceeds maximum number of elements, 256: ignoring
>
> warning:LegendSetValues: lgMarkerColors exceeds maximum number of elements, 256: ignoring
>
> warning:LegendSetValues: lgLineDashSegLens exceeds maximum number of elements, 256: ignoring
>
> warning:LegendSetValues: lgLineThicknesses exceeds maximum number of elements, 256: ignoring
>
> warning:LegendSetValues: lgMarkerThicknesses exceed
>
> ************************************
>
> On Thu, Aug 4, 2011 at 10:15 PM, Mary Haley <haley@ucar.edu> wrote:
> Wei,
>
> You are passing 3D arrays to gsn_csm_xy, which is expecting either 1D arrays (for a single line), or 2D arrays (for multiple lines).
>
> The printVarSummary indicates that you have a staggered grid. You probably should unstagger it with wrf_user_unstagger:
>
> http://www.ncl.ucar.edu/Document/Functions/WRF_arw/wrf_user_unstagger.shtml
>
> I believe this will also reduce your 3D arrays to 2D arrays.
>
> --Mary
>
>
> On Aug 4, 2011, at 4:44 AM, wei huang wrote:
>
>> Dear Respected Dennis and Mary, thank you very much for your help, however, now there is another problem which is given below. Kindly could you give me more clues about it? The code and its printVarSummary is given below.
>> Thanks again
>> ***********************************
>> 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"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
>> ;
>> begin
>> ;
>> a = addfile("wrfout_00.nc","r")
>>
>> t = 0
>> n = (/32,73/) ; lat index values of the points you want
>> m = (/52,105/) ; lon
>> w = wrf_user_getvar(a,"W",-1) ; relative humidity
>> p = wrf_user_getvar(a, "pressure",-1)
>> x = w(t,:,n,m)
>> y = p(t,:,n,m)
>> printVarSummary(x)
>> printVarSummary(y)
>> ;exit
>> ;************************************
>> wks = gsn_open_wks("x11","plt")
>>
>> resxy = True ; plot mods desired
>> resxy@gsnXRefLine = 0.0 ; draw ref line
>> resxy@trYReverse = True ; reverse Y-axis
>> resxy@xyLineThicknesses = 2
>> resxy@xyLineColors = (/"blue"/) ; change line colors
>> resxy@trYMinF = 0.0
>> resxy@trYMaxF = 1000.0
>>
>> resxy@pmLegendDisplayMode = "Always" ; turn on legend
>> resxy@trXMinF = -10
>> resxy@trXMaxF = 10
>> resxy@pmLegendSide = "Top" ; Change location of
>> resxy@pmLegendParallelPosF = .65 ; move units right
>> resxy@pmLegendOrthogonalPosF = -0.75 ; move units down
>> resxy@lgPerimOn = False
>> resxy@pmLegendWidthF = 0.12 ; Change width and
>> resxy@pmLegendHeightF = 0.12 ; height of legend.
>> resxy@lgLabelFontHeightF = .015 ; change font height
>> plt = gsn_csm_xy (wks,x,y, resxy)
>>
>> end
>>
>>
>> Variable: x
>> Type: float
>> Total Size: 640 bytes
>> 160 values
>> Number of Dimensions: 3
>> Dimensions and sizes: [bottom_top_stag |27] x [south_north | 2] x [west_east | 2]
>> Coordinates:
>> Number Of Attributes: 6
>> FieldType : 104
>> MemoryOrder : XYZ
>> description : z-wind component
>> units : m s-1
>> stagger : Z
>> coordinates : XLONG XLAT
>>
>>
>> Variable: y
>> Type: float
>> Total Size: 624 bytes
>> 156 values
>> Number of Dimensions: 3
>> Dimensions and sizes: [bottom_top | 27 x [south_north | 2] x [west_east | 2]
>> Coordinates:
>> Number Of Attributes: 6
>> FieldType : 104
>> MemoryOrder : XYZ
>> description : Pressure
>> units : hPa
>> stagger :
>> coordinates : XLONG XLAT
>> fatal: Number of subscripts do not match number of dimensions of variable,(2) Subscripts used, (3) Subscripts expected
>> fatal:Execute: Error occurred at or near line 4047 in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl
>>
>> fatal:Execute: Error occurred at or near line 41 in file rh.ncl
>>
>>
>> On Thu, Aug 4, 2011 at 5:17 AM, Mary Haley <haley@ucar.edu> wrote:
>> Further info: you can use wrf_user_ll_to_ij to get the ij indexes of the lat/lon values you want.
>>
>> http://www.ncl.ucar.edu/Document/Functions/WRF_arw/wrf_user_ll_to_ij.shtml
>>
>> --Mary
>>
>> On Aug 3, 2011, at 12:05 PM, Dennis Shea wrote:
>>
>> > You already have the vertical velocity (w, not omega).
>> > At each grid point, you have or can calculate the pressure levels
>> > (bottom_top_stag) ... call it p(Time,bottom_top_stag,south_north,west_east)
>> >
>> > You can not use the {...} syntax because the grid is curvilinear and not
>> > rectilinear, You must use standard indexing.
>> >
>> > t = 5
>> > n = (/32, 73/) ; lat index values of the points you want
>> > m = (/52, 105/) ; lon
>> >
>> > x = w(t,:,n,m)
>> > p = p(t,:,n,m)
>> >
>> > plt = gsn_csm_xy (wks,x,p,resxy)
>> >
>> >
>> > On 8/3/11 11:06 AM, wei huang wrote:
>> >> Hi, could anyone give me some help to modifying the code (omega_1.ncl
>> >> <http://www.ncl.ucar.edu/Applications/Scripts/omega_1.ncl>) for using
>> >> the WRF output. I’m interested to plot the vertical profile like this
>> >> omega plot. The wrf variable print is as follows:
>> >> thanks and regards
>> >>
>> >> Variable: w
>> >>
>> >> Type: float
>> >>
>> >> Total Size: 130572000 bytes
>> >>
>> >> 32643000 values
>> >>
>> >> Number of Dimensions: 4
>> >>
>> >> Dimensions and sizes:[Time | 48] x [bottom_top_stag | 27] x [south_north
>> >> | 100] x [west_east | 80]
>> >>
>> >> Coordinates:
>> >>
>> >> Number Of Attributes: 6
>> >>
>> >> coordinates : XLONG XLAT
>> >>
>> >> stagger :Z
>> >>
>> >> units :m s-1
>> >>
>> >> description : z-wind component
>> >>
>> >> MemoryOrder : XYZ
>> >>
>> >> FieldType :104
>> >>
>> >>
>> >>
>> >> _______________________________________________
>> >> 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
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
>
> <plt.000001.png>_______________________________________________
> 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 Thu Aug 4 10:41:00 2011

This archive was generated by hypermail 2.1.8 : Fri Aug 05 2011 - 14:53:55 MDT