\documentclass[a4paper,12pt]{report}
\usepackage{gensymb}
%% \usepackage{babel}
\usepackage[latin1]{inputenc}
\begin{document}

\tableofcontents

\chapter{Sonar and its simulation}

\section{Introduction}

The facts and formulas presented here are the results of a long research
over the internet and the conclusions of many implementation tests. We
took some information from the documentation of the "Harpoon 3" sonar
model and from a document describing the most common German listening
device of World War 2, the "GHG" (Gruppenhorchgerät).

There are many sources of noise in the ocean. Beside the disturbances of
the ocean surface by the wind, background noise by animals and
geological activities and sudden events like exploding depth charges
etc. the most important source are the vessels cruising around the sea.
This means the ships and submarines of the game.

% explain/handle: convergence zones (sound reflecting of water surface or sea floor
% several times, make sounds travel longer)
% explain sound synthesis for simulation

Sound propagates as waves underwater, its speed depending on many
factors, like temperature (the most important), pressure, salination and
other values of the water (amount of algae etc.).

Computing the noise level at any point in the ocean we can use the ray
tracing model to simulate sound propagating from an arbitrary
source. Sound waves propagate in water, are reflected and refracted on
borders between layers in the water and so on. If the sound ray
intersects a the border between two layers with different speed of
sound, the ray is reflected and refracted according to Snell's law. Also
other vessels can reflect sound waves etc. This simulation can be
extended to a great complexity.

The speed change is not so important in horizontal (x/y) direction, but
in vertical (z) direction as the water forms mostly horizontally
oriented layers. Temperature is the most important factor. We need to
simulate reflection and/or refraction at border of those layers, at
least for active sonars like ASDIC.

Hiding the submarine "below" a thermal layer was and is an important
tactical aspect of submarine warfare.

Sound strength is decreased with growing distance when the sound spreads
in the water. Lower frequencies are transmitted over a longer range.

This is named propagation and absorbtion. Strength of the sound is
distributed over the area the sound is spread. Because the area grows
quadratically with the distance, the strength falls off with the square
of the distance. Absorption depends on frequency of the sound, higher
frequencies are absorpted with an much higher rate. Using the
logarithmic model for sound strengths the squares etc. can be written as
multiplications or divisions, which gives simple formulas.

We add the background noise strength (ambient noise) as well as all the
noise sources to the strength of one signal, subtract the
signal-to-noise-ratio level of the receiver (signals weaker than a
certain level are cut off) and do this for each frequency band. This
gives the frequency spectrum that is received at the sub's sonar.

\section{Physical facts}

\subsection{Constants and basic formulas}

Sound travels in sea water with a velocity of $v = 1465 m/s$ where in
air it travels with ca. $340 m/s$. Because velocity is wavelength
multiplied by frequency ($v = \lambda * f$) and velocity is constant,
the wavelength depends on the frequency.

A signal or noise is composed of many basic waves with its own frequency
each. For simplification we treat signals just as sine waves, thus
$signal(t) = a * \sin (x + p)$, where $a$ is the amplitude and $p$ is
the phase.

Because human perception is logarithmic, we can handle sound in a
\emph{deci-Bel scale (dB)}, where (logarithmic) intensity $L = 10 *
log_{10} (I)$. Intensity is pressure divided by specific density and
speed of sound in water: $I = \frac{P^2}{\rho * v}$ (unit of $P$: $Pa =
N/m^2$, unit of $I$: $N/(m*s)$ and $\rho$ is $1000 kg/m^3$).

\subsection{Signal physics}

Sound is spread underwater from any source in the shape of a growing
sphere. For our simulation we handle sound simulation in a horizontal
plane only, thus sound is spread in a circle around its source. Because
the total strength is constant after leaving the source, and the
strenght is distributed over the whole area, the sound strength is
decreased by the square of the distance to its source. This is called
propagation and thus $I_{prop} = I_0 / R^2$ with $R$ is the distance to
source. Of course it is $R = v * t$.

