<div dir="ltr"><div class="gmail_default"><font face="arial, helvetica, sans-serif">Hi David,</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"><br></font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif">The issue is that when you have a line with missing value segments, a graphical object has to be created for every line segment. It therefore may return several objects if you have several line segments.</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"><br></font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif">You have this code:</font></div><div class="gmail_default">
<p class=""><font face="arial, helvetica, sans-serif"><span class=""> dum1(0) = </span><span class="">gsn_add_polyline</span><span class="">(wks,plot,flight_time(mintime:maxtime),vert_accel(mintime:maxtime),polyres)</span></font></p><p class=""><span class=""><font face="arial, helvetica, sans-serif">which is failing because "dum1(0)" is one object, but gsn_add_polyline is trying to return two objects.</font></span></p><p class=""><font face="arial, helvetica, sans-serif"><span class="">The error "</span><span style="color:rgb(0,0,0)">Dimension sizes on right hand side of assignment do not match dimension sizes of left hand side", was telling you that the thing on the left of the "=" doesn't match what the right side is trying to return.</span></font></p><p class=""><span class=""><font face="arial, helvetica, sans-serif">If you simply remove or comment this line:</font></span></p><p class=""><span class=""><font face="arial, helvetica, sans-serif">
</font></span></p><p class=""><span class=""><font face="arial, helvetica, sans-serif"> dum1 = new(20,"graphic")</font></span></p><p class=""><span class=""><font face="arial, helvetica, sans-serif">and then do this:</font></span></p><p class=""><span class=""><font face="arial, helvetica, sans-serif">
</font></span></p><p class=""><span class=""><font face="arial, helvetica, sans-serif"> dum1 = gsn_add_polyline(wks,plot,flight_time(mintime:maxtime),vert_accel(mintime:maxtime),polyres)</font></span></p><p class=""><font face="arial, helvetica, sans-serif">it should work fine.</font></p><p class=""><font face="arial, helvetica, sans-serif">BTW, I think to get gsn_polyline to work you could move the "draw(plot)" command to before the gsn_polyline call. However, it's better to use gsn_add_polyline in general, because then the lines become part of the plot. If you need to resize the plot later, like in a call to gsn_panel, then the lines will stay with the plot.</font></p><p class=""><font face="arial, helvetica, sans-serif">--Mary</font></p><p class=""><br></p></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 1, 2016 at 11:38 AM, Vollaro, David <span dir="ltr"><<a href="mailto:dvollaro@albany.edu" target="_blank">dvollaro@albany.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Hi,</p>
<p><br>
</p>
<p>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:</p>
<p><br>
</p>
<p></p>
<div>fatal:Dimension sizes on right hand side of assignment do not match dimension sizes of left hand side<br>
fatal:["Execute.c":8575]:Execute: Error occurred at or near line 85 in file polylin_order.ncl<br>
<br>
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.<br>
<br>
Dave<br>
</div>
<p></p>
<p><br>
</p>
<p>---------------------------------------------------------------------------------------------------------------------</p>
<p></p>
<div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"<br>
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"<br>
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"<br>
;-----------------------------------------------------------------; <br>
;polylin_test.ncl<br>
; djv 3/16<br>
; This program is tests polyline issue w/missvals. If have more than 1 segment <br>
; and use gsn_add_polyline will get error:<br>
;fatal:Dimension sizes on right hand side of assignment do not match dimension sizes of left hand side<br>
;fatal:["Execute.c":8575]:Execute: Error occurred at or near line 95 in file ploylin_order.ncl<br>
<br>
; Can avoid using gsn_polyline but cannot control order of plotting<br>
;-----------------------------------------------------------------;<br>
<br>
begin<br>
res = True<br>
resplan = True<br>
;------------------ User PARAMETERS -----------------------------<br>
<br>
;------------------ End User PARAMETERS ------------------------- <br>
<br>
datafile = "test.dat"<br>
data = asciiread(datafile,-1,"string")<br>
vert_accel = stringtofloat(str_get_cols(data, 0,6))<br>
altkm = stringtofloat(str_get_cols(data, 7,12))<br>
vert_accel@_FillValue = -32767<br>
altkm@_FillValue = -32767<br>
<br>
mintime = 0<br>
maxtime = numAsciiRow(datafile) - 1<br>
flight_time = fspan(mintime,maxtime,maxtime+1)<br>
<br>
;Set some resources for xy plots <br>
ytres = True ;Resources for timeseries plots<br>
ytres@tiXAxisString = "minutes"<br>
ytres@trXMinF = 0<br>
ytres@trXMaxF = maxtime<br>
ytres@xyLineThicknessF = 2.<br>
ytres@gsnDraw = False ;Set to False so can plot multi-colored lines<br>
ytres@gsnFrame = False<br>
ytres@tiYAxisOn = True <br>
<div>; Set plt resources for vert accel<br>
ytresa = ytres<br>
ytresa@trYMinF = -2<br>
ytresa@trYMaxF = 2<br>
ytresa@tiYAxisString = "Vacc(Yellow)"<br>
; ytresa@xyCurveDrawOrder = "PreDraw"<br>
; ytresa@xyLineColor = -1 ;Set=Transparent so polyline colors work<br>
<br>
; Set plt resources for altitude<br>
altres = ytres<br>
altres@trYMinF = 10<br>
altres@trYMaxF = 15<br>
altres@tiYAxisString = "Alt"<br>
altres@xyLineColor = 1 ;Set=Transparent so polyline colors work<br>
wks = gsn_open_wks("X11","outfile")<br>
<br>
plot = gsn_csm_xy2(wks,flight_time(mintime:maxtime),vert_accel(mintime:maxtime),altkm(mintime:maxtime),ytresa,altres)<br>
<br>
;----------------------------------------------<br>
; Overlay colored lines<br>
; gsn_add_polyline does not work if segment is brken up into 2 due to missval<br>
; Will work w/gsn_ployline but will plot 1st and then overlay gsn_csm_xy plt<br>
;----------------------------------------------<br>
dum1 = new(20,"graphic")<br>
polyres = True<br>
polyres@gsLineThicknessF = 8.<br>
polyres@gsLineColor = "yellow"<br>
; ytresa@tfPolyDrawOrder = "PostDraw"<br>
<br>
if(any(.not.ismissing(vert_accel(mintime:maxtime))))then<br>
; dum1(0) = gsn_add_polyline(wks,plot,flight_time(mintime:maxtime),vert_accel(mintime:maxtime),polyres)<br>
<br>
gsn_polyline(wks,plot,flight_time(mintime:maxtime),vert_accel(mintime:maxtime),polyres)<br>
end if<br>
draw(plot)<br>
frame(wks)<br>
end</div>
</div>
<br>
<p></p>
</div>
</div>
<br>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>