tgranular2img: allow awk(1) syntax for grain coloring - granular - granular dynamics simulation
(HTM) git clone git://src.adamsgaard.dk/granular
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit a099bd7de3cb5145572c4be296b12df240c594d6
(DIR) parent 9277911965be20b4d8493ee43750c9bd5f107da1
(HTM) Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Thu, 22 Apr 2021 21:30:47 +0200
granular2img: allow awk(1) syntax for grain coloring
Diffstat:
M granular2img | 4 ++--
M granular2img.1 | 15 ++++++++++++---
2 files changed, 14 insertions(+), 5 deletions(-)
---
(DIR) diff --git a/granular2img b/granular2img
t@@ -4,7 +4,7 @@ usage() {
printf 'usage: %s [-f field] [-h] [-l label] [-t term]\n' "${0##*/}" 1>&2
}
-field="1"
+field="$1"
label="diameter [m]"
term="pdf"
while getopts 'f:hl:t:' arg; do
t@@ -22,7 +22,7 @@ if test $# != 0; then
exit 1
fi
-awk -F' ' "{print \$2, \$3, \$1 / 2.0, \$${field}}" \
+awk -F' ' "{print \$2, \$3, \$1 / 2.0, ${field}}" \
| gnuplot -e "set term ${term};\
set xlabel 'x [m]';\
set ylabel 'y [m]';\
(DIR) diff --git a/granular2img.1 b/granular2img.1
t@@ -21,8 +21,9 @@ written to stdout.
The options are as follows:
.Bl -tag -width Ds
.It Fl f Ar field
-Specify the column number to use for grain coloring (default: 1
-(diameter)).
+Specify the
+.Xr awk 1
+expression to use for grain coloring (default: '$1' (diameter)).
.It Fl h
Show help text.
.It Fl l Ar label
t@@ -48,10 +49,18 @@ unspecified error
.Sh EXAMPLES
.Dl $ granularpacking | granular2img -t png > out.png
.Pp
-.Dl $ granularpacking | granular2img -f 2 -l 'x pos. [m]' | zathura -
+.Bd -literal -offset indent
+$ granularpacking | granular2img -f '$2' -l 'x pos. [m]' \\
+ | zathura -
+.Ed
+.Bd -literal -offset indent
+$ granularpacking | granular2img -f '$2*$3' -l 'x*y pos. [m]' \\
+ | zathura -
+.Ed
.Pp
.Dl $ granular2img < packing.tsv > out.pdf
.Sh SEE ALSO
+.Xr awk 1 ,
.Xr gnuplot 1 ,
.Xr granular2vtu 1 ,
.Xr granular 5