While sound travels through water, the molecules of water absorb sound
energy. The higher the frequency of the sound, the greater the
absorption effect. The absorption coefficient $m_f$ depends mostly on
temperature of the water and frequency of the sound wave. The formula is
$(2.1*10^{-10} * (T-38)^2 + 1.3*10^{-7}) * f^2 = g(T) * f^2$ (unit:
$dB/m$), where $T$ is temperature in centigrade and $f$ is frequency in
kHz\footnote{Since we simulate frequency bands, we can compute the
  medium constant for a band by integrating that formula over f and
  computing the integral from lower to upper frequency limit. $\int g(T)
  * f^2 df = \frac{1}{3} g(T) * f^3$ thus $\int _a^b g(T) * f^2 df =
  \frac{g(T)}{3} ( b^3 - a^3 )$ and for the medium $m_f(T) = \frac{g(T)
    (b^3-a^3)}{3(b - a)}$. If we assume 10° for T we get $g(T) =
  0.000194473$ which gives for 500Hz $m_f = 0.000048618$ and for 1kHz
  $m_f = 0.000194473$. If we use the integral and choose as band 20Hz to
  1kHz we get $m_f = 0.000066147$. For the other bands we get $m_f =
  0.000842717$ for 1kHz-3kHz, $m_f = 0.004083938$ for 3kHz-6kHz and $m_f
  = 0.002744233$ for 6kHz-7kHz.}. We thus get: $I_{absorb} =
\frac{I_0}{m_f * R}$.

This gives in total: $I = \frac{I_0}{m_f * R^3}$. Thus high frequency
signals are rather weakened by absorption and low frequency signals are
reather weakened by propagation. Low frequent sounds can travel even
hundreds of miles.

%% todo: talk about background noise and sensor sensitivity and the rest of the harpoon3 docs

%% talk about noise sources and frequency band simulation!

\section{The listening device GHG}

\subsection{How it worked}

The vessel hat a certain number of hydrophones mounted around its hull
(GHG had 24 hydrophones per side). The output of these hydrophones as
electrical signal was fed to electrical rotor contacts, that sat on a
turnable rectangular device, that was made of a certain number of metal
strips (most common: 100 strips with GHG). Each strip was connected over
an electrical delay circuit to the next strip. Thus, an electrical
signal arriving at strip $n$ was delayed by $n * t_{stripdelay}$, where
$t_{stripdelay} = 17\mu s$ on German GHG devices. Strip lines are
numbered $0 \ldots 99$ from bottom to top in our simulation. The
contacts were placed like a scaled projection of their real position
around the hull.

Because sound arrives at each hydrophone at another point of time, the
hydrophone outputs had to be combined with delay for each signal so that
the result gave a sensible represenation of the sound signal for the
human ear. The GHG did exactly that - the electrical delay between each
strip line and the distance between two hydrophones and the positions of
the rotor contacts were exactly choosen so that delay of sound in water
between two hydrophones matched the electrical delay between the two
strips that the rotor contacts of the two hydrophones were connected to.

This has also another important side effect, that is the main purpose of
the GHG device: total output gets weaker when the GHG rotor apparatus
was turned away from the signal's direction. This happens because the
signal output of the hydrophones are layed on top of each other with
various phase shifts. When the electrical delay doesn't match the sound
delay any more, phase shifts unequal to zero occour. The larger the
angle between signal direction and GHG apparatus becomes, the weaker the
signal gets.

\subsection{Problems}

Simulation showed two serious problems with that arrangement: because we
have a fix, integer number of strip lines, the phase shifts are discrete
values, leading to a non-monotonous rise or fall of total signal output
when the device was turned. This even lead to serious jitter in the
output signal strength.

The second problem were "ghost" signals appearing at higher
frequencies. At higher frequencies several periods of the signal are
received by the hydrophones and fed to the strip lines. So the discrete
phase shift compensation becomes more and more problematic. Output
between two neighbouring hydrophones shows a phase shift of a half
period or more, but the electrical delay for phase shift compensation
has only a low resolution at high frequencies. So many signals that
should overlay each other and neutralize themselfes mistakingly add up
to a high output. This happens with an offset of ca. $90\degree$, so a signal
causes a peak at its real position and one with $90\degree$ offset.

Beside these two problems the GHG simulation gave only little difference
between peak signal output and base output, making it hard to
distinguish signals from background noise. A signal causes high output
not only at the hydrophones listening to its direction, but also at all
other hydrophones. We tried to vary hydrophone position, field-of-view
width and listening direction, but it didn't help. The jitter was so
high, that it nearly reached peak signal strength.

