4source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
6set_variable: WORKDIR ARCHIVE_WORKDIR ${TMPDIR:-/tmp}/
7set_variable: VERSION ARCHIVE_VERSION \*
8set_array RUNS 1 99999999
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)."
19 fatal "Wrong number of arguments."
22set_variable ARCHIVE $argv[1]
23set_variable DETECTOR $argv[2]
24set_variable DIR $argv[3]
29set_variable DETECTOR `getDetector -D $DETECTOR -O string`
30let "DETECTOR_ID = `getDetector -D $DETECTOR -O int`"
33# map name in input_data/data/ to name in auxiliary_data/jpp/
38BUFFER[baseAcousticBeacon]=transmitter
39BUFFER[hydrophones]=hydrophone
40BUFFER[waveforms]=waveform
47 grep -E -v "^#" $1 | tail -n+2 | tr ',' ' '
50function typeout_tripod()
55function typeout_hydrophone()
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 }}'
60function typeout_transmitter()
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 }}'
65function typeout_waveform()
71# format aliases with given precision
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 }"'
83 set_variable PRECISION 2
85 eval grep -E -v \"^#\" $1 \| $3 > $WORKDIR/.A.txt
86 eval grep -E -v \"^#\" $2 \| $3 > $WORKDIR/.B.txt
88 diff $WORKDIR/.A.txt $WORKDIR/.B.txt; export RESULT=$?
89 rm -f $WORKDIR/.A.txt $WORKDIR/.B.txt
93for KEY VALUE in ${(kv)BUFFER}; do
95 set_variable INPUT_FILE $DIR/data/$DETECTOR/${DETECTOR}_${KEY}.csv
97 if [[ -f $INPUT_FILE ]]; then
99 set_variable PRECISION 4
101 eval typeout_$VALUE $INPUT_FILE \| format_$VALUE > $WORKDIR/${VALUE}.txt
103 echo -n "Comparing ${INPUT_FILE:t} with archived file..."
105 rm -f $WORKDIR/${VALUE}_A.txt
107 getFile.sh $ARCHIVE $DETECTOR_ID $RUNS[1] $VALUE $VERSION $WORKDIR/${VALUE}_A >& /dev/null
109 if (( $? == 0 )); then
111 compare $WORKDIR/${VALUE}_A.txt $WORKDIR/${VALUE}.txt format_$VALUE
113 if (( $RESULT == 0 )); then
114 echo "$GREEN OK $RESET"
116 echo "$RED Alternative input file $WORKDIR/${VALUE}.txt. $RESET"
119 echo "$RED No file in archive. $RESET"
122 echo "No file ${INPUT_FILE:t} in calibration/input_tables/"