I generate two supposedly random data sets with grdmath
. As long as two grdmath
calls are separated by a call to another program everything seems fine (panels a) – c) in image below). But grdmath NRAND
gives exact the same values if it is called in direct succession (panels d) – f) in image below) or the calls are combined into a single call (panels g) – i) in image below)
After spending way to much time staring at patterns emerging in grdmath NRAND
data over in the other thread I don’t know what’s going on anymore. Maybe I just don’t see the woods for the trees. Am I doing something wrong here?
Using GMT version: 6.2.0_79f0ee5_2021.02.07
Code to play with:
#!/usr/bin/env bash
# # # # # # # # #
# #
# FIRST ROW #
# #
# # # # # # # # #
# grdmath calls seperated by calls to other programs
# First Set
gmt grdmath -R0/10/0/10 -I1 \
0 0.5 NRAND X ADD = xa.grd \
0 0.5 NRAND Y ADD = ya.grd
gmt grd2xyz xa.grd -o2 > x0.txt
gmt grd2xyz ya.grd -o2 > y0.txt
gmt convert -A x0.txt y0.txt > xy0.txt
# Second Set
gmt grdmath -R0/10/0/10 -I1 \
0 0.5 NRAND X ADD = xA.grd \
0 0.5 NRAND Y ADD = yA.grd
gmt grd2xyz xA.grd -o2 > x1.txt
gmt grd2xyz yA.grd -o2 > y1.txt
gmt convert -A x1.txt y1.txt > xy1.txt
# # # # # # # # # #
# #
# SECOND ROW #
# #
# # # # # # # # # #
# grdmath calls following directly onto each other
gmt grdmath -R0/10/0/10 -I1 \
0 0.5 NRAND X ADD = xb.grd \
0 0.5 NRAND Y ADD = yb.grd
gmt grdmath -R0/10/0/10 -I1 \
0 0.5 NRAND X ADD = xB.grd \
0 0.5 NRAND Y ADD = yB.grd
gmt grd2xyz xb.grd -o2 > x10.txt
gmt grd2xyz yb.grd -o2 > y10.txt
gmt convert -A x10.txt y10.txt > xy10.txt
gmt grd2xyz xB.grd -o2 > x11.txt
gmt grd2xyz yB.grd -o2 > y11.txt
gmt convert -A x11.txt y11.txt > xy11.txt
# # # # # # # # #
# #
# THIRD ROW #
# #
# # # # # # # # #
# grdmath calls combined into single call
gmt grdmath -R0/10/0/10 -I1 \
0 0.5 NRAND X ADD = xc.grd \
0 0.5 NRAND Y ADD = yc.grd \
0 0.5 NRAND X ADD = xC.grd \
0 0.5 NRAND Y ADD = yC.grd
gmt grd2xyz xc.grd -o2 > x20.txt
gmt grd2xyz yc.grd -o2 > y20.txt
gmt convert -A x20.txt y20.txt > xy20.txt
gmt grd2xyz xC.grd -o2 > x21.txt
gmt grd2xyz yC.grd -o2 > y21.txt
gmt convert -A x21.txt y21.txt > xy21.txt
# # # # # # # # #
# #
# PLOTTING #
# #
# # # # # # # # #
gmt begin not_really_random png
gmt subplot begin 3x3 -M10p/40p -A -Fs10c -JX10c -R0/10/0/10
# FIRST ROW
gmt subplot set
gmt plot xy0.txt -Sx0.25c -W1p,red -B -B+t"xy0"
gmt subplot set
gmt plot xy1.txt -S+0.25c -W1p,blue -B -B+t"xy1"
gmt subplot set
gmt plot xy0.txt -Sx0.25c -W1p,red
gmt plot xy1.txt -S+0.25c -W1p,blue -B -B+t"xy0 + xy1"
# SECOND ROW
gmt subplot set
gmt plot xy10.txt -Sx0.25c -W1p,red -B -B+t"xy10"
gmt subplot set
gmt plot xy11.txt -S+0.25c -W1p,blue -B -B+t"xy11"
gmt subplot set
gmt plot xy10.txt -Sx0.25c -W1p,red
gmt plot xy11.txt -S+0.25c -W1p,blue -B -B+t"xy10 + xy11"
# THIRD ROW
gmt subplot set
gmt plot xy20.txt -Sx0.25c -W1p,red -B -B+t"xy20"
gmt subplot set
gmt plot xy21.txt -S+0.25c -W1p,blue -B -B+t"xy21"
gmt subplot set
gmt plot xy20.txt -Sx0.25c -W1p,red
gmt plot xy21.txt -S+0.25c -W1p,blue -B -B+t"xy20 + xy21"
gmt subplot end
gmt end show