Commit c1e35956 authored by thomas.forbriger's avatar thomas.forbriger

calex [WP][!!!]: add template for calex control script

This is just a collection of bits and pieces and cannot be run usefully yet.
parent b82b4964
#!/bin/sh
# this is <calex.sh>
# ----------------------------------------------------------------------------
#
# Copyright (c) 2016 by Thomas Forbriger (BFO Schiltach)
#
# run calex and display results
#
# ----
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# ----
#
# REVISIONS and CHANGES
# 11/10/2016 V1.0 Thomas Forbriger
#
# ============================================================================
#
#
# indicate version
VERSION=2015-07-19
#
# ============================================================================
# **** define usage functions ****
# ============================================================================
#
usage() {
cat >&2 << HERE
usage: calex.sh [-v|--verbose] [-D|--debug] [-d|--device dev] [--setsize]
[-X|--Xoption para] [-f|--parafile file]
or: calex.sh --help|-h
HERE
}
#
# ----------------------------------------------------------------------------
#
longusage() {
cat >&2 <<HERE
This shell script is a replacement for the DOS plot program winplot.g32.
It produces a multi-trace screen plot of ASCII data such as read or written by
my programs CALEX, DISPCAL, TILTCAL, SEIFE etc (“SEIFE format”). WINPLOT first
looks for a file 'plop’, 'plop.txt’, or 'winplot.par’, supposed to contain a
few numerical parameters and the names of the data files. winplot.sh uses
stuplox as provided in Seitosh (see Seitosh repository:
https://git.scc.kit.edu/Seitosh/Seitosh).
The 'winplot.par’ file has the following format:
---- snip ----
1, 4, 24, 16, 1, 12000, 0.8
eing
ausg
synt
rest
---- snip ----
The seven numerical parameters in the first line mean:
first parameter iavg:
=0, plot original data;
=1, remove average;
=2, use full width for nonnegative data.
Line width lw can be increased by adding 10*lw to iavg
second parameter nt:
number of traces to be plotted (i.e. number of file names)
third parameter w:
approximate width of the plot in cm on a 12” screen
fourth parameter h:
approximate height of the plot in cm on a 12” screen
These numbers (w and h) are only used for Postscript plots.
fifth parameter n1:
index of first plotted sample, = 0 means first input sample
sixth parameter n2:
index of last plotted sample, = 0 means last input sample
seventh parameter s:
scaling.
If positive: the peak amplitude of each trace is scaled to s times Full
Scale. (I normally use 0.8).
If negative: the amplitude ± s is scaled to Full Scale (the same scale for
all traces)
In both cases amplitudes beyond Full Scale are clipped.
Filenames – here eing, ausg, synt, rest - are valid to first blank, the rest
is considered as a comment.
A figure caption (one line) may be appended in a new line after the last file
name.
Zooming is possible by editing n1, n2 and s in the plop file, but is easier
with stuplox or stuploxx.
winplot.sh accepts additional parameters on the command line:
-f|--parafile file preferrably read plot parameters from file "file"
-v|--verbose report plot parameters to the terminal
-D|--debug make shell echo commands being executed
-d||--device dev select other output device than graphics screen
e.g. use '-d plotfile.ps/ps' to plot into Postscript
file 'plotfile.ps'
run 'stuplox -help' for a list of output devices
--setsize use width and height parameter read from parameter
file (affects only Postscript output); both parameters
are ignored otherwise
-X|--Xoption para pass additional option to stuplox; this option can be
used multiple times in order to pass several options;
if the option used in 'para' takes a parameter string
consisting of several words, they must by enclosed in
escaped quotes; e.g. to set the time axis label to
'time on 19.7.2015' you have to pass
--Xoption='-X "time on 19.7.2015"'
or
--Xoption="-X \"time on 19.7.2015\""
HERE
}
#
# ============================================================================
# execute
# ============================================================================
#
# echo usage information in any case
echo "winplot.sh (version $VERSION)"
usage
#
# read command line options
# -------------------------
TEMP=$(getopt -o vhX:d:Df: --long \
help,verbose,Xoption:,device:,debug,parafile:,setsize \
-n $(basename $0) -- "$@") || {
echo >&2
echo >&2 "ERROR: command line parameters are incorrect!"
echo >&2 "aborting $0..."; exit 2
}
eval set -- "$TEMP"
#
# extract command line options
# ----------------------------
VERBOSE=0
SETSIZE=0
DEVICE=x11
PARAFILE=plop
XSTUPLOXOPT=""
while true; do
case "$1" in
--help|-h) longusage; exit 1;;
--) shift; break;;
-X|--Xoption) XSTUPLOXOPT="${XSTUPLOXOPT} ${2}"; shift;;
-v|--verbose) VERBOSE=1;;
--setsize) SETSIZE=1;;
-d|--device) DEVICE="$2"; shift;;
-f|--parafile) PARAFILE="$2"; shift;;
-D|--debug) set -x ;;
*) echo >&2 "ERROR: option $1 unprocessed!";
echo >&2 "aborting $0..."; exit 2;;
esac
shift
done
#
# find parameter file
# -------------------
if test ! -r $PARAFILE
then
PARAFILE=plop
fi
if test ! -r $PARAFILE
then
PARAFILE=plop.txt
fi
if test ! -r $PARAFILE
then
PARAFILE=winplot.par
fi
if test ! -r $PARAFILE
then
echo >&2 "Missing parameter file (plop, plop.txt, or winplot.par)"
echo >&2 "aborting..."
exit 2
fi
echo using parameter file $PARAFILE
# time window
DATE="2016/05/25"
calex
COMMENT="$(head -n 1 calex.par)"
UNITS=counts
# generate result plot
stuploxx --dev=calex_signals.ps/cps \
-title="${COMMENT}" \
-labh=0.22 -labr -labe -labc -labu \
calex.einf p:1 ci:1 sf:1.1 f:seife:date=${DATE} u:${UNITS} \
n:"signal proportional to current in calibration coil" \
calex.ausf p:2 ci:1 sf:1.1 f:seife:date=${DATE} u:${UNITS} \
n:"output of seismometer" \
calex.synt p:3 ci:4 sf:1.1 f:seife:date=${DATE} u:${UNITS} \
n:"simulated output" \
calex.rest p:4 ci:2 sf:1.1 f:seife:date=${DATE} u:${UNITS} \
n:"residual" \
calex.ausf p:5 ci:1 sf:1.1 f:seife:date=${DATE} u:${UNITS} \
n:"output of seismometer" \
calex.synt p:5 ci:4 sf:1.1 f:seife:date=${DATE} u:${UNITS} \
n:"simulated output" \
calex.rest p:5 ci:2 sf:1.1 f:seife:date=${DATE} u:${UNITS} \
n:"residual"
# result data
calexoutextract.awk -v INI=8 calex.out > calex_summary.out
a2ps -o calex_summary.ps --center-title="${COMMENT}" calex_summary.out
# ----- END OF calex.sh -----
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment