[ncl-talk] gsn_add_polyline error

Vollaro, David dvollaro at albany.edu
Wed Jun 1 11:38:09 MDT 2016


Hi,


I am trying to add a line that has missing values onto an XY plot using gsn_add_polyline.  If the missing values are arranged such that 2 segments are created(ie MM###MMM## where M=missval and #=a number) the following error occurs:


fatal:Dimension sizes on right hand side of assignment do not match dimension sizes of left hand side
fatal:["Execute.c":8575]:Execute: Error occurred at or near line 85 in file polylin_order.ncl

If only 1 segment is created(#####MMMM) then everything works fine.  A simplified version of the script is below with a sample dataset attached.  Any help is appreciated.

Dave


---------------------------------------------------------------------------------------------------------------------

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"
;-----------------------------------------------------------------;
;polylin_test.ncl
; djv 3/16
; This program is tests polyline issue w/missvals.  If have more than 1 segment
; and use gsn_add_polyline will get error:
;fatal:Dimension sizes on right hand side of assignment do not match dimension sizes of left hand side
;fatal:["Execute.c":8575]:Execute: Error occurred at or near line 95 in file ploylin_order.ncl

; Can avoid using gsn_polyline but cannot control order of plotting
;-----------------------------------------------------------------;

begin
 res = True
 resplan = True
;------------------ User PARAMETERS -----------------------------

;------------------ End User PARAMETERS -------------------------

   datafile = "test.dat"
   data   = asciiread(datafile,-1,"string")
   vert_accel = stringtofloat(str_get_cols(data, 0,6))
   altkm = stringtofloat(str_get_cols(data, 7,12))
   vert_accel at _FillValue = -32767
   altkm at _FillValue = -32767

   mintime = 0
   maxtime = numAsciiRow(datafile) - 1
   flight_time = fspan(mintime,maxtime,maxtime+1)

;Set some resources for xy plots
    ytres = True              ;Resources for timeseries plots
    ytres at tiXAxisString = "minutes"
    ytres at trXMinF    = 0
    ytres at trXMaxF    = maxtime
    ytres at xyLineThicknessF = 2.
    ytres at gsnDraw     = False     ;Set to False so can plot multi-colored lines
    ytres at gsnFrame    = False
    ytres at tiYAxisOn   = True

; Set plt resources for vert accel
    ytresa = ytres
    ytresa at trYMinF = -2
    ytresa at trYMaxF = 2
    ytresa at tiYAxisString = "Vacc(Yellow)"
;     ytresa at xyCurveDrawOrder = "PreDraw"
;     ytresa at xyLineColor = -1          ;Set=Transparent so polyline colors work

; Set plt resources for altitude
    altres = ytres
    altres at trYMinF = 10
    altres at trYMaxF = 15
    altres at tiYAxisString = "Alt"
    altres at xyLineColor = 1          ;Set=Transparent so polyline colors work
    wks = gsn_open_wks("X11","outfile")

    plot = gsn_csm_xy2(wks,flight_time(mintime:maxtime),vert_accel(mintime:maxtime),altkm(mintime:maxtime),ytresa,altres)

;----------------------------------------------
;   Overlay colored lines
;   gsn_add_polyline does not work if segment is brken up into 2 due to missval
;   Will work w/gsn_ployline but will plot 1st and then overlay gsn_csm_xy plt
;----------------------------------------------
     dum1       = new(20,"graphic")
     polyres = True
     polyres at gsLineThicknessF = 8.
     polyres at gsLineColor = "yellow"
;     ytresa at tfPolyDrawOrder = "PostDraw"

    if(any(.not.ismissing(vert_accel(mintime:maxtime))))then
;        dum1(0) = gsn_add_polyline(wks,plot,flight_time(mintime:maxtime),vert_accel(mintime:maxtime),polyres)

     gsn_polyline(wks,plot,flight_time(mintime:maxtime),vert_accel(mintime:maxtime),polyres)
    end if
    draw(plot)
    frame(wks)
end

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160601/0cc756fe/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.dat
Type: application/octet-stream
Size: 364 bytes
Desc: test.dat
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160601/0cc756fe/attachment.obj 


More information about the ncl-talk mailing list