Re: can't understand error message

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed Jul 17 2013 - 09:14:45 MDT

Katja,

In order to correctly use one-dimension coordinate arrays for the X and Y axis of a contour plot, the length of the coordinate arrays must be the same length as the corresponding dimension of the variable you are trying to plot.

You are contouring "slice" using an X coordinate array of "time2" and a Y coordinate array of "height2". This means that NCL will expect "slice" to be a two-dimensional array of size nh x nt, where "nh" is the length of height2, and "nt" is the length of time2: 2879 x 496.

I can't tell from your code what the size of slice is. It is helpful in this case to add the line:

  printVarSummary(slice)

to see what the dimensions of slice are.

Also, I'm not sure why you have this code:

time2=new(dimsizes(time),typeof(time))
height2=new(dimsizes(height),typeof(height))

time2=time
height2=height

;print(time2)

    res@sfXArray = time2
    res@sfYArray = height2

It is not necessary to make a copy of time and height. You should have just been able to do:

    res@sfXArray = time
    res@sfYArray = height

But, again, these arrays don't appear to be the size anyway, so you'll have to fix this.

Finally, you actually don't need to set sfXArray and sfYArray at all, if your variable "slice"
already has coordinate arrays attached to them. The printVarSummary command
that I suggested above will tell you if you have coordinate arrays. If you do, then
the printVarSummary command will look something like this:

Variable: slice
Type: float
Total Size: 5711936 bytes
            1427984 values
Number of Dimensions: 2
Dimensions and sizes: [time | 2879] x [height | 496]
Coordinates:
            time: [1..2879]
            height: [0.05…1000.5]
Number Of Attributes: 4
. . .

I fudged some of the numbers above, since I don't know what your "slice" array really looks like, or what the size is.
The point is, that if you see the two arrays listed under the "Coordinates:" line, then you know you have coordinate
arrays, and you then don't need :

    res@sfXArray = time
    res@sfYArray = height

--Mary

On Jul 17, 2013, at 3:27 AM, Katja Lohmüller wrote:

> Hello NCL-talk,
>
> I'm trying to create a contour plot with the variable time on the
> abscissa and height on the ordinate. The contours represent the target
> classification of cloud particles.
> Compiling my code, I get an error message I can't understand.
> Maybe one of you ist able to help me, that would be great!
>
> My code is as follows:
>
> ;************************************************************
> ; Target Classification 2D
> ;************************************************************
>
> ;************************************************************
> 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
>
> a=addfile("/localdata/Lohmueller/BA/Daten_Lindenberg/Classification/20130101_lindenberg_classification.nc",
> "r")
>
> time=a->time
> tar=a->target_classification
> height=a->height
>
> ;print(tar(2,:))
>
> wks= gsn_open_wks("pdf","Target")
>
> slice=tar(:,:)
>
> ;print(slice(2,:))
>
> gsn_define_colormap(wks,"BlGrYeOrReVi200")
>
>
> res = True
>
> res@gsnMaximize = True
> res@gsnPaperOrientation = "landscape"
> res@cnFillOn = True
> res@cnCellFillEdgeColor = "black"
> res@cnFillMode = "CellFill"
> res@cnLinesOn = False
> res@cnLineLabelsOn = False
> res@cnLevelSelectionMode = "ManualLevels" ; set manual
> contour levels
> res@cnMinLevelValF = 0. ; set the minimum contour level
> res@cnMaxLevelValF = 10. ; set the maximum contour level
> res@cnConstFLabelConstantSpacingF = 1
> res@cnFillColors = (/2,18,39,63,79,96,127,159,175,191,201/)
> ; set the colors to be used
> res@cnLevelSpacingF = 1
>
>
> res@lbLabelAutoStride = True
> res@lbPerimOn = False
> res@lbLabelStride = 2
>
>
> res@tiMainString = ""
>
> ;res@trGridType = "TriangularMesh"
>
> ;plot=gsn_xy(wks,time, height, False)
> time2=new(dimsizes(time),typeof(time))
> height2=new(dimsizes(height),typeof(height))
>
> time2=time
> height2=height
>
> ;print(time2)
>
> res@sfXArray = time2
> res@sfYArray = height2
>
> contour = gsn_csm_contour(wks,slice,res)
>
> end
>
>
> And the error message:
> warning:ScalarFieldSetValues: coordinate array sfXArray requires 496
> elements: defaulting
> warning:ScalarFieldSetValues: coordinate array sfYArray requires 2879
> elements: defaulting
>
>
> Thank you,
> Katja
> --
> Katja Lohmüller
> Institut fuer Meteorologie und Klimatologie
> Leibniz Universitaet Hannover
> Herrenhaeuser Str. 2
> 30419 Hannover
>
> Email: lohmueller@muk.uni-hannover.de
> Mobil: 0049 176 61396963
> Buero: 0049 511 762 2396
>
>
> _______________________________________________
> 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 Wed Jul 17 09:14:53 2013

This archive was generated by hypermail 2.1.8 : Fri Jul 19 2013 - 15:39:06 MDT