Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
plot-Tuna.sh
Go to the documentation of this file.
1 #!/bin/zsh
2 script=${0##*/}
3 
4 # ------------------------------------------------------------------------------------------
5 #
6 # Auxiliary script to plot slow control data from database.
7 #
8 # ------------------------------------------------------------------------------------------
9 
10 if [ -z $JPP_DIR ]; then
11  echo "Variable JPP_DIR undefined."
12  exit
13 fi
14 
15 source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
16 
17 set_variable DEBUG ${DATABASE_DEBUG:-2}
18 set_variable WORKDIR ${DATABASE_WORKDIR:-/tmp/}
19 set_variable CANVAS ${DATABASE_CANVAS:-1200x600}
20 set_variable TIMEAXIS ${DATABASE_TIMESAXIS:-%d:%m:%y%F1970-01-01 00:00:00}
21 set_variable GRAPHICS ${DATABASE_GRAPHICS:-gif}
22 set_variable WILDCARD ${DATABASE_WILDCARD:-%}
23 
24 if ( do_usage $* ); then
25  usage "$script <input file> <parameters file> [working directory]"
26 fi
27 
28 case $# in
32  *) fatal "Wrong number of arguments."
33 esac
34 
35 if [[ ! -f $INPUT_FILE ]]; then
36  fatal "File $INPUT_FILE not found."
37 fi
38 
39 if [[ ! -f $PARAMETERS_FILE ]]; then
40  echo $PARAMETERS_FILE > $WORKDIR/.parameters.txt # temporary file
41  set_variable PARAMETERS_FILE $WORKDIR/.parameters.txt
42 fi
43 
44 mkdir -p $WORKDIR
45 
46 exec 3< $PARAMETERS_FILE
47 
48 while read -u 3 QUANTITY 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 3 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
114 done
115 
116 rm -f $WORKDIR/.parameters.txt
void set_variable(const std::string &name, const std::string &value)
Set environment variable.
bool read(Vec &v, std::istream &is)
Read a Vec(tor) from a stream.
Definition: io_ascii.hh:139
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
exit
Definition: JPizza.sh:36
&set_variable INPUT_FILE
Definition: JLegolas.sh:30
fatal Invalid number of arguments esac let YMIN
Definition: testToT.sh:39
then JPizza f
Definition: JPizza.sh:46
then echo
&set_variable PARAMETERS_FILE
Definition: file-Tuna.sh:28
then print_variable DETECTOR INPUT_FILE INTERMEDIATE_FILE check_input_file $DETECTOR $INPUT_FILE check_output_file $INTERMEDIATE_FILE $OUTPUT_FILE JMCEvt f $INPUT_FILE o $INTERMEDIATE_FILE d
Definition: JPath.sh:52
int debug
debug level
Definition: JSirene.cc:61
* usage
then JFileTuna f $INPUT_FILE
Definition: file-Tuna.sh:66
alias put_queue eval echo n
Definition: qlib.csh:19
then display $WORKDIR
Definition: plot-Domino.sh:142
double u[N+1]
Definition: JPolint.hh:706
then usage $script< detector file >< inputfile > fi case set_variable WORKDIR
Definition: JLegolas.sh:28
esac $JPP_BIN JLogger sh $LOGGER until pgrep JGetMessage</dev/null > dev null
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62