Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JAcousticsSupportkit.hh
Go to the documentation of this file.
1#ifndef __JACOUSTICS__JACOUSTICSSUPPORTKIT__
2#define __JACOUSTICS__JACOUSTICSSUPPORTKIT__
3
4#include <istream>
5#include <ostream>
6#include <cmath>
7
8
9/**
10 * \file
11 *
12 * Acoustics support kit.
13 * \author mdejong
14 */
15namespace JACOUSTICS {}
16namespace JPP { using namespace JACOUSTICS; }
17
18namespace JACOUSTICS {
19
20 static const double TOAMIN_S = 0.0000000; //!< Minimal allowed time-of-arrival [s]
21 static const double TOAMAX_S = 0.6310912; //!< Maximal allowed time-of-arrival [s]
22
23
24 /**
25 * Auxiliary data structure for calculation of attenuation length.
26 *
27 * Attenuation according to Ainslie and McColm, J. Acoust. Soc. AM. 103 (3) 1671 1998.\n
28 * See also http://resource.npl.co.uk/acoustics/techguides/seaabsorption/physics.html for numerical values.
29 */
31 /**
32 * Constructor.
33 *
34 * \param T temperature [C]
35 * \param S salinity [pm]
36 * \param pH pH
37 */
38 JAttenuationLength(const double T,
39 const double S,
40 const double pH) :
41 T (T),
42 S (S),
43 pH(pH)
44 {}
45
46
47 /**
48 * Get attentuation length for given frequency at given depth.
49 *
50 * \param D_m depth [m]
51 * \param f_kHz frequency [kHz]
52 * \return attenuation length [m]
53 */
54 double operator()(const double D_m,
55 const double f_kHz) const
56 {
57 const double z = D_m * 1.0e-3;
58 const double f1 = 0.78 * sqrt(S/35.0) * exp(T/26.0);
59 const double f2 = 42.0 * exp(T/17.0);
60 const double a1 = 0.106 * f1*(f_kHz*f_kHz) / (f_kHz*f_kHz + f1*f1) * exp((pH-8.0)/0.56);
61 const double a2 = 0.52 * (1.0 + T/43.0) * (S/35.0) * f2 * f_kHz*f_kHz / (f_kHz*f_kHz + f2*f2) * exp(-z/6.0);
62 const double a0 = 0.00049 * exp(-T/27.0 + z/17.0) * f_kHz*f_kHz;
63 const double A = a0 + a1 + a2; // dB/km
64
65 return 10.0e3 / (A*log(10.0));
66 }
67
68 double T;
69 double S;
70 double pH;
71 };
72
73
74 /**
75 * Function object to calculate attenutation length.
76 */
77 static const JAttenuationLength getAttenuationLength(13.2, // temperature [deg]
78 38.0, // salinity [pm]
79 8.0); // pH
80
81
82
83
84 /**
85 * Get relative quality for given frequency at given distance.
86 *
87 * \param D_m depth [m]
88 * \param f_kHz frequency [kHz]
89 * \param d_m distance [m]
90 * \return quality
91 */
92 inline double getQ(const double D_m,
93 const double f_kHz,
94 const double d_m)
95 {
96 return exp(-0.5 * d_m / getAttenuationLength(D_m, f_kHz)) / d_m;
97 }
98
99
100 /**
101 * Utility class for emitter power and frequency.
102 */
103 struct JWaveform {
104 /**
105 * Default constructor.
106 */
108 Q0 (0.0),
109 f_kHz(0.0)
110 {}
111
112
113 /**
114 * Constructor.
115 *
116 * Note that the power corresponds to the minimal distance (see method JWaveform::getDmin()).
117 *
118 * \param Q0 power [quality]
119 * \param f_kHz frequency [kHz]
120 */
121 JWaveform(const double Q0,
122 const double f_kHz) :
123 Q0 (Q0),
124 f_kHz(f_kHz)
125 {}
126
127
128 /**
129 * Get minimal distance.
130 *
131 * \return distance [m]
132 */
133 static double getDmin()
134 {
135 return 1.0;
136 }
137
138
139 /**
140 * Get quality at given distance.
141 *
142 * \param D_m depth [m]
143 * \param d_m distance [m]
144 * \return quality
145 */
146 double getQ(const double D_m,
147 const double d_m) const
148 {
149 if (d_m > getDmin())
150 return Q0 * JPP::getQ(D_m, this->f_kHz, d_m) / JPP::getQ(D_m, this->f_kHz, getDmin());
151 else
152 return Q0;
153 }
154
155
156 /**
157 * Read waveform from input stream.
158 *
159 * \param in input stream
160 * \param waveform waveform
161 * \return input stream
162 */
163 friend inline std::istream& operator>>(std::istream& in, JWaveform& waveform)
164 {
165 return in >> waveform.Q0 >> waveform.f_kHz;
166 }
167
168
169 /**
170 * Write waveform to output stream.
171 *
172 * \param out output stream
173 * \param waveform waveform
174 * \return output stream
175 */
176 friend inline std::ostream& operator<<(std::ostream& out, const JWaveform& waveform)
177 {
178 return out << waveform.Q0 << ' ' << waveform.f_kHz;
179 }
180
181 double Q0;
182 double f_kHz;
183 };
184}
185
186#endif
Auxiliary classes and methods for acoustic position calibration.
static const double TOAMIN_S
Minimal allowed time-of-arrival [s].
double getQ(const double D_m, const double f_kHz, const double d_m)
Get relative quality for given frequency at given distance.
static const double TOAMAX_S
Maximal allowed time-of-arrival [s].
static const JAttenuationLength getAttenuationLength(13.2, 38.0, 8.0)
Function object to calculate attenutation length.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for calculation of attenuation length.
double operator()(const double D_m, const double f_kHz) const
Get attentuation length for given frequency at given depth.
JAttenuationLength(const double T, const double S, const double pH)
Constructor.
Utility class for emitter power and frequency.
double getQ(const double D_m, const double d_m) const
Get quality at given distance.
static double getDmin()
Get minimal distance.
friend std::istream & operator>>(std::istream &in, JWaveform &waveform)
Read waveform from input stream.
JWaveform()
Default constructor.
JWaveform(const double Q0, const double f_kHz)
Constructor.
friend std::ostream & operator<<(std::ostream &out, const JWaveform &waveform)
Write waveform to output stream.