gmt icon indicating copy to clipboard operation
gmt copied to clipboard

grdcontour having trouble with tiny mignitudes

Open PaulWessel opened this issue 2 years ago • 4 comments

See the original PyGMT issue for background.

I have isolated a small 5x4 grid cut from the offending grid above that fails to let us contour the zero-contour. This hangs:

gmt grdcontour t.grd -V -C10 -JX15c > t.ps

The values are very small on either side of zero. Here is a graphical view of the values:

nodes

If I scale t.grd by 1000 and try to contour that it works. Since grdcontour works by never allowing any node to be exactly zero (we add a tiny amount), the issue of tiny in relation to these small values is the troubles, so I know where to look. Posting t.grd here for reference.

t.grd.zip

PaulWessel avatar May 24 '22 00:05 PaulWessel

GMT's grdcontour is a memory and CPU hungry algo (it makes a grid copy and swaps the zero for each contour). One day it may change to use the marching squares. Not pretending that I understand it from the wiki figures but that's what is used by GDAL, so ... one day.

joa-quim avatar May 24 '22 01:05 joa-quim

Sure, we wrote grdcontour back in the day (1988?) so not much info to go by - we invented our own algo. Of course it should be rewritten by anyone who has the time to do so!

PaulWessel avatar May 24 '22 01:05 PaulWessel

Didn't mean to reinvent. Maybe see if we can reuse lib code that's available.

joa-quim avatar May 24 '22 01:05 joa-quim

I remember I posted somewhere a comparison between contouring (cumping contours) with gdal_contour versus grdcontour. I think the time difference in completing was several 10x's.

anbj avatar May 24 '22 07:05 anbj