From 53b78fac59ccfcee2a5e822bf4be3f52289675be Mon Sep 17 00:00:00 2001 From: Paul Wessel Date: Mon, 23 Oct 2023 16:28:48 +0200 Subject: [PATCH] Convert grdblend test to documentation figure (#7968) * Convert grdblend test to documentation figure Removing the old test/grdblend/blend.sh and add doc/scripts/GMT_blend.sh instead, with figure link in grdblend documentation. * Rename script * Create GMT_blend.sh * Update images.dvc * Update grdblend.rst --- doc/rst/source/grdblend.rst | 10 ++++ doc/scripts/GMT_blendtype.sh | 97 ++++++++++++++++++++++++++++++++++++ doc/scripts/images.dvc | 6 +-- test/baseline/grdblend.dvc | 6 +-- test/baseline/psxy.dvc | 6 +-- test/grdblend/blend.sh | 89 --------------------------------- 6 files changed, 116 insertions(+), 98 deletions(-) create mode 100755 doc/scripts/GMT_blendtype.sh delete mode 100755 test/grdblend/blend.sh diff --git a/doc/rst/source/grdblend.rst b/doc/rst/source/grdblend.rst index 5fcc4993e00..c111c6856cf 100644 --- a/doc/rst/source/grdblend.rst +++ b/doc/rst/source/grdblend.rst @@ -117,6 +117,16 @@ Optional Arguments for subsequent grids we only consider them in the decision if the values are :math:`z \ge 0` (**+p**) or :math:`z \le 0` (**+n**), respectively. + +.. figure:: /_images/GMT_blendtype.* + :width: 500 px + :align: center + + Blending is just one option what happens in areas of overlap. The dashed + lines indicates the "inner" regions where the relative weights are 1 and + between the dashed lines and the grid borders the relative weights are + cosine-tapered down to 0. + .. _-Q: **-Q** diff --git a/doc/scripts/GMT_blendtype.sh b/doc/scripts/GMT_blendtype.sh new file mode 100755 index 00000000000..d9427fda568 --- /dev/null +++ b/doc/scripts/GMT_blendtype.sh @@ -0,0 +1,97 @@ +#!/usr/bin/env bash +# + +# "Inner" regions when blending (dashed lines) +cat << EOF > info.txt +a.nc -R1/5/1/5 1 +b.nc -R5/10/1/4 1 +c.nc -R5/9/5/9 1 +d.nc -R1/5/5/9 1 +EOF +# Make 4 constant grids +gmt grdmath -R0/6/0/6 -I0.1 0 = a.nc +gmt grdmath -R4/10/0/5 -I0.1 2 = b.nc +gmt grdmath -R0/6/4/10 -I0.1 8 = c.nc +gmt grdmath -R4/10/4/10 -I0.1 4 = d.nc + +gmt begin GMT_blendtype + gmt set GMT_THEME cookbook FONT_TAG 10p,Helvetica-Bold,black FONT_ANNOT_PRIMARY 8p + gmt makecpt -Crainbow -T0/8 + gmt subplot begin 2x3 -Fs5c/3c -Sct -Srl -R0/10/0/10 -A0+jTR + gmt subplot set 0 -Aaverage + # 0. Just add them up + gmt grdblend ?.nc -R0/10/0/10 -I0.1 -Gblend.nc + gmt grdimage blend.nc + # Draw grid outlines + cat <<- EOF > lines.txt + > a + 6 0 + 6 6 + 0 6 + > b + 4 0 + 4 5 + 10 5 + > c + 4 10 + 4 4 + 10 4 + > d + 6 10 + 6 4 + 0 4 + EOF + gmt plot lines.txt -W1p + # 1. Blend the overlapping grids + gmt grdblend info.txt -I0.1 -Gblend.nc + gmt subplot set 1 -Ablend + gmt grdimage blend.nc + gmt plot lines.txt -W1p + # Draw the inside regions + gmt plot -W0.5p,- -L <<- EOF + > a + 1 1 + 5 1 + 5 5 + 1 5 + > b + 5 1 + 10 1 + 10 4 + 5 4 + > c + 5 5 + 9 5 + 9 9 + 5 9 + > d + 1 5 + 5 5 + 5 9 + 1 9 + EOF + # 2. Last grid encountered matters + gmt grdblend ?.nc -Co -I0.1 -Gblend.nc + gmt subplot set 2 -Alast + gmt grdimage blend.nc + gmt plot lines.txt -W1p + # 3. First grid encountered matters + gmt grdblend ?.nc -Cf -I0.1 -Gblend.nc + gmt subplot set 3 -Afirst + gmt grdimage blend.nc + gmt plot lines.txt -W1p + # 4. Grid with lowest value matters + gmt grdblend ?.nc -Cl -I0.1 -Gblend.nc + gmt subplot set 4 -Alow + gmt grdimage blend.nc + gmt plot lines.txt -W1p + # 5. Grid with highest value matters + gmt grdblend ?.nc -Cu -I0.1 -Gblend.nc + gmt subplot set 5 -Ahigh + gmt grdimage blend.nc + gmt plot lines.txt -W1p + gmt subplot end + gmt colorbar -DJRM -B1 +gmt end show + + diff --git a/doc/scripts/images.dvc b/doc/scripts/images.dvc index 9c40be1003c..92941e46363 100644 --- a/doc/scripts/images.dvc +++ b/doc/scripts/images.dvc @@ -1,5 +1,5 @@ outs: -- md5: c80408f923113a2ef18ad98111b0496a.dir - size: 33225142 - nfiles: 201 +- md5: d32873164f988cee578babc564af6bd6.dir + size: 33333883 + nfiles: 203 path: images diff --git a/test/baseline/grdblend.dvc b/test/baseline/grdblend.dvc index 1c86089867f..1855ddff897 100644 --- a/test/baseline/grdblend.dvc +++ b/test/baseline/grdblend.dvc @@ -1,5 +1,5 @@ outs: -- md5: 45920baa4aca533105ba984d12245bb5.dir - size: 319127 - nfiles: 8 +- md5: c26aa6d39feeec2780603ba7ebe3eaf9.dir + size: 266208 + nfiles: 7 path: grdblend diff --git a/test/baseline/psxy.dvc b/test/baseline/psxy.dvc index ce21a614da3..530cb097b71 100644 --- a/test/baseline/psxy.dvc +++ b/test/baseline/psxy.dvc @@ -1,5 +1,5 @@ outs: -- md5: 5c6184bff710b71e7134155b26ca285f.dir - size: 9377472 - nfiles: 143 +- md5: 239f4bd18d38b222c7da4a1fa70bb7aa.dir + size: 9322544 + nfiles: 142 path: psxy diff --git a/test/grdblend/blend.sh b/test/grdblend/blend.sh deleted file mode 100755 index aef59c5cdce..00000000000 --- a/test/grdblend/blend.sh +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/env bash -# - -ps=blend.ps - -# Make 4 constant grids -gmt grdmath -R0/6/0/6 -I0.1 0 = a.nc -gmt grdmath -R4/10/0/5 -I0.1 2 = b.nc -gmt grdmath -R0/6/4/10 -I0.1 8 = c.nc -gmt grdmath -R4/10/4/10 -I0.1 4 = d.nc -gmt makecpt -Crainbow -T0/8 > t.cpt -# Just add them up -gmt grdblend ?.nc -R0/10/0/10 -I0.1 -Gblend.nc -gmt grdimage blend.nc -Ct.cpt -JX3i -P -B2 -BWSne -K -X0.75i -Y0.75i > $ps -# Draw grid outlines -cat << EOF > lines.txt -> a -6 0 -6 6 -0 6 -> b -4 0 -4 5 -10 5 -> c -4 10 -4 4 -10 4 -> d -6 10 -6 4 -0 4 -EOF -gmt psxy -Rblend.nc lines.txt -J -O -K -W1p >> $ps -cat << EOF > info.txt -a.nc -R1/5/1/5 1 -b.nc -R5/10/1/4 1 -c.nc -R5/9/5/9 1 -d.nc -R1/5/5/9 1 -EOF -echo 10 10 average | gmt pstext -R -J -O -K -Dj0.1i/0.1i -F+jTR+f14p >> $ps -# Blend the overlapping grids -gmt grdblend info.txt -R0/10/0/10 -I0.1 -Gblend.nc -gmt grdimage blend.nc -Ct.cpt -J -O -X3.5i -B2 -BWSne -K >> $ps -gmt psxy -Rblend.nc lines.txt -J -O -K -W1p >> $ps -# Draw the inside regions -gmt psxy -R -J -O -K -W0.5p,- -L << EOF >> $ps -> a -1 1 -5 1 -5 5 -1 5 -> b -5 1 -10 1 -10 4 -5 4 -> c -5 5 -9 5 -9 9 -5 9 -> d -1 5 -5 5 -5 9 -1 9 -EOF -echo 10 10 blend | gmt pstext -R -J -O -K -Dj0.1i/0.1i -F+jTR+f14p >> $ps -gmt psscale -Ct.cpt -Dx3.25i/1.5i+w2.8i/0.15i+jML -O -K -B1 >> $ps -gmt grdblend ?.nc -Co -R0/10/0/10 -I0.1 -Gblend.nc -gmt grdimage blend.nc -Ct.cpt -J -O -X-3.5i -Y3.3i -B2 -BWsne -K >> $ps -gmt psxy -Rblend.nc lines.txt -J -O -K -W1p >> $ps -echo 10 10 last | gmt pstext -R -J -O -K -Dj0.1i/0.1i -F+jTR+f14p >> $ps -gmt grdblend ?.nc -Cf -R0/10/0/10 -I0.1 -Gblend.nc -gmt grdimage blend.nc -Ct.cpt -J -O -X3.5i -B2 -BWsne -K >> $ps -gmt psxy -Rblend.nc lines.txt -J -O -K -W1p >> $ps -echo 10 10 first | gmt pstext -R -J -O -K -Dj0.1i/0.1i -F+jTR+f14p >> $ps -gmt psscale -Ct.cpt -Dx3.25i/1.5i+w2.8i/0.15i+jML -O -K -B1 >> $ps -gmt grdblend ?.nc -Cl -R0/10/0/10 -I0.1 -Gblend.nc -gmt grdimage blend.nc -Ct.cpt -J -O -X-3.5i -Y3.3i -B2 -BWsne -K >> $ps -echo 10 10 low | gmt pstext -R -J -O -K -Dj0.1i/0.1i -F+jTR+f14p >> $ps -gmt psxy -Rblend.nc lines.txt -J -O -K -W1p >> $ps -gmt grdblend ?.nc -Cu -R0/10/0/10 -I0.1 -Gblend.nc -gmt grdimage blend.nc -Ct.cpt -J -O -X3.5i -B2 -BWsne -K >> $ps -gmt psxy -Rblend.nc lines.txt -J -O -K -W1p >> $ps -echo 10 10 high | gmt pstext -R -J -O -K -Dj0.1i/0.1i -F+jTR+f14p >> $ps -gmt psscale -Ct.cpt -Dx3.25i/1.5i+w2.8i/0.15i+jML -O -B1 >> $ps -