Re: error message can't be solved

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Jun 10 2013 - 08:11:43 MDT

Hi Katja,

The error message:

> fatal:Number of dimensions in parameter (1) of (GetFillColor) is (1), (2) dimensions were expected
> fatal:Execute: Error occurred at or near line 95 in file alex.ncl

is telling you that the second argument (argument count starts at 0) to GetFillColor is supposed to be a 2D array, and you are giving it a 1D array.

If you read the documentation for GetFillColor:

http://www.ncl.ucar.edu/Document/Functions/Contributed/GetFillColor.shtml

you will see that the second argument needs to be an n x 3 array:

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl

        function GetFillColor (
                cnlevels [*] : numeric,
                cmap [*][3] : numeric,
                value [1] : numeric
        )

        
Unfortunately, this page is not very useful in telling you how to get an nx3 array. The nx3 array needs to be an array of RGB triplets, which you can get with the "gsn_retrieve_colormap" function.

Instead of using a colormap name, try this code:

> cnLevels=fspan(-55.0,5.0,13)
> gsn_define_colormap (wks,cmap)
> cmap = gsn_retrieve_colormap (wks)

I will fix the GetFillColor documentation to include this information. I will also see if "GetFillColor" can be enhanced to allow a color map name.

--Mary

On Jun 10, 2013, at 6:19 AM, Katja Lohmüller wrote:

>
> Hello ncl-talk, sorry it's me again
>
> I'm trying to plot a trajectory but I always get the same error report and I can't solve the problem.
> Maybe anyone of you is able to help me. That would be great.
>
> I have the script as follows (please don't pay attention to some lines which appear as a comment. they've just been some tries to solve my problem earlier):
>
>
> ;*************************************************
> ; traj_2.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 data
> ;************************************
> path = "/home/lohmueller/Desktop/BA/Amdardaten/Flutra01JanDLH_1.asc"
> data = asciiread(path,(/37,4/),"float")
> ; print(data)
> ntime=37
>
> ;********************************************
> wks = gsn_open_wks("pdf","trajalex") ; open workstation
> ;*********************************************
> ; color preps
> ;*****************************
>
> cnLevels=fspan(-55.0,5.0,13)
> cmap = ("BlWhRe")
> gsn_define_colormap (wks,cmap)
>
>
>
>
> res = True ; map resources
>
> res@gsnDraw = False ; don't draw
> res@gsnFrame = False ; don't advance frame
> res@vpWidthF = 0.80 ; make map bigger
> res@vpHeightF = 0.80
> res@mpMaxLatF = 60 ; select subregion
> res@mpMinLatF = 40
> res@mpMaxLonF = 45
> res@mpMinLonF = 27
>
> ;res@cnLevelSelectionMode = "ManualLevels" ; set manual contour levels
> ;res@cnMinLevelValF = -55. ; set the minimum contour level
> ;res@cnMaxLevelValF = 5. ; set the maximum contour level
> ;res@cnConstFLabelConstantSpacingF = 5
>
> ; label bar resources
> res_lb = True
> res_lb@vpWidthF = 0.60
> res_lb@vpHeightF = 0.10
> res_lb@lbPerimOn = False ; Turn off perimeter.
> res_lb@lbOrientation = "Horizontal" ; Default is vertical.
> res_lb@lbLabelStride = 2
> res_lb@lbLabelAlignment = "InteriorEdges" ; Default is "BoxCenters".
> res_lb@lbFillColors = (/"red","blue"/) ; Colors for boxes.
> res_lb@lbMonoFillPattern = True ; Fill them all solid.
> res_lb@lbLabelFontHeightF = 0.015
>
> res@tiMainString = "Trajektorie" ; title
>
> map = gsn_csm_map_ce(wks,res) ; create map
>
> ;*********************************************
> ;trajectory parameters
> ;*********************************************
>
>
> xpt= new(ntime,float)
> ypt= new(ntime,float)
> t= new(ntime,float)
>
>
> ;*********************************************
> ;plot parameters
> ;*********************************************
>
> pres = True
> pres@gsLineThicknessF = 2.0
>
> mres = True
> first= True
> last= True
>
> ;*********************************************
>
> do i=0,ntime-1
> ypt(i) = data(i,1)
> xpt(i)= data(i,0)
> t(i) = data(i,3)
> end do
>
> ;print(t)
> pres@gsLineColor=GetFillColor(cnLevels,cmap,t)
> gsn_polyline(wks,map,xpt,ypt,pres)
>
>
> ; do j= 0,ntime-2
> ; pres@gsLineColor=GetFillColor(cnLevels,cmap,t(j))
> ; gsn_polyline(wks,map,(/xpt(j),xpt(j+1)/),(/ypt(j),ypt(j+1)/),pres)
> ; end do
>
>
> ; create a unique marker to indicate the start of the trajectory
>
> first@gsMarkerSizeF = 20.0 ; marker size
> first@gsMarkerColor = "red" ; marker color
> last@gsMarkerSizeF = 9.0 ; marker size
> last@gsMarkerColor = "blue" ; marker color
>
> gsn_polymarker(wks,map,xpt(0),ypt(0),first) ;draw start of trajectory
> gsn_polymarker(wks,map,xpt(36),ypt(36),last) ;draw start of trajectory
> ;delete(first@gsMarkerColor)
> ;delete(first@gsMarkerSizeF)
>
>
>
> gsn_labelbar_ndc(wks,dimsizes(cnLevels)+1,cnLevels,0.30,0.30,res_lb)
>
> draw(map)
> frame(wks)
>
> end
>
>
> The error message is:
>
> fatal:Number of dimensions in parameter (1) of (GetFillColor) is (1), (2) dimensions were expected
> fatal:Execute: Error occurred at or near line 95 in file alex.ncl
>
> Thanks.
>
> Regards,
> 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
> <Flutra01JanDLH_1.asc>_______________________________________________
> 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 Jun 10 08:11:51 2013

This archive was generated by hypermail 2.1.8 : Tue Jun 11 2013 - 12:03:58 MDT