We thus decided to create our own function to simulate falloff of signal
strength depending on angle between signal and apparatus and on
frequency. A good base are powers of the cosine function:
$$strength(f,
\alpha, \beta) := \max(0, \cos ^ {k * f} (\alpha - \beta))$$ where $f$
is frequency, $\alpha$ and $\beta$ are signal direction and apparatus
angle and $k$ is a falloff constant. The constant must be choosen so
that at certain frequencies the top of the peak function has at least $1
dB$ more output for $\beta$ degrees than the rest. This is because the
human ear works in $dB$ scale and can distinguish signal strengths on a
$dB$ base. Historical information of the GHG showed $8\degree$ precision at
$500 Hz$, $4\degree$ precision for $1 kHz$, $1.5\degree$ for frequencies above $3
kHz$ and less than $1\degree$ for frequencies above $6 kHz$. So the constant
$k$ must be choosen that for $\beta ^+_- \gamma$ degrees the output of
$strength$ is at least $1 dB$ higher than the value for any other angle.

\section{What can we learn from "Harpoon 3"}

\subsection{Formulas}

"Harpoon 3" uses the following formulas (note: $\phi(x) := 10^\frac{x}{10}
= (10^{0.1})^x = 1.258925412^x$, so the function $\phi$ transforms
deziBel values to linear sound intensity values):

\begin{tabular}[t]{|l|p{40ex}|} \hline
Target noise & $L_t = L_{t_0} + G_f + m_{v_t} * v_t + G_c$ \\ \hline
Ambient noise & $L_a = L_{a_0} + m_{w_p} * sea\ state\ level$ \\ \hline
Sensor background noise & $L_r = L_{r_0} + m_{v_r} * v_r$ \\ \hline
Total sensor background noise & $L_{b_p} = \frac{1}{m_b} \phi^{-1}(\phi(L_r) + \phi(L_a))$ \\ \hline
Condition for passive detection & $L_t - 20 * log_{10}(R * 1852) - m_d * R - L_{b_p} \ge G_{s_p}$ \\ \hline
\end{tabular}

Where $G_{s_p}$ is passive sensor sensitivity, depending on sensor type.
Note that $L_{t_0}$ is a single constant per vessel, that describes the
basic noise level of that vessel. Noise levels for the various bands are
described by adding a band specific constant $G_f$. Note further that
the numbers in the condition detection formula are derived from the
propagation and absorption simulation of sound (propagation $- 20 *
log_{10}(R * 1852)$ and absorption $- m_d * R$ for range $R$ in nautical
miles).

\subsection{Constants}

Here are some values and constants use by "Harpoon 3" as an example
(all values in deziBels):

\begin{tabular}[t]{|p{50ex}|c|c|c|} \hline
Value & LF & MF & HF \\ \hline
Ambient noise base $L_{a_0}$ & 87 & 90 & 73 \\ \hline
Noise increase per sea state level $m_{w_p}$ & 5 & 5 & 5 \\ \hline
divergence of band noise level from average noise level $G_f$ & -6 & +5 & -19 \\ \hline
target noise increase by speed (per knot) $m_{v_t}$ & 1 & 1 & 1 \\ \hline
noise increase by cavitation (only at full/flank speed) $G_c$ & 2 & 2 & 2 \\ \hline
background noise from receiver, per knot $m_{v_r}$ & 3.6 & 4.2 & 5.5 \\ \hline
background noise reduction factor $m_b$  & 3.4 & 2.9 & 3.7 \\ \hline
dispersion factor (per nautical mile) $m_d$ & 1/6 & 1 & 3 \\ \hline
\end{tabular}

Note that sea state level of 3 means "small waves" and 8 means "high
seas", we thus can assume that sea state level is in range 0\ldots 10.
The base values per vessel ($L_{r_0}$ for receiver etc.) do vary. There
is no reason given for the use of the "background noise reduction
factor", but note that it is multiplied in the deziBel value range, so
it is an exponent in absolute sound strength space.

\subsection{Conclusion}

