Jpp  18.0.0-rc.3
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
archive-input_data.sh
Go to the documentation of this file.
1 #!/bin/zsh
2 script=${0##*/}
3 
4 source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
5 
6 set_variable: WORKDIR ARCHIVE_WORKDIR ${TMPDIR:-/tmp}/
7 set_variable: VERSION ARCHIVE_VERSION \*
8 set_array RUNS 1 99999999
9 
10 
11 if 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)."
16 fi
17 
18 if (( $# != 3 )); then
19  fatal "Wrong number of arguments."
20 fi
21 
22 set_variable ARCHIVE $argv[1]
25 
26 
27 JCookie.sh
28 
30 let "DETECTOR_ID = `getDetector -D $DETECTOR -O int`"
31 
32 
33 # map name in input_data/data/ to name in auxiliary_data/jpp/
34 
35 typeset -A BUFFER
36 
37 BUFFER[tripods]=tripod
38 BUFFER[baseAcousticBeacon]=transmitter
39 BUFFER[hydrophones]=hydrophone
40 BUFFER[waveforms]=waveform
41 
42 
43 # processing functions
44 
45 function typeout()
46 {
47  egrep -v "^#" $1 | tail -n+2 | tr ',' ' '
48 }
49 
50 function typeout_tripod()
51 {
52  typeout $1
53 }
54 
55 function 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 
60 function 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 
65 function typeout_waveform()
66 {
67  typeout $1
68 }
69 
70 
71 # format aliases with given precision
72 
73 alias format_tripod='awk "{ printf \"%2d %+12.${PRECISION}f %+12.${PRECISION}f %+9.${PRECISION}f\n\", \$1, \$2, \$3, \$4 }"'
74 alias format_transmitter='awk "{ printf \"%2d %3d %2d %7.${PRECISION}f %7.${PRECISION}f %7.${PRECISION}f\n\", \$1, \$2, \$3, \$4, \$5, \$6 }"'
75 alias format_hydrophone='awk "{ printf \"%2d %3d %7.${PRECISION}f %7.${PRECISION}f %7.${PRECISION}f\n\", \$1, \$2, \$3, \$4, \$5 }"'
76 alias format_waveform='awk "{ printf \"%3d %d\n\", \$1, \$2 }"'
77 
78 
79 # comparison
80 
81 function compare()
82 {
83  set_variable PRECISION 2
84 
85  eval egrep -v \"^#\" $1 \| $3 > $WORKDIR/.A.txt
86  eval egrep -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 
93 for 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  rm -f $WORKDIR/${VALUE}_A.txt
104 
105  getFile.sh $ARCHIVE $DETECTOR_ID $RUNS[1] $VALUE master $WORKDIR/${VALUE}_A >& /dev/null
106 
107  echo -n "Comparing ${INPUT_FILE:t} with archived file..."
108 
109  compare $WORKDIR/${VALUE}_A.txt $WORKDIR/${VALUE}.txt format_$VALUE
110 
111  if (( $RESULT == 0 )); then
112  echo "$GREEN OK $RESET"
113  else
114  echo "$RED Alternative input file $WORKDIR/${VALUE}.txt. $RESET"
115  fi
116  fi
117 done
then usage $script< detector identifier >< startdate\"YYYY-MM-DDHH:MM:SS\"><finaldate\"YYYY-MM-DDHH:MM:SS\"><QA/QCfile> fi case set_variable QAQC_TXT $argv[4]
Definition: JDataMonitor.sh:24
set_array RUNS
then ls $DIR egrep
Definition: getArchive.sh:75
then usage $script[< detector identifier >< run range >]< QA/QCfile > nExample script to produce data quality plots nWhen a detector identifier and run range are data are downloaded from the database nand subsequently stored in the given QA QC file
Definition: JDataQuality.sh:19
esac done BUFFER
Definition: JMakePDF.sh:77
usr share Modules init zsh export TMPDIR
then fatal Number of tripods
Definition: JFootprint.sh:45
JDetectorsHelper & getDetector()
Auxiliary function for helper object initialisation.
Definition: JDBToolkit.hh:378
then fatal Wrong number of arguments fi DIR
const int n
Definition: JPolint.hh:697
then fatal Missing detector file $DETECTOR fi eval JPrintDetector a $DETECTOR O IDENTIFIER for KEY in tripod hydrophone transmitter
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR set_variable DIR $JPP_DIR examples JPhysics set_variable DEBUG set_variable darkcount_Hz set_variable rateL0_Hz set_array rateL1_Hz if do_usage *then usage $script[working directory] fi function typeout()
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR &dev null set_variable
Definition: JAcoustics.sh:21
do set_variable STRING_TXT awk
#define VERSION
Definition: elog-version.h:27
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR &dev null set_variable DEBUG set_variable WORKDIR
Definition: JLegolas.sh:20
* usage
set_variable INPUT_FILE
then set_variable MODULE getModule a $DETECTOR L $STRING $FLOOR JEditDetector a $DETECTOR M $MODULE add $X o $DETECTOR else echo No update of detector $DETECTOR
then display $WORKDIR
Definition: plot-Domino.sh:128
set_variable DETECTOR
data_type v[N+1][M+1]
Definition: JPolint.hh:777
static JNullStream null
Null I/O stream.
Definition: JNullStream.hh:51
source $JPP_DIR setenv csh $JPP_DIR &dev null eval JShellParser o a A
script
Definition: JAcoustics.sh:2
do echo Generating $dir eval D
Definition: JDrawLED.sh:53
string OK
Definition: run_tests.py:44