Defining triangle network for triangulate

Hi all!

I have been using GMT for about a decade now, and my maps are almost readable at this point :slight_smile:

Recently, I have been using GMT to plot results from finite element models. These models have pre-defined meshes, so I have been taking the model outputs with values at the triangle vertices, and using pscontour with the -E flag to define the network of triangles and plot the model results:

These plots look pretty nice, but with fine meshes my output PostScript files become unmanageably large. I can reduce the file size by using psconvert to generate a PNG or JPEG, but sometimes I prefer having the PostScript to make minor changes in Illustrator (e.g., when making graphics for presentations).

I can make the PostScript files much more tractable by sending the finite element results through triangulate, etc. and plotting the gridded background contours. However, triangulate does not seem to have an option for the user to define an existing network of triangles. This is fine except near discontinuities (for me, faults in the model), where the wrong interpolation will result in smearing across the discontinuity.

Am I correct in thinking there is no user-defined network option for triangulate? If so, is there any possibility of adding this functionality, as in pscontour?

Great. I have done GMT scripting for 30+ years and they are still unreadable.

Since triangulate does optimal Delauney triangulation I do not think it would be easy to add an option to prescribe your desired (presumably coarser) triangulation network that still preserves your fault. it would not be triangularization per se but some sort of averaging of the old nodes to fill in the new nodes. So there is nothing in GMT that can simply do this. Offering this scheme as perhaps it might work:

Use gmtselect with a simple polygon that captures the area of most detail (along the fault, presumably) to isolate those notes. Save them. Then do the opposite in gmtselect (-I) to get the further away nodes. Run those through blockmean at a suitable coarser interval, then triangulate them. Now you will need to remove the skinny new triangles that cross your fault exclusion zone then merge the two far-field and near-field triangularization. With luck, perhaps this works to reduce the size of the file sent to contour.

Another idea is to not futz around with PS files and use PDF instead. Much smaller and still vector graphics and editable in Illustrator. I appreciate your concerns about file size and some journals insisting on EPS rather than PDF out of ignorance. While I continue to pay the insane Adobe tax I rarely use it and prefer to do any and all embellishment of plots via GMT scripting rather than on-off edits in Illustrator. It pays off in the long run.