"Harpoon 3" makes some crude simplifications. To make computing of sound
strengths easier, all frequencies are distributed to three frequency
bands (Low, medium and high frequencies, LF/MF/HF). Computations are
done in a simple version in deziBel space. Background noise is decreased
by a factor, so the example values are way too high itself. The noise
strength of a target depends rather on its basic noise strength than on
its speed, which is unrealistic. We should use basic noise levels for
every frequency band and use more bands (four, 0\ldots 1kHz, 1\ldots
3kHz, 3\ldots 6kHz, 6\ldots 7kHz).  Background noise should be decreased
before summing it up or even while calculating it, not after summing of
all background noise sources.

\section{Special effects of the various listening devices}

The number of microphones and the number of strip lines (membranes) in
the device determine the resolution of direction finding, as well as the
frequency and strength of the signal.

To correctly detect the signal and to distinguish between left/right and
front/aft signals, groups of the microphones could be disabled.

To allow reliable detection a submarine needs to dive below 20m to avoid
the disturbing noises of the ocean surface.

The operator of a device can detect any number of signals (as long as
the resolution allows it). But to keep track of more than one signal he
needs to switch permanently between two signals and redetect them. This
is a difficult and time consuming process. Thus the simulation should
limit the number of signals he could keep track of to, say,
max. five. Of course he could mix up two signals that are to close to
each other and start tracking a wrong signal. And the update of the
actual position of each signal is delayed by the detection process for
the other signals. E.g. if the operator needs 5 seconds to localize one
signal and keeps track of three, he can update the position of each
signal only every 15 seconds. This is an important aspect of
simulation. Too many noise sources will disturb the correct localization
as well.

\subsection{Kristallbasisdrehgerät (KDB)}

Freely turnable, no all-around detection...
Some special effects not yet described here...
(fixme)

\subsection{Gruppenhorchgerät (GHG)}

Blind spots...
Select group of hydrophones...
(fixme)

\subsection{Balkongerät (BG)}

Blind spot at stern...
(fixme)

\section{How sound is simulated in "Danger from the Deep"}

\subsection{Physics}

Compute target noise for a target: $L_t = L_{t_f} + m_{v_t} * v_t + G_c$
where $L_{t_f}$ is the basic noise level for a specific target and a
given frequency band. Compute the noise for all targets and all
frequency bands and sum them up to $I_{targets} = \phi(L_{targets})$.
Note that the intensities that are summed up here are computed with all
effects taken into account, like propagation and absorption ($L_{target}
= L_t - L_{prop} - L_{absorb}$).

Compute background noise from ocean's background noise and receiver's
background noise: $I_{backgr} = \phi(L_a) + \phi(L_r)$ where $L_a$ is
constant over all vessels for a given frequency band (depends only on
weather etc.), and $L_r$ depends on the receiver's vessel.

Now divide by sensor sensitivity and round to integer dB values:
$I_{total} = I_{targets} + I_{backgr}$. The value should be cut off
(clamped) at some small value $\theta > 0$, thus if it is less than
$\theta$, set it to $\theta$. This gives a minimum deziBel value of
$\phi^{-1}(\theta)$ that may be less than zero. The resulting value is
fed to the sonarman simulator:

$$L_{result} = \lfloor \phi^{-1}(\max(\theta, \frac{I_{targets} + I_{backgr}}{\phi(G_{s_p})})) 
\rfloor$$

Note that we do not \emph{subtract} background noise intensity from
target noise intensity, as the formulas of "Harpoon" would suggest. This
could lead to negative intensity values and is also not physically
correct. Instead by adding both intensities and transforming them to the
deziBel range, high background noise intensities will "shadow" target
noise signals and thus is what we want to accomplish.

To compute the total sound intensity of all frequency bands we sum them
up multiplied by a band specific constant: $I_{total} = \sum_{i=1}^{nr\
of\ frequency\ bands} I_{band_i} * m_{band_i}$.

\subsection{The general idea}

While simulating general noise strengths around the submarine, we have
to present the noise to the user. This means we have to generate a
final, hearable sound fetched to the sound driver, that is computed by
the data of the physical simulation and a pool of predefined, recorded
samples, like screws of various ship types.

