Jpp test-rotations-old
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
15
16if do_usage $*; then
17 usage "$script <QA/QC file> [(parameter)]"
18fi
19
20if (( $# == 0 )); then
21 fatal "Wrong number of arguments."
22fi
23
24set_variable INPUT_FILE $argv[1]
25set_array PARAMETERS $argv[2,-1]
26
27HEADER=(`head -1 $INPUT_FILE`)
28
29if [[ "$PARAMETERS[1]" == "?" ]]; then
30 echo $HEADER[*]
31 exit 0
32fi
33
34INDICES=()
35
36for PARAMETER in $PARAMETERS[*]; do
37
38 INDEX=${HEADER[(ie)$PARAMETER]}
39
40 if (( $INDEX > ${#HEADER} )); then
41 fatal "Invalid parameter $PARAMETER."
42 else
43 INDICES+=($INDEX)
44 fi
45done
46
47if (( ${#INDICES} == 0 )); then
48 INDICES=({1..${#HEADER}})
49fi
50
51while read BUFFER; do
52
53 ARRAY=(`echo $BUFFER`)
54
55 if [[ ${(pj:\0:)HEADER} != ${(pj:\0:)ARRAY} ]]; then
56
57 for i in $INDICES[*]; do
58 printf "%-24s %-32s\n" $HEADER[$i] $ARRAY[$i]
59 done
60 fi
61done < $INPUT_FILE