[ncl-talk] Reproducible gsn_add_poylline draw error [bug report]

David Brown dbrown at ucar.edu
Thu May 25 15:31:05 MDT 2017


Hi Alan,
I have checked in a fix for this problem. I will caution however that the
fix is only good because the numbers are still resolvable (barely) with
4-byte floating point numbers. If the spacing between the numbers that
define the X-Axis coordinate is decreased or their magnitude is increased
then the issue may reappear. More robust fixes are possible but will
require quite a bit more work.

A work-around is to subtract a uniform offset  (as large as possible) from
the coordinates, and then use explicit tick mark labels to put the original
values back into the plot.
 -dave

On Tue, May 23, 2017 at 11:20 AM, David Brown <dbrown at ucar.edu> wrote:

> Hi Alan,
> I will look into this.
>  -dave
>
> On Mon, May 22, 2017 at 3:36 PM, Alan Brammer <abrammer at albany.edu> wrote:
>
>> Hey NCL devs,
>>
>> I’ve come across a sometimes avoidable but easily reproducible bug, that
>> seems to still exist in 6.4.0
>>
>> Basically when a polyline is added to a plot with an axis on the order of
>> time units (e.g. "hours since 1800”  or  > 1e6 ) and extends beyond the x
>> limits of the plot,  it looks like the polyline function truncates the end
>> of the lines erroneously.
>> And then I just kind of broke it completely with the last plot.
>>
>> Couldn’t work out if the error is occurring in NhlAddPrimitive or in the
>> create polytype section.
>>
>> Simple example script inline below with the output plots attached.
>>
>>
>> Alan
>>
>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>>
>> wks = gsn_open_wks("png","polyline_error")
>>
>> times := fspan(1881552, 1881984, 73)
>> times at units = "hours since 1800-01-01"
>>
>> stime = times(8)
>> ltime = times(50)
>>
>> res := True
>> res at gsnDraw = False
>> res at gsnFrame = False
>> res at trXMinF = stime
>> res at trXMaxF = ltime
>>
>> x := times
>> y := sin(x) +4.
>> res at trYMaxF = max(y)
>> res at trYMinF = min(y)
>>
>> ;;;; .000001.png
>> plot = gsn_csm_blank_plot(wks, res)
>> line = gsn_add_polyline(wks, plot, x, y, False)
>> draw(plot)
>> frame(wks)
>>
>> ;;;; .000002.png
>> res at trXMinF = stime
>> res at trXMaxF = times(15)
>> plot = gsn_csm_blank_plot(wks, res)
>> line = gsn_add_polyline(wks, plot, x, y, False)
>> draw(plot)
>> frame(wks)
>>
>>
>> ; oh jeez,   it gets worse.
>> ;;;; .000003.png
>> res at trYMinF = min(y)+0.00001    ;; trim just the very very bottom off
>> the plot and watch all hell break lose.
>> plot = gsn_csm_blank_plot(wks, res)
>> line = gsn_add_polyline(wks, plot, x, y, False)
>> draw(plot)
>> frame(wks)
>> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170525/646a8181/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: polyline_error.000003.png
Type: image/png
Size: 23258 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170525/646a8181/attachment.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: polyline_error.000002.png
Type: image/png
Size: 22851 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170525/646a8181/attachment-0001.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: polyline_error.000001.png
Type: image/png
Size: 27477 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170525/646a8181/attachment-0002.png 


More information about the ncl-talk mailing list