The problem is that the distance of the signal sources and the
characteristics of the listening devices change the form of the sound.
The farer away a noise source is, the weaker it gets - but high
frequencies fall off much faster. This means that we would have to use
some sort of equalizer on the pre-recorded sound samples to make them
sound realistic when presented to the user's headphones or speakers.

To implement that we would need some sort of Fourier transformation, to
transform the pre-recorded sample to frequency space, where we can cut
higher frequencies and then transform it back. Even with fast Fourier
transforms this can be done in realtime but would eat insane amounts of
CPU time.

A much better approach would be to precompute the various frequencies of
a recorded sample offline, that means split the sample to many different
samples, each with its own part of the frequency spectrum. Like:
$$ Record = \sum_{i=1}^n f_i(x)$$
where $x$ is time and $n$ is the number of frequency bands. The
$+$-Operator used here is a sample mixing function, which can be a real
addition or some function provided by the sound card. If the number of
frequency bands is not too high, today's sound cards can mix them in
hardware. We would need to generate the $f_i$ samples offline, that
means not in realtime - this can be done with the FFT as mentioned
above. To mix a realistic sound we compute:
$$ Play = \sum_{i=1}^n f_i(x) * s_i$$
where $s_i$ is a frequency dependent scalar.

The question is here, how many discrete frequency bands should be
simulated. The result gets more realistic, the more bands are used. We
have to simulate physics of sound for each band though, but that is not
too costly. The biggest problem is how many sound samples can be mixed
in realtime later. A number of 8 to 16 should be doable here.

Related to that problem is the issue of detecting the type of the noise
source. A specific source can be determined by the distribution of
frequencies around the whole spectrum. For the detection to be
definitive, we need to simulate enough discrete frequency bands, by far
more than four. Especially many more bands in the low frequency range
are needed. The distance to the sound source then changes the signature
of the noise, as higher frequencies decay faster. And most important for
the simulation is the effect that various signal sources will overlap
and form a new frequency distribution in the user's earphones. That
makes deistinguishing the signals more difficult as well as determining
the type of the strongest signal. This is an important aspect of
simulation, e.g. in a noise environment the operator could misinterpret
a signal type and detect an escort as harmless civil ship.

Is is unclear how many discrete bands would have to be simulated for an
almost exact simulation here, and how their distribution over the whole
spectrum would have to be. It is also unclear how an algorithm that
determines the type of signal should work. It could sum up the squares
of the differences between the amplitudes of each frequency band of the
listened signal and a known reference signal. However that ignores the
faster decay of higher frequencies with increasing range. The most
realistic form could be some kind of neural network here that is trained
for all known sources. Input would be the amplitude of each frequency
band, output would be the type of signal. The total strength of the
signal is represented in medium amplitude of all bands, so the net can
be trained to take the distance into account too.


% fixme: add noise from own receiver!!!

% fixme: sonar man should not build center of two angles for result
% reporting! because the signal strengths are symmetrical, this would give
% much higher precision than in reality. in fact the low precision with low
% frequencies wouldn't be simulated well! with 8° of same signal strength at
% < 1kHz the operator would find the middle or half of 4° and report an
% exact position anyway - not quite good.

%% missing: wave interference in shallow water factor
%% missing: convergence zones


