term-paper-diffeq

view doc/plot-results.sh @ 113:bc94df402ff0

Updated report to comply with source code changes introduced in rev 110.
author Dmitry Dzhus <mail@sphinx.net.ru>
date Fri Nov 16 19:08:52 2007 +0300 (2 years ago)
parents b56428b8a044
children
line source
1 #!/bin/bash
2 #
3 # A script to produce `.mps` MetaPost mpgraph plot using text file
4 # with results
5 #
6 # Usage:
7 #
8 # ./plot-results.sh RESULTS-LIST
9 #
10 # If RESULTS-LIST is single file
11 # `fundmatrix__exo-statement.scm-results`, this script will produce
12 # `fundmatrix__exo-statement.scm-plot.mps`. In case of several file
13 # names passed as command line arguments:
14 # `fundmatrix__statement.scm-results
15 # iterative-solve__statement.scm-results`
16 # `statement.scm-all-plots.mps` is a filename of resulting image.
18 RESULTS=$@
20 MP=$(mktemp /tmp/docXXXXXX)
21 DATAFILES=""
23 # Generate a list of source data files
24 for file in ${RESULTS}
25 do
26 TEMPFILE=$(mktemp /tmp/docXXXXXX)
27 # Strip out everything except u(x) approximation
28 cat ${file} \
29 | head -n $(($(grep -n "%%" ${file} | sed -e "s/:.*//")-1)) \
30 > ${TEMPFILE}
31 DATAFILES="${DATAFILES}\"${TEMPFILE}\","
32 done
33 DATAFILES=${DATAFILES%,}
35 # Generate `method__statement.scm-plot` (if one argument passed) or
36 # `statement.scm-all-plots`. Place labels on plot curves only if one
37 # result is being drawn
38 if (( $#==1 ))
39 then
40 PLOT_PREFIX=${RESULTS/results/plot}
41 LABEL="\`\$1'"
42 PEN="single"
43 else
44 # Warning: script uses name of statement file of the _first_
45 # argument in the name of resulting MPS image.
46 PLOT_PREFIX=${1/*__/}
47 PLOT_PREFIX=${PLOT_PREFIX%-results}"-all-plots"
48 LABEL=""
49 PEN="multi"
50 fi
53 # Generate `.mps` plot
54 m4 --define="__PLOT_PREFIX"="${PLOT_PREFIX}" \
55 --define="__LABEL"="${LABEL}" \
56 --define="__DATA"="${DATAFILES}" \
57 --define="__PEN"="__PEN_${PEN}" \
58 plot.tpl.mp > ${MP}
60 mpost -interaction=nonstopmode ${MP}
62 rm ${MP} $(echo ${DATAFILES} | sed -e "s/\"//g" | sed -e "s/,/ /g")