Jpp  master_rocky-40-g5f0272dcd
the software that should make you happy
JAcousticsToolkit.sh
Go to the documentation of this file.
1 #!/bin/zsh
2 script=${0##*/}
3 
4 # ------------------------------------------------------------------------------------------
5 #
6 # Toolkit for acoustics scripts.
7 #
8 # ------------------------------------------------------------------------------------------
9 
10 if [ -z $JPP_DIR ]; then
11  echo "Variable JPP_DIR undefined."
12  exit
13 fi
14 
15 source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
16 
17 if do_usage $*; then
18  usage "source $script"\
19  "\nToolkit for acoustics scripts."
20 fi
21 
22 #
23 # Acoustics detector.
24 #
25 ACOUSTICS_DETECTOR=detector.datx
26 
27 
28 #
29 # Acoustics keys for auxiliary files.
30 #
31 ACOUSTICS_AUXS=(
32  tripod
33  hydrophone
34  transmitter)
35 
36 
37 #
38 # Acoustics keys for input files.
39 #
40 ACOUSTICS_KEYS=(
41  sound_velocity
42  waveform
43  mechanics
44  acoustics_trigger_parameters
45  acoustics_fit_parameters
46  disable)
47 
48 
49 #
50 # Method to add tripod data from given file into associative array.
51 #
52 # \param 1 file name
53 # \param 2 associative array
54 #
55 function get_tripods+()
56 {
57  set_local_variable __FILE__ $1
58  set_local_variable __ARRAY__ $2
59 
60  while read __line__; do
61 
62  if [[ -n "$__line__" && "$__line__" != \#* ]]; then
63 
64  echo $__line__ | read __id__ __x__ __y__ __z__
65 
66  eval ${__ARRAY__}\[${__id__}\]=\"$__x__ $__y__ $__z__\"
67  fi
68 
69  done < $__FILE__
70 }
71 
72 
73 #
74 # Method to write tripod data from given file into associative array.
75 #
76 # \param 1 file name
77 # \param 2 associative array
78 #
79 function get_tripods()
80 {
81  eval $2=\‍(\‍)
82 
83  get_tripods+ $1 $2
84 }
85 
86 
87 #
88 # Method to add transmitter data from given file into associative array.
89 #
90 # \param 1 file name
91 # \param 2 associative array
92 #
93 function get_transmitters+()
94 {
95  set_local_variable __FILE__ $1
96  set_local_variable __ARRAY__ $2
97 
98  while read __line__; do
99 
100  if [[ -n "$__line__" && "$__line__" != \#* ]]; then
101 
102  echo $__line__ | read __id__ __string__ __floor__ __x__ __y__ __z__
103 
104  eval ${__ARRAY__}\[${__id__}\]=\"$__x__ $__y__ $__z__\"
105  fi
106 
107  done < $__FILE__
108 }
109 
110 
111 #
112 # Method to write transmitter data from given file into associative array.
113 #
114 # \param 1 file name
115 # \param 2 associative array
116 #
117 function get_transmitters()
118 {
119  eval $2=\‍(\‍)
120 
121  get_transmitters+ $1 $2
122 }
123 
124 
125 #
126 # Method to print string numbers of strings with with transmitter.
127 #
128 # \param 1 file name
129 # \return string numbers
130 #
131 function get_strings_with_transmitter()
132 {
133  set_local_variable __FILE__ $1
134 
135  while read __line__; do
136 
137  if [[ -n "$__line__" && "$__line__" != \#* ]]; then
138 
139  echo $__line__ | read __id__ __string__ __floor__ __x__ __y__ __z__
140 
141  echo -n " $__string__"
142  fi
143 
144  done < $__FILE__
145 
146  echo
147 }
148 
149 
150 #
151 # Method to print string numbers of strings with with hydrophone.
152 #
153 # \param 1 file name
154 # \return string numbers
155 #
156 function get_strings_with_hydrophone()
157 {
158  set_local_variable __FILE__ $1
159 
160  while read __line__; do
161 
162  if [[ -n "$__line__" && "$__line__" != \#* ]]; then
163 
164  echo $__line__ | read __string__ __floor__ __x__ __y__ __z__
165 
166  echo -n " $__string__"
167  fi
168 
169  done < $__FILE__
170 
171  echo
172 }
173 
174 
175 #
176 # Method to write waveform data from given file into associative array.
177 #
178 # \param 1 file name
179 # \param 2 associative array
180 #
181 function get_waveforms()
182 {
183  set_local_variable __FILE__ $1
184  set_local_variable __ARRAY__ $2
185 
186  while read __line__; do
187 
188  if [[ -n "$__line__" && "$__line__" != \#* ]]; then
189 
190  echo $__line__ | read __id__ __m__
191 
192  eval ${__ARRAY__}\[${__id__}\]=\"$__m__\"
193  fi
194 
195  done < $__FILE__
196 }