% /* passive sonar, GHG etc */
% /* how its done:
%    for all noise sources within a sensible range (20 seamiles or so)
%    compute signal strength for four frequency bands (0-1kHz,1-3kHz,3-6kHz,6-7kHz).
%    compute direction of signal.
%    compute sonar signal sensitivity (depends on sonar type - specific sensitivity - and of
%      speed of receiver. Higher speeds decrease sensitivity, much more effect than speed of
%      targets for target noise strength).
%    depending on angle of ghg apparaturs reduce signal strength of all signals
%    (cos(angle) between direction and ghg angle = normal vector from ghg angle).
%    (NOTE: do this ^ with new reduction function!)
%    handle background noise of own sub/ship
%    compute and add background noise (ambient noise)
%    subtract own noise + sensitivity, rest is signal strength
%    make signal strengths discrete, depending on frequency, lower freqs -> larger steps !NO!
%      discrete steps not in dB but depending on angle! lower freq -> bigger steps !NO!
%    discretize ALL signals only to dB, independent of frequency!!!
%    sum of strenghts is resulting noise strength, feed to user's headphones or to sonar operator simulator
%    weighting of various frequency strengths depends on human perception and width of freq. bands
%      1-3 kHz *0.9, 0-1 kHz *1, 3-6 kHz *0.7 6-7 kHz *0.5, total strength is weighted sum div. weight sum of used bands.
%    => noise of ships must be stored in distributed frequencies or we need a online bandpass filter
%       to weaken higher frequencies
%    blind spots of GHG etc need to be simulated, BG is blind to aft, GHG to front/aft, KDB to ?
%    NOTE: compute that with strength reduction formula!
   
%    HOW THE GHG WORKS:
%    Sound signals arrive at the hydrophones on different points of time.
%    Thus, a signal function depends on time: s(t).
%    The signal is the same for all hydrophones, but with varying time:
%    s_i(t_i) = s_j(t_j) for i,j in 0,...11 for 12 hydrophones, and t_n = t_0 + n * delta_t
%    delta_t can be computed, it is the the time a signal needs to travel in water to
%    cover the distance between the two hydrophones. If the electrical delay caused by the
%    strip lines of the strip line array inside the GHG match delta_t, then all signals
%    are overlayed with the same time factor:
%    strip line output = sum over i of s_i(t_i ) = sum over i of s_i(t_0 + i * delta_t)
%    We know that a sum of signals gives the signal with maximum amplitude when there is
%    no phase shift between them, e.g. sum_i=0..3 sin(x+i*m) for any small m is maximal
%    when m is zero. The larger the absolute value of m is the weaker the signal gets.
%    Thus, the strip line output is maximized, when the delay of each signal in water
%    equals the electrical delay.
%    (Note that the formulas above match a situation where a wave comes from the bow and the
%    strip line array's membranes are perpendicular to the sound wave, thus the GHG points
%    also to the bow. But it even works when the hydrophones are arranged in a line from
%    bow to aft and the sound wave comes directly from starboard direction - in that case the
%    sound hits all hydrophones at the same time, all signals go to one strip line and thus
%    the output is maximized. When the strip line array is turned away then the hydrophone
%    outputs are distributed over multiple lines, causing delay and phase shift of the summands
%    of the signal, thus leading to a weaker total output.)
%    Proof: the hydrophones are arranged in an array with roughly 2.2m length. To travel
%    that distance the sound takes 1.5ms. The strip line array has 100 strips with 17µs
%    delay between each strip given a total maximum delay of 1.7ms. This fits.
%    When the strip line array is not facing the signal perpendicular, the electrical delay
%    and the sound delay in water differs, leading to a phase shift of signals in any direction,
%    weakening the total signal output. This is modelled by the fall-off function that is a
%    function of the angle between the GHG apparatus angle and the incoming signal's angle and
%    also of the frequency of the signal.
%    We only need to compute an historically accurate fall-off function. This is done by
%    simulating the phase shifts and thus a real GHG as close as possible.
%    (at the moment the function compute_signal_strength_GHG() does this).

%    fixme: handle noise strengths a bit different! do not cut off at 0 dB!
%    0 dB = Intensity 1, but sensor sensitivity can be much smaller, up to
%    -18 dB = 0.015 N/m² and thus even much weaker signals are detected...
%    I_0 = 10^-6 Pa/m²
%    Propagation: loss off 100dB on 10000m, or factor 10^-10
% */


% 	// detection formula:
% 	// compute noise of target = L_t
% 	// compute ambient noise = L_a
% 	// compute sensor background noise (noise from own vessel, receiver) = L_r
% 	// store sensor sensitivity = S
% 	// The signal is detected when L_t - (L_a + L_r) > S
% 	// which is equivalent to L_t > S + L_a + L_r
% 	// This means loud background noise (e.g. rough seas) or high noise from own
% 	// vessel shadows target noise. We need to quantize the received noise somehow
% 	// or we could always find loudest source if background and own noise is constant,
% 	// because target noise would be the only varying factor.
% 	// The current way of detecting sounds is thus not realistic, as the highest
% 	// noise signal is always detected, no matter how big the difference to the back-
% 	// ground signals is...
% 	// By using the formulas above, noise strengths are multiplied (logarithmic scale!)
% 	// instead of copied. Maybe this models shadowing better...
% 	// weak signal of 1 dB and strong signal of 50 dB.
% 	// Adding them and computing dB of addition gives 50.000055 dB, total shadowed.
% 	// Adding them in dB scale gives 51 dB, which is not right.
% 	// What about subtraction? 50 dB - 1 dB = 49 dB, in real scale 49.99995 dB, nearly 50.
% 	// So adding dB values is bad, as weaker signals get accounted much stronger
% 	// than they are.
% 	// Solution maybe: quantize the target's noise, so weaker signals have the same
% 	// quantum as the background noise and vanish.

