calex.sh 4.69 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/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
32
VERSION=2016-10-18
33
34
35
36
37
38
39
# 
# ============================================================================
# **** define usage functions                                             ****
# ============================================================================
#
usage() {
cat >&2 << HERE
40
41
usage: calex.sh [-v|--verbose] [-D|--debug] [-d|--device dev] 
                [file] 
42
43
44
45
46
47
48
49
   or: calex.sh --help|-h
HERE
}
#
# ----------------------------------------------------------------------------
#
longusage() {
cat >&2 <<HERE
50
Run calex with a given control file and produce a report on the results.
51

52
  file      calex control file
53
54

  -v|--verbose          report plot parameters to the terminal
55
56
57
  -D|--date date        set date of seife data
  -u|--units units      set units of data samples
  -b|--outbase basename set basename for output files
58
59
60
61
62
63
64
65
66
67
68
69
  -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
HERE
}
#
# ============================================================================
# execute
# ============================================================================
#
# echo usage information in any case
70
echo "calex.sh (version $VERSION)"
71
72
73
74
usage
#
# read command line options
# -------------------------
75
76
TEMP=$(getopt -o vhd:D:u:b: --long \
  help,verbose,device:,debug,date:,units:,outbase: \
77
78
79
80
81
82
83
84
85
86
87
  -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
DEVICE=x11
88
89
90
91
PARAFILE=calex.par
OUTBASE=NSP
UNITS="counts"
DATE="1970/01/01"
92
93
94
95
96
while true; do
  case "$1" in
    --help|-h) longusage; exit 1;;
    --) shift; break;;
    -v|--verbose)  VERBOSE=1;;
97
    -u|--units)    UNITS="$2"; shift;;
98
    -d|--device)   DEVICE="$2"; shift;;
99
100
101
    -b|--outbase)  OUTBASE="$2"; shift;;
    -D|--date)     DATE="$2"; shift;;
    --debug) set -x ;;
102
103
104
105
106
107
108
109
110
    *) echo >&2 "ERROR: option $1 unprocessed!";
       echo >&2 "aborting $0..."; exit 2;;
  esac
  shift
done

#
# find parameter file
# -------------------
111
if test $# -gt 0
112
then
113
  PARAFILE=$1
114
115
116
fi
if test ! -r $PARAFILE
then
117
  echo >&2 "Missing parameter file $PARAFILE"
118
119
120
121
122
  echo >&2 "aborting..."
  exit 2
fi
echo using parameter file $PARAFILE

123
COMMENT="$(head -n 1 $PARAFILE)"
124

125
126
127
128
if test "$OUTBASE" = NSP
then
  OUTBASE=$(basename $PARAFILE .par)
fi
129

130
calex $PARAFILE
131
132

# generate result plot
133
stuploxx --dev=${OUTBASE}_signals.ps/cps \
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
  -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
152
calexoutextract.awk -v INI=8 ${OUTBASE}.out > ${OUTBASE}_summary.out
153

154
a2ps -o ${OUTBASE}_summary.ps --center-title="${COMMENT}" ${OUTBASE}_summary.out
155

156
157
158
159
echo results are present in:
ls -1 ${OUTBASE}.out ${OUTBASE}_summary.out ${OUTBASE}_summary.ps \
  ${OUTBASE}_signals.ps

160
# ----- END OF calex.sh -----