tadd plotting tools and their man pages - cngf-pf - continuum model for granula… | |
git clone git://src.adamsgaard.dk/cngf-pf | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 13318ad1e3e39b9771899f4b8055b97752f5b320 | |
parent 4e5828e062c676396ca0c67660c83cc6755f7002 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Fri, 10 Sep 2021 13:08:30 +0200 | |
add plotting tools and their man pages | |
Diffstat: | |
M Makefile | 18 +++++++++++++----- | |
A cngf-pf-plot-depth-evol | 31 +++++++++++++++++++++++++++++… | |
A cngf-pf-plot-depth-evol.1 | 94 +++++++++++++++++++++++++++++… | |
A cngf-pf-plot-point-evol | 37 +++++++++++++++++++++++++++++… | |
A cngf-pf-plot-point-evol.1 | 109 +++++++++++++++++++++++++++++… | |
D plot_cngf_pf_evolution | 27 --------------------------- | |
6 files changed, 284 insertions(+), 32 deletions(-) | |
--- | |
diff --git a/Makefile b/Makefile | |
t@@ -14,6 +14,10 @@ BIN = \ | |
max_depth_simple_shear\ | |
shear_flux\ | |
+SCRIPTS = \ | |
+ cngf-pf-plot-point-evol\ | |
+ cngf-pf-plot-depth-evol\ | |
+ | |
SRC = \ | |
arrays.c\ | |
fluid.c\ | |
t@@ -31,7 +35,10 @@ CNGFPF_CFLAGS = ${CFLAGS} ${INCS} -DVERSION=\"${VERSION}\" | |
CNGFPF_LDFLAGS = ${LDFLAGS} | |
CNGFPF_LIBS = ${LIBS} | |
-MAN1 = ${BIN:=.1} | |
+MAN1 = \ | |
+ ${BIN:=.1}\ | |
+ ${SCRIPTS:=.1}\ | |
+ | |
DOC = \ | |
README.md\ | |
LICENSE\ | |
t@@ -56,7 +63,8 @@ ${BIN}: ${OBJ} | |
dist: | |
rm -rf "${NAME}-${VERSION}" | |
mkdir -p "${NAME}-${VERSION}" | |
- cp -rf ${MAN1} ${DOC} ${HDR} ${SRC} Makefile test "${NAME}-${VERSION}" | |
+ cp -rf ${MAN1} ${DOC} ${HDR} ${SRC} ${BIN:=.c} ${SCRIPTS} Makefile \ | |
+ "${NAME}-${VERSION}" | |
# make tarball | |
tar cf - "${NAME}-${VERSION}" | \ | |
gzip -c > "${NAME}-${VERSION}.tar.gz" | |
t@@ -65,8 +73,8 @@ dist: | |
install: ${BIN} | |
# installing executables | |
mkdir -p ${DESTDIR}${PREFIX}/bin | |
- cp -f ${BIN} ${DESTDIR}${PREFIX}/bin | |
- for f in ${BIN}; do chmod 755 ${DESTDIR}${PREFIX}/bin/$$f; done | |
+ cp -f ${BIN} ${SCRIPTS} ${DESTDIR}${PREFIX}/bin | |
+ for f in ${BIN} ${SCRIPTS}; do chmod 755 ${DESTDIR}${PREFIX}/bin/$$f; … | |
# installing documentation and license information | |
mkdir -p ${DESTDIR}${DOCPREFIX} | |
cp -f ${DOC} ${DESTDIR}${DOCPREFIX} | |
t@@ -78,7 +86,7 @@ install: ${BIN} | |
uninstall: | |
# removing executable files | |
- for f in ${BIN}; do rm -f ${DESTDIR}${PREFIX}/bin/$$f; done | |
+ for f in ${BIN} ${SCRIPTS}; do rm -f ${DESTDIR}${PREFIX}/bin/$$f; done | |
# removing documentation and license information | |
for f in ${DOC}; do rm -f ${DESTDIR}${DOCPREFIX}/$$f; done | |
-rmdir ${DESTDIR}${DOCPREFIX} | |
diff --git a/cngf-pf-plot-depth-evol b/cngf-pf-plot-depth-evol | |
t@@ -0,0 +1,31 @@ | |
+#!/bin/sh | |
+ | |
+usage() { | |
+ printf 'usage: %s [-f field] [-h] [-l label] [-t term] file..\n' "${0#… | |
+} | |
+ | |
+field="2" | |
+label="shear velocity [m/s]" | |
+term="pdf" | |
+while getopts 'f:hl:t:' arg; do | |
+ case "${arg}" in | |
+ f) field="${OPTARG}" ;; | |
+ h) usage; exit 0 ;; | |
+ l) label="${OPTARG}" ;; | |
+ t) term="${OPTARG}" ;; | |
+ *) usage; exit 1 ;; | |
+ esac | |
+done | |
+shift $((OPTIND - 1)) | |
+ | |
+for f in "$@"; do | |
+ cut -f${field} "$f" | transpose | |
+done | transpose | \ | |
+gnuplot -e "set term ${term};\ | |
+ set xlabel 'Output file [-]';\ | |
+ set ylabel 'i_z [-]';\ | |
+ set cblabel '${label}';\ | |
+ set autoscale xfix;\ | |
+ set autoscale yfix;\ | |
+ plot '-' matrix with image title ''" | |
+ | |
diff --git a/cngf-pf-plot-depth-evol.1 b/cngf-pf-plot-depth-evol.1 | |
t@@ -0,0 +1,94 @@ | |
+.Dd $Mdocdate$ | |
+.Dt CNGF-PF-PLOT-DEPTH-EVOL 1 | |
+.Os | |
+.Sh NAME | |
+.Nm cngf-pf-plot-depth-evol | |
+.Nd plot evolution of a model parameter at all depths | |
+.Sh SYNOPSIS | |
+.Nm | |
+.Op Fl h | |
+.Op Fl f Ar field | |
+.Op Fl l Ar label | |
+.Op Fl t Ar term | |
+.Ar | |
+.Sh DESCRIPTION | |
+This tool is intended to process output files from | |
+.Xr cngf-pf 1 , | |
+and visualizes the evolution of a model parameter with depth across | |
+output files using | |
+.Xr gnuplot . | |
+The standard output is raw file data, so either redirect to a viewer | |
+program that accepts files as standard input streams, or save to disk. | |
+The output plot has file number as the horizontal axis, depth as the | |
+vertical axis, and plots the specified | |
+.Ar field | |
+values of the model using a color map. | |
+.Pp | |
+For publication-quality figures, it is recommended to adapt the | |
+.Nm | |
+script to own purposes. | |
+.Pp | |
+The arguments are as follows: | |
+.Bl -tag -width Ds | |
+.It Fl f Ar field | |
+Plot the specified | |
+.Ar field | |
+number in the input files. | |
+See the | |
+.Sx OUTPUT FORMAT | |
+section in | |
+.Xr cngf-pf 1 | |
+for information on what field numbers correspond to which model parameter. | |
+The value | |
+.Ar field | |
+must be a positive number. | |
+Default: 2 (shear velocity). | |
+.It Fl h | |
+Show usage information. | |
+.It Fl l Ar label | |
+Print this value as the color bar label. | |
+Default: "shear velocity [m/s]". | |
+.It Fl t Ar term | |
+Specify the | |
+.Xr gnuplot | |
+output terminal type and corresponding output file format. | |
+Write | |
+.Ql set term | |
+in | |
+.Xr gnuplot. | |
+to see a complete listing of output terminals available on the system. | |
+Default: "pdf". | |
+.It Ar | |
+A list of paths to files generated by | |
+.Xr cngf-pf 1 . | |
+.El | |
+.Sh EXAMPLES | |
+Generate some | |
+.Xr cngf-pf 1 | |
+output files with a daily change in fluid pressure for subsequent | |
+plotting: | |
+.Pp | |
+.Dl $ cngf-pf -F 50e3 -a 40e3 -q 1.16e-5 -I 3600 -e 345600 sim | |
+.Pp | |
+This generates many output files with the | |
+.Ql sim | |
+prefix. | |
+To plot the shear velocity of the model over time, and save the output | |
+to a file: | |
+.Pp | |
+.Dl $ cngf-pf-plot-depth-evol sim.output*.txt > shear-vel.pdf | |
+.Pp | |
+Or to view the output directly in the pdf viewer | |
+.Xr zathura 1 : | |
+.Pp | |
+.Dl $ cngf-pf-plot-depth-evol sim.output*.txt | zathura - | |
+.Pp | |
+Plot the fluid pressure: | |
+.Pp | |
+.Dl $ cngf-pf-plot-depth-evol -f 4 -l 'Fluid pressure [Pa]' sim.output*.txt > … | |
+.Sh SEE ALSO | |
+.Xr cngf-pf 1 , | |
+.Xr cngf-pf-plot-point-evol 1 , | |
+.Xr gnuplot 1 | |
+.Sh AUTHORS | |
+.An Anders Damsgaard Aq Mt [email protected] | |
diff --git a/cngf-pf-plot-point-evol b/cngf-pf-plot-point-evol | |
t@@ -0,0 +1,37 @@ | |
+#!/bin/sh | |
+ | |
+usage() { | |
+ printf 'usage: %s [-f field] [-h] [-l label] [-p point] [-t term] file… | |
+} | |
+ | |
+field="2" | |
+label="shear velocity [m/s]" | |
+term="pdf" | |
+point="-1" | |
+while getopts 'f:hl:p:t:' arg; do | |
+ case "${arg}" in | |
+ f) field="${OPTARG}" ;; | |
+ h) usage; exit 0 ;; | |
+ l) label="${OPTARG}" ;; | |
+ p) point="${OPTARG}" ;; | |
+ t) term="${OPTARG}" ;; | |
+ *) usage; exit 1 ;; | |
+ esac | |
+done | |
+shift $((OPTIND - 1)) | |
+ | |
+if test "$point" -lt 1; then | |
+ rowsel="tail -n "$(printf '%d * -1\n' "$point" | bc)"" | |
+ trim="head -n 1" | |
+else | |
+ rowsel="head -n ${point}" | |
+ trim="tail -n 1" | |
+fi | |
+ | |
+for f in "$@"; do | |
+ $rowsel "$f" | $trim | |
+done | \ | |
+gnuplot -e "set term ${term};\ | |
+ set xlabel 'Output file [-]';\ | |
+ set ylabel '${label}';\ | |
+ plot '-' u 0:${field} with lines title ''" | |
diff --git a/cngf-pf-plot-point-evol.1 b/cngf-pf-plot-point-evol.1 | |
t@@ -0,0 +1,109 @@ | |
+.Dd $Mdocdate$ | |
+.Dt CNGF-PF-PLOT-POINT-EVOL 1 | |
+.Os | |
+.Sh NAME | |
+.Nm cngf-pf-plot-point-evol | |
+.Nd plot evolution of a model point | |
+.Sh SYNOPSIS | |
+.Nm | |
+.Op Fl h | |
+.Op Fl f Ar field | |
+.Op Fl l Ar label | |
+.Op Fl p Ar point | |
+.Op Fl t Ar term | |
+.Ar | |
+.Sh DESCRIPTION | |
+This tool is intended to process output files from | |
+.Xr cngf-pf 1 , | |
+and visualizes the evolution of a model parameter across output files | |
+using | |
+.Xr gnuplot . | |
+The standard output is raw file data, so either redirect to a viewer | |
+program that accepts files as standard input streams, or save to disk. | |
+The output plot has file number as the horizontal axis, and plots the | |
+specified | |
+.Ar field | |
+values of model | |
+.Ar point | |
+as the vertical axis. | |
+.Pp | |
+For publication-quality figures, it is recommended to adapt the | |
+.Nm | |
+script to own purposes. | |
+.Pp | |
+The arguments are as follows: | |
+.Bl -tag -width Ds | |
+.It Fl f Ar field | |
+Plot the specified | |
+.Ar field | |
+number in the input files. | |
+See the | |
+.Sx OUTPUT FORMAT | |
+section in | |
+.Xr cngf-pf 1 | |
+for information on what field numbers correspond to which model parameter. | |
+The value | |
+.Ar field | |
+must be a positive number. | |
+Default: 2 (shear velocity). | |
+.It Fl h | |
+Show usage information. | |
+.It Fl l Ar label | |
+Print this value as the vertical axis label. | |
+Default: "shear velocity [m/s]". | |
+.It Fl p Ar point | |
+Select the n-th | |
+.Ar point | |
+in the model domain. | |
+The value | |
+.Ar point | |
+must be a non-zero positive or negative number. | |
+Positive numbers correspond to the n'th model point counted from the base | |
+(-z). | |
+Negative numbers correspond to the n'th model point counted from the top | |
+(+z). | |
+Default: -1 (top point). | |
+.It Fl t Ar term | |
+Specify the | |
+.Xr gnuplot | |
+output terminal type and corresponding output file format. | |
+Write | |
+.Ql set term | |
+in | |
+.Xr gnuplot. | |
+to see a complete listing of output terminals available on the system. | |
+Default: "pdf". | |
+.It Ar | |
+A list of paths to files generated by | |
+.Xr cngf-pf 1 . | |
+.El | |
+.Sh EXAMPLES | |
+Generate some | |
+.Xr cngf-pf 1 | |
+output files with a daily change in fluid pressure for subsequent | |
+plotting: | |
+.Pp | |
+.Dl $ cngf-pf -F 50e3 -a 40e3 -q 1.16e-5 -I 3600 -e 345600 sim | |
+.Pp | |
+This generates many output files with the | |
+.Ql sim | |
+prefix. | |
+To plot the shear velocity of the uppermost model point over time, | |
+and save the output to a file: | |
+.Pp | |
+.Dl $ cngf-pf-plot-point-evol sim.output*.txt > shear-vel.pdf | |
+.Pp | |
+Or to view the output directly in the pdf viewer | |
+.Xr zathura 1 : | |
+.Pp | |
+.Dl $ cngf-pf-plot-point-evol sim.output*.txt | zathura - | |
+.Pp | |
+Plot the fluid pressure at the 10th model point from the bottom: | |
+.Pp | |
+.Dl $ cngf-pf-plot-point-evol -f 4 -l 'Fluid pressure [Pa]' -p 10 sim.output*.… | |
+.Sh SEE ALSO | |
+.Xr cngf-pf 1 , | |
+.Xr cngf-pf-plot-depth-evol 1 , | |
+.Xr gnuplot 1 | |
+.Sh AUTHORS | |
+.An Anders Damsgaard Aq Mt [email protected] | |
diff --git a/plot_cngf_pf_evolution b/plot_cngf_pf_evolution | |
t@@ -1,27 +0,0 @@ | |
-#!/bin/sh | |
- | |
-usage() { | |
- printf 'usage: %s [-f field] [-h] [-l label] [-t term]\n' "${0##*/}" 1… | |
-} | |
- | |
-field="2" | |
-label="shear velocity [m/s]" | |
-term="pdf" | |
-while getopts 'f:hl:t:' arg; do | |
- case "${arg}" in | |
- f) field="${OPTARG}" ;; | |
- h) usage; exit 0 ;; | |
- l) label="${OPTARG}" ;; | |
- t) term="${OPTARG}" ;; | |
- *) usage; exit 1 ;; | |
- esac | |
-done | |
-shift $((OPTIND - 1)) | |
- | |
-for f in "$@"; do | |
- tail -n 1 "$f" | |
-done | \ | |
-gnuplot -e "set term ${term};\ | |
- set xlabel 'Timestep [-]';\ | |
- set ylabel '${label}';\ | |
- plot '-' u 0:${field} with lines title ''" |