Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
plot-Tuna.sh
Go to the documentation of this file.
1#!/usr/bin/env zsh
2script=${0##*/}
3
4# ------------------------------------------------------------------------------------------
5#
6# Auxiliary script to plot slow control data from database.
7#
8# ------------------------------------------------------------------------------------------
9
10if [ -z $JPP_DIR ]; then
11 echo "Variable JPP_DIR undefined."
12 exit
13fi
14
15source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
16
17set_variable: DEBUG DATABASE_DEBUG 2
18set_variable: WORKDIR DATABASE_WORKDIR ${TMPDIR:-/tmp}/
19set_variable: CANVAS DATABASE_CANVAS 1200x600
20set_variable: TIMEAXIS DATABASE_TIMESAXIS %d:%m:%y%F1970-01-01 00:00:00
21set_variable: GRAPHICS DATABASE_GRAPHICS gif
22set_variable: WILDCARD DATABASE_WILDCARD %
23
24if do_usage $*; then
25 usage "$script <input file> <parameters file> [working directory]"
26fi
27
28case $# in
29 3) set_variable WORKDIR $3;&
30 2) set_variable PARAMETERS_FILE $2;
31 set_variable INPUT_FILE $1;;
32 *) fatal "Wrong number of arguments."
33esac
34
35if [[ ! -f $INPUT_FILE ]]; then
36 fatal "File $INPUT_FILE not found."
37fi
38
39if [[ ! -f $PARAMETERS_FILE ]]; then
40 echo $PARAMETERS_FILE > $WORKDIR/.parameters.txt # temporary file
41 set_variable PARAMETERS_FILE $WORKDIR/.parameters.txt
42fi
43
44mkdir -p $WORKDIR
45
46exec 3< $PARAMETERS_FILE
47
48while read -u 3 QUANTITY MIN OUT YMIN YMAX; do
49
50 if [[ -n "${QUANTITY}" && ! ${QUANTITY} =~ "^#" ]]; then
51
52 # set environment variables:
53 # STRINGS
54 # FIRST_FLOOR
55 # LAST_FLOOR
56
57 eval `JPrintTitle -f ${INPUT_FILE}:TUNA`
58
59 echo $QUANTITY | sed -n "s/\‍([^\.]*\‍)\.\‍([^\.]*\‍)\.\‍(.*\‍)/\1 \2 \3/p" | read string floor QUANTITY
60
61 debug "Parsed: <${string}> <${floor}> <${QUANTITY}>"
62
63 if [[ ${string} != $WILDCARD ]]; then
64 set_array STRINGS $string
65 fi
66
67 if [[ ${floor} != $WILDCARD ]]; then
68 set_variable FIRST_FLOOR ${floor/-*}
69 set_variable LAST_FLOOR ${floor/*-}
70 fi
71
72 if [[ -n "${YMIN}" && -n "${YMAX}" ]]; then
73 set_variable Y_RANGE -y "$YMIN $YMAX"
74 else
75 set_variable Y_RANGE
76 fi
77
78 set_variable quantity `echo $QUANTITY | sed 's/\[/\\\[/g;s/\]/\\\]/g'`
79
80 typeset -Z 4 STRING
81 typeset -Z 2 FLOOR
82
83 for STRING in $STRINGS[*]; do
84
85 for (( FLOOR = $FIRST_FLOOR; $FLOOR <= $LAST_FLOOR; FLOOR += 1 )); do
86
87 notice "Creating graphics ${WORKDIR}/${STRING}_${FLOOR}_${QUANTITY}.${GRAPHICS}"
88
89 JPlot1D \
90 -w "$CANVAS" \
91 -f "${INPUT_FILE}:${STRING}.${FLOOR}.${quantity}$" \
92 ${Y_RANGE} \
93 -L LT \
94 -T "(${STRING},${FLOOR})" \
95 -t "$TIMEAXIS" \
96 -o ${WORKDIR}/${STRING}_${FLOOR}_${QUANTITY}.${GRAPHICS} \
97 -d 0 -B
98 done
99
100 if (( ${LAST_FLOOR} - ${FIRST_FLOOR} + 1 == 18 )); then
101
102 notice "Creating graphics ${WORKDIR}/${STRING}_${QUANTITY}.${GRAPHICS}"
103
104 montage \
105 -tile 6x3 \
106 -geometry +0+0 \
107 ${WORKDIR}/${STRING}_*_${QUANTITY}.${GRAPHICS} \
108 ${WORKDIR}/${STRING}_${QUANTITY}.${GRAPHICS}
109
110 rm -f ${WORKDIR}/${STRING}_*_${QUANTITY}.${GRAPHICS}
111 fi
112 done
113 fi
114done
115
116rm -f $WORKDIR/.parameters.txt