Jpp test-rotations-old-533-g2bdbdb559
the software that should make you happy
Loading...
Searching...
No Matches
software/JDataQuality/qaqc.sh
Go to the documentation of this file.
1#!/usr/bin/env zsh
2#
3# \author mdejong
4#
5script=${0##*/}
6
7if [ -z $JPP_DIR ]; then
8 echo "Variable JPP_DIR undefined."
9 exit
10fi
11
12source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
13
14set_variable: DEBUG QAQC_DEBUG 0
15set_variable+ UTC QAQC_UTC UTC
16
17if do_usage $*; then
18 usage "$script <QA/QC file> <run range> [(parameter)]"
19fi
20
21if (( $# < 2 )); then
22 fatal "Wrong number of arguments."
23fi
24
25set_variable INPUT_FILE $argv[1]
26set_variable RANGE $argv[2]
27set_array PARAMETERS $argv[3,-1]
28
29RUNS=(${RANGE%%-*} ${RANGE##*-})
30
31
32HEADER=(`head -1 $INPUT_FILE`)
33
34if [[ "$PARAMETERS[1]" == "?" ]]; then
35 echo $HEADER[*]
36 exit 0
37fi
38
39let "INDEX_OF_RUN = ${HEADER[(ie)run]}" # index of column "run"
40
41INDICES=()
42
43for PARAMETER in $PARAMETERS[*]; do
44
45 INDEX=${HEADER[(ie)$PARAMETER]}
46
47 if (( $INDEX > ${#HEADER} )); then
48 fatal "Invalid parameter $PARAMETER."
49 else
50 INDICES+=($INDEX)
51 fi
52done
53
54if (( ${#INDICES} == 0 )); then
55 INDICES=({1..${#HEADER}})
56fi
57
58
59printf "#"
60
61for i in $INDICES[*]; do
62 printf "%-32s " $HEADER[$i]
63done
64
65printf "\n"
66
67while read BUFFER; do
68
69 ARRAY=(`echo $BUFFER`)
70
71 if [[ ${(pj:\0:)HEADER} != ${(pj:\0:)ARRAY} ]]; then
72
73 let "RUN = $ARRAY[$INDEX_OF_RUN]"
74
75 if (( $RUN >= $RUNS[1] && $RUN <= $RUNS[2] )); then
76
77 for i in $INDICES[*]; do
78
79 # convert to date
80
81 if [[ $HEADER[$i] == ${UTC:-XXX}* ]]; then
82 ARRAY[$i]="$(date '+%d-%m-%Y %H:%M' -d @$ARRAY[$i])"
83 fi
84
85 printf " %-32s" $ARRAY[$i]
86 done
87
88 printf "\n"
89 fi
90 fi
91done < $INPUT_FILE