#99 Wiggly isocontours for structured data on a polar grid

closed-fixed
nobody
None
5
2013-06-23
2009-02-14
Joachim Namislow
No

For smooth structured data on a polar grid produced from a simple analytic function, isocontours are wiggly. When using GNUPLOT to produce isocontours from the same data, isocontours are smooth. Therefore, I suspect a problem with the isocontour finder.

The GNUPLOT result can be reproduced by typing:
gnuplot> set contour
gnuplot> set cntrparam levels 20
gnuplot> splot "asy.dat" using 1:2:3 w l 0

For the same data file, 'asy < test.asy' produces the equivalent figure. Setting '--' to '..' does not make a difference.

Discussion

  • Test data: asy.dat

     
    Attachments
  • File Added: test.asy

     
  • Asymptote script producing an isocontour plot for structured data

     
    Attachments
  • File Added: gnuplot.png

     
  • Output from GNUPLOT for asy.dat

     
    Attachments
  • Output from ASYMPOTE for asy.dat

     
    Attachments
  • File Added: asymptote.pdf

     
  • I forgot to add, that this happens with locally built package asymptote-1.59-1.fc10.x86_64 on Fedora 10.

     
  • Output from ASYMPOTE for a simple plane

     
    Attachments
  • File Added: plane.pdf

     
  • John Bowman
    John Bowman
    2009-02-15

    The problem is that the asy contour routines were designed assuming data on a rectangular lattice.
    The wiggles you notice can be mostly eliminated by changing in the 1.62 version of contour.asy:
    pair middle=0.5*(bleft+tright);
    to an arbitrary quadrilateral:
    pair middle=0.25*(bleft+bright+tleft+tright);
    The corresponding function value is then determined by linear interpolation.
    However, it seems better to simply use 2 triangles when the midpoint data is unavailable.
    That is how the current svn version works; the output now looks similar to the gnuplot example.

     
  • John Bowman
    John Bowman
    2009-02-15

    • status: open --> closed-fixed
     
  • That's a huge improvement, thanks! This finally completes the implementation of contour rendering for structured data which had been introduced after my report of bug 1984363. There were some small irregularities on the highly distorted grid left after migration from scattered to structured data (for the same set) which are now also gone.

     
  • Replacing "pair middle=0.5*(bleft+tright);" by "pair middle=0.25*(bleft+bright+tleft+tright);" in contour.asy pulled from asymptote-1.47-1.fc10 yields excellent results, actually better than the respective upstream contour.asy to which the modification has already been applied [for real data, not the synthetic one attached to this report]. Have there been some other relevant modifications?

     
  • John Bowman
    John Bowman
    2009-02-25

    Ok, I've reverted the other change I referred to regarding using 2 triangles per cell rather than 4.
    In other words, we again interpolate the 4 corner function values to estimate a missing midpoint value.
    Perhaps you can try out

    http://asymptote.svn.sourceforge.net/viewvc/asymptote/trunk/asymptote/base/contour.asy

    before the next release and see if you are happy with the output. This version should be functionally equivalent to what was in the 1.47 (and 1.62) release.

     
  • John Bowman
    John Bowman
    2009-02-25

    In my last comment, I meant to say "functionally equivalent, except for the fix to the definition of middle".

     
  • This bug is back since r4784 of contour.asy and needs to be reopened. The previous version r4027 worked correctly, though. Note that the isse is not restricted to polar grids as used for asy.dat.

     
    Attachments