Skip to content

Commit

Permalink
Convert grdblend test to documentation figure (#7968)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
PaulWessel authored Oct 23, 2023
1 parent b9e19a8 commit 53b78fa
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 98 deletions.
10 changes: 10 additions & 0 deletions doc/rst/source/grdblend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down
97 changes: 97 additions & 0 deletions doc/scripts/GMT_blendtype.sh
Original file line number Diff line number Diff line change
@@ -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


6 changes: 3 additions & 3 deletions doc/scripts/images.dvc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
outs:
- md5: c80408f923113a2ef18ad98111b0496a.dir
size: 33225142
nfiles: 201
- md5: d32873164f988cee578babc564af6bd6.dir
size: 33333883
nfiles: 203
path: images
6 changes: 3 additions & 3 deletions test/baseline/grdblend.dvc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
outs:
- md5: 45920baa4aca533105ba984d12245bb5.dir
size: 319127
nfiles: 8
- md5: c26aa6d39feeec2780603ba7ebe3eaf9.dir
size: 266208
nfiles: 7
path: grdblend
6 changes: 3 additions & 3 deletions test/baseline/psxy.dvc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
outs:
- md5: 5c6184bff710b71e7134155b26ca285f.dir
size: 9377472
nfiles: 143
- md5: 239f4bd18d38b222c7da4a1fa70bb7aa.dir
size: 9322544
nfiles: 142
path: psxy
89 changes: 0 additions & 89 deletions test/grdblend/blend.sh

This file was deleted.

0 comments on commit 53b78fa

Please sign in to comment.