Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
archive-input_data.sh
Go to the documentation of this file.
1#!/usr/bin/env zsh
2script=${0##*/}
3
4source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
5
6set_variable: WORKDIR ARCHIVE_WORKDIR ${TMPDIR:-/tmp}/
7set_variable: VERSION ARCHIVE_VERSION \*
8set_array RUNS 1 99999999
9
10
11if do_usage $*; then
12 usage "$script <archive> <detector> <directory>"\
13 "\nAuxiliary script to check auxiliary data in archive for a given detector."\
14 "\nThe directory corresponds to the location of the input tables (see https://git.km3net.de/calibration/input_tables) "\
15 "\nand the archive to auxiliary data (see https://git.km3net.de/auxiliary_data/jpp)."
16fi
17
18if (( $# != 3 )); then
19 fatal "Wrong number of arguments."
20fi
21
22set_variable ARCHIVE $argv[1]
23set_variable DETECTOR $argv[2]
24set_variable DIR $argv[3]
25
26
27JCookie.sh
28
29set_variable DETECTOR `getDetector -D $DETECTOR -O string`
30let "DETECTOR_ID = `getDetector -D $DETECTOR -O int`"
31
32
33# map name in input_data/data/ to name in auxiliary_data/jpp/
34
35typeset -A BUFFER
36
37BUFFER[tripods]=tripod
38BUFFER[baseAcousticBeacon]=transmitter
39BUFFER[hydrophones]=hydrophone
40BUFFER[waveforms]=waveform
41
42
43# processing functions
44
45function typeout()
46{
47 grep -E -v "^#" $1 | tail -n+2 | tr ',' ' '
48}
49
50function typeout_tripod()
51{
52 typeout $1
53}
54
55function typeout_hydrophone()
56{
57 typeout $1 | awk -v DEGTORAD=0.017453293 '{ $5 *= DEGTORAD; if ($2 != -1) { print $1, $2, ($3 * -cos($5) + $4 * -sin($5)), ($3 * +sin($5) + $4 * -cos($5)), $6 }}'
58}
59
60function typeout_transmitter()
61{
62 typeout $1 | awk -v DEGTORAD=0.017453293 '{ $6 *= DEGTORAD; if ($3 != -1) { print $1, $2, $3, ($4 * -cos($6) + $5 * -sin($6)), ($4 * +sin($6) + $5 * -cos($6)), $7 }}'
63}
64
65function typeout_waveform()
66{
67 typeout $1
68}
69
70
71# format aliases with given precision
72
73alias format_tripod='awk "{ printf \"%2d %+12.${PRECISION}f %+12.${PRECISION}f %+9.${PRECISION}f\n\", \$1, \$2, \$3, \$4 }"'
74alias format_transmitter='awk "{ printf \"%2d %3d %2d %7.${PRECISION}f %7.${PRECISION}f %7.${PRECISION}f\n\", \$1, \$2, \$3, \$4, \$5, \$6 }"'
75alias format_hydrophone='awk "{ printf \"%2d %3d %7.${PRECISION}f %7.${PRECISION}f %7.${PRECISION}f\n\", \$1, \$2, \$3, \$4, \$5 }"'
76alias format_waveform='awk "{ printf \"%3d %d\n\", \$1, \$2 }"'
77
78
79# comparison
80
81function compare()
82{
83 set_variable PRECISION 2
84
85 eval grep -E -v \"^#\" $1 \| $3 > $WORKDIR/.A.txt
86 eval grep -E -v \"^#\" $2 \| $3 > $WORKDIR/.B.txt
87
88 diff $WORKDIR/.A.txt $WORKDIR/.B.txt; export RESULT=$?
89 rm -f $WORKDIR/.A.txt $WORKDIR/.B.txt
90}
91
92
93for KEY VALUE in ${(kv)BUFFER}; do
94
95 set_variable INPUT_FILE $DIR/data/$DETECTOR/${DETECTOR}_${KEY}.csv
96
97 if [[ -f $INPUT_FILE ]]; then
98
99 set_variable PRECISION 4
100
101 eval typeout_$VALUE $INPUT_FILE \| format_$VALUE > $WORKDIR/${VALUE}.txt
102
103 echo -n "Comparing ${INPUT_FILE:t} with archived file..."
104
105 rm -f $WORKDIR/${VALUE}_A.txt
106
107 getFile.sh $ARCHIVE $DETECTOR_ID $RUNS[1] $VALUE $VERSION $WORKDIR/${VALUE}_A >& /dev/null
108
109 if (( $? == 0 )); then
110
111 compare $WORKDIR/${VALUE}_A.txt $WORKDIR/${VALUE}.txt format_$VALUE
112
113 if (( $RESULT == 0 )); then
114 echo "$GREEN OK $RESET"
115 else
116 echo "$RED Alternative input file $WORKDIR/${VALUE}.txt. $RESET"
117 fi
118 else
119 echo "$RED No file in archive. $RESET"
120 fi
121 else
122 echo "No file ${INPUT_FILE:t} in calibration/input_tables/"
123 fi
124done