% 	// fixme: ghost images appear with higher frequencies!!! seems to be a ghg "feature"


% 	// fixme: depending on listener angle, use only port or starboard phones to listen to signals!
% 	//        (which set to use must be given as parameter) <OK>
% 	// fixme: add sensitivity of receiver (see harpoon docs...)  TO BE DONE NEXT
% 	// fixme: add noise produced by receiver/own ship            TO BE DONE NEXT
% 	// fixme: discretize strengths!!! (by angle and frequency!) <OK, MAYBE A BIT CRUDE>
% 	//        this could be done also by quantizing the strength (in dB) of the signal,
% 	//        or both. To be tested...
% 	// fixme: identify type of noise (by sonarman). compute similarity to known
% 	//        noise signatures (minimum sim of squares of distances between measured
% 	//        values and known reference values). this should be done in another function...
% 	//        To do this store a list of typical noise signatures per ship
% 	//        category - that is also needed for creating the noise signals.
% 	//        <OK> BUT: this doesnt work well. To determine the signal type by distribution
% 	//        to just four frequency bands is not realistic. Signals are distuingished
% 	//        by their frequency mixture., CHANGE THIS LATER

\section{Simulation of the sonar operator}

The sonar operator (sonarman) has two modes of operation. Either he
listens all around the compass to detect any signal or he tracks a
specific signal.

\subsection{Scan mode}

This is the common mode. The sonarman turns his device around the clock
(e.g. in clockwise order) while he listens to any signals received by
the hydrophones. When he recognizes a growing signal strength he
continues turning until the signal gets weaker again. He then remembers
the angle where the signal got weaker and turns back his device, to find
the angle where the signal reaches its maximum strength. Because he is
turning the device in the opposite direction now, he is again listening
for the moment that the signal gets weaker. When he found it he has the
second angle, computes the medium value of both angles and reports the
contact. He could turn the device to the computed center of the signal
and try to determine the type of signal (given by distribution of
frequencies). After that he continues in normal direction and listens to
the next signal.

With that algorithm he finds every peak signal around the clock, but
this takes time. Approximately one to two minutes for all 360 degrees.
This is to slow to track a strong signal, like an attacking escort.
Tracking such signals is of course more important than an all-around
scan. So the operator switches to track mode when he detects a signal
that is stronger than some certain limit. Of course if there is an even
stronger signal not yet detected, this one is missed, but that is
realistic.

The operator keeps a list of contacts that is permanently updated while
he turns his device over and over. Newer reports make older ones
obsolete that are within a certain angular neighbourhood (e.g. 3
degrees). But this can be done simpler. Every contact at angle $n$ gets
obsolete when the device turns over that angle \emph{again}, thus new
reports are replacing old ones automatically.

\subsection{Track mode}

The operator knows the angle (and type) of the signal when he starts the
track mode. He turns his device permanently some degrees left and right
until he finds the angle where the signal is strongest. He constantly
updates the contact report, but keeps all other (and thus older) reports
in his list. When the signal gets too week, he switches back to scan
mode.

The operator could also check the type of the signal. If type changes
then he could switch back to scan mode or could widen its scan area
around the last angle until he found the strong signal again.

To make more precise records he would have to turn the device left and
right to find the limits of the signal and compute its center, as the
signal may be evenly strong over a greater angular range. Thus the track
mode is like scan mode, but with the device constantly turning between
the two angles where the signal falls off. The range between these two
angles is the range with the peak value.

As a variation the captain (the player) could determine which signal
should get tracked by the operator, or when the operator should switch
back to scan mode. The user interface and interaction here may be
complex but will give a very realistic simulation.

\end{document}
