You are on page 1of 30

REPORT

ON

Acquisition and Analysis of Passive Acoustic Data

Prepared for the course BITS F221


Practice School – 1
AT

National Institute of Oceanography


Goa

A Practice School Station Of


Birla Institute of Technology & Sciences, Pilani
Birla Institute of Technology & Science, Pilani

Practice School Division

Station: National Institute of Oceanography, Goa Centre: Goa

Duration from: 21/05/19 To: 13/07/19

Date of Submission: 14/06/19

Title of Project: Acquisition and Analysis of Passive Acoustic Data

NAME ID NO

Prateek Mahajan 2017A3PS0317P

Pratyush Sinha 2017B1A31002P

Name of Mentor: Sh. William A. Fernandes


Name of PS Faculty: Dr. Pravin Mane
Project Area : Passive Underwater Acoustics
ABSTRACT

Recording of passive acoustic data involves the usage of passive sensors to


transform the mechanical vibrations in water into electrical signals. The further
sampling and logging of the transformed signal can be accomplished with the
help of an embedded system. This report deals with the design and
development of the aforementioned embedded system, and the processing of the
data acquired from the laboratory and field to analyse it.

Signature of student

Signature of PS faculty :

Date :
ACKNOWLEDGEMENTS

The internship opportunity we had with the CSIR- National Institute of


Oceanography, Goa was a great chance for learning and professional
development. We are grateful to have been given an opportunity to get an insight
into the working of a prestigious research institute like the above.

For the above, we would firstly like to thank Professor Sunil Kumar Singh,
Director, NIO Goa for the opportunity to work in CSIR-NIO.

We would also like to express our deepest gratitude and thank our mentor, Mr.
William A Fernandes, who, in spite of his busy schedule, took time out to hear
and guide us, and provide his full support in our project in any way possible.

Lastly, we would like to thank our PS instructor, Dr. Pravin Mane for providing
us his constant support and supervision, and for his valuable suggestions which
proved to be of great value for us to complete our project.

Special thanks to BITS PILANI for providing us this golden opportunity in the
form of Practice School.
FIGURES AND TABLES

FIGURES:

Sl. No. Figure Label


1. Block Diagram of Data Logger Circuit
2. Logic flow of data logger software
3. Experimental setup for data acquisition in laboratory
4. Pipettes used in experiment
5. Signal Processing work flow
6. Fourier Transform algorithm
7. Algorithm for FFT
8. Signal to Noise Ratio.
9. Output signal after Filter
10. RMS Envelope
11. Hilbert Envelope
12. Peak Envelope
13. Expression of STFT

TABLES:

Sl.no. Table label


1. Laboratory Log
TABLE OF CONTENTS

1. About the Institute


2. Introduction
3. Design of Logger
4. Method of Experiment
5. Work flow of Signal Processing
6. Spectral representation of signals
6.1 DFT- Discrete Fourier Transform
6.2 DTFT- Discrete Time Fourier Transform
7. Pre-Processing
7.1 Filter Design and Implementation
7.2 Signal Enveloping
8. Exploration of Signal
8.1 Spectrogram
8.2 Periodogram
9. Annexure A
10. Annexure B
11. References
ABOUT THE INSTITUTE

The National Institute of Oceanography (NIO) with its headquarters at Dona


Paula, Goa, and regional centres at Kochi, Mumbai and Visakhapatnam, is one of
the 37 constituent laboratories of the Council of Scientific & Industrial Research
(CSIR), New Delhi.

CSIR-NIO was established on 1 January 1966 following the International Indian


Ocean Expedition (IIOE) in the 1960s. The institute has since grown into a multi-
disciplinary oceanographic research institute of international repute. The
principal focus of research has been on observing and understanding special
oceanographic characteristics of the Indian Ocean. The results have been reported
in more than 5000 research articles so far.

The institute has a sanctioned strength of 200 scientists and 100 technical support
staff. The major research areas include the four traditional branches of
oceanography - biological, chemical, geological/geophysical, and physical – as
well as ocean engineering, marine instrumentation and marine archaeology
The institute has numerous state-of-the-art laboratories at its headquarters in Goa
as well as the regional centres. It also operates two research vessels RV Sindhu
Sankalp (56 m) and RV Sindhu Sadhana (80 m) that are equipped for
multidisciplinary oceanographic observations. The institute has a library with
15,000 books and 20,000 back volumes of research journals, making it the best
collection of printed literature on ocean sciences in the country.

In addition to basic research, the institute also carries out applied research
sponsored by the industry. These studies include oceanographic data collection,
environmental impact assessment, and modelling to predict environmental
impact. The institute also provides consultancy on a number of issues including
marine environmental protection and coastal zone regulations.

With the largest collection of ocean scientists in the country, and equipped with
suitable ocean research infrastructure, CSIR-NIO serves as an advanced centre of
education in ocean sciences. It has a School of Oceanography under the Academy
of Scientific & Innovative Research (AcSIR). In addition, it is a recognized centre
for doctoral research by a large number of universities. There are at present over
100 Junior/Senior Research Fellows (qualified through CSIR/UGC eligibility
criterion) pursuing their doctoral studies in the institute. In addition, about 300
undergraduate and postgraduate students pursue their project research at this
institute every year.
INTRODUCTION

In a marine environment, the sound signals are generated by various sources


(surface as well as undersea) and are collectively called as marine ambient noise
(AN). AN is sometimes classified as geo-phonic, bio- phonic and anthro-phonic.
These underwater ambient noise signals are capable of travelling long distances
and therefore can be studied for number of applications such as underwater object
detection, tracking of marine habitats and identification etc. Ambient noise
analysis already has various terrestrial applications including forest soundscape
studies using animal/ bird sounds for species identification, quantification studies
and protection. The migration of birds is a phenomenon that occurs due to climate
change[1]. Hence, pattern associated with the above does provide some
signatures of climate change. Thus, long term monitoring of environmental
parameters may be used for climate research[2]. The study of traffic and pollution
data can also be used to comprehend the environmental parameters. All the above
mentioned research studies can be undertaken by implementing economically
low cost data loggers within the region of interest.

In this report, we are presenting a Single Channel Data Logger and the data
associated with it from laboratory tests. Further, we shall present the signal
processing system we have developed to analyse the data obtained from the
laboratory tests mentioned earlier.
DESIGN OF LOGGER

The Single Channel Data Logger designed was done so around a Teensy 3.6
cortex-M4F ARM(Advanced RISC Machine) processor board. The Teensyduino
software provides integrated support for Teensy microcontrollers within the
Arduino IDE software platform by adding microcontroller specific libraries and
the compiled program download utility that loads the program to the
microcontroller memory. While designing the circuit for the above, a signal
conditioning board(using an LM-324) was tested. However, owing to the fact that
better results were obtained without the latter, the LM-324 was scrapped. Hence,
the final circuit used in the logger was-

V1

Vibrations in
water

Fig 1: Block Diagram of Data Logger Circuit


Over here, pin number 33 of the teensy 3.6 board is connected to the
hydrophone signal input and a common ground is in place with the ground of
the teensy connected to that of the hydrophone. Further, a program was
executed on the teensy (using the Teensyduino plugin) to log the data at a
sampling rate of 56.00 kHz and copy it onto the sd card inserted in the above.
While doing so, there were 2 options available-
1. Saving the data on a text file
2. Saving the data on a binary file
Upon testing, it was found that saving the data on a text file took too much time
and made it unfeasible to maintain a sampling rate of 56.00 kHz. Therefore, the
data logged from the above device will be saved on a binary file. The logic flow
of the program has been displayed below.
Fig 2: Logic flow of data logger software
The program written corresponding to the above logic flow is present in
annexure A of this report. The data logged in the sd card( in the form of a binary
file) is then converted into its ascii form with the help of a C++ code. The above
is present in annexure B of this report.

The following are the data recording settings-


1. Sampling rate- 56.00 kHz
2. Sampling Interval- 60s
3. Recording Interval- 15s
METHOD OF EXPERIMENT
A data logger, with a design and specifications as explained earlier, was used to
log data in the laboratory using the following setup-

Hydrophone

Teensy 3.6

Junction Box
with battery

Fig 3: Experimental setup for data acquisition in laboratory

Further, the following pipettes were used to generate bubbles in the water.

25 mL Mohr-type
borosil pipette

10 mL Mohr-type
borosil pipette

1 mL Mohr-type
borosil pipette

Fig 4: Pipettes used in experiment

At the same time, the teensy was instructed to log the hydrophone input received
upon generating the bubbles. This data will then be processed and analysed in
accordance to the signal processing system elaborated upon later in this report.
The laboratory log associated with the above data acquisition can be found on the
next page.
Sl. Date Time Filename Sampling Recording Event Remarks
no. (in hrs) Interval Interval
1 12/06/2019 1040 DATALOG1. 60s 15s Multiple bubbles generated at a wind, keyboard noises present,
dat time, small bubble, 1 mL Mohr- bubble generation also causes
type borosil pipette disturbances
2 12/06/2019 1041 DATALOG2. 60s 15s Multiple bubbles generated at a wind, keyboard noises present,
dat time, small bubble, 1 mL Mohr- bubble generation also causes
type borosil pipette disturbances
3 12/06/2019 1042 DATALOG3. 60s 15s Multiple bubbles generated at a wind, keyboard noises present,
dat time, small bubble, 1 mL Mohr- bubble generation also causes
type borosil pipette disturbances
4 12/06/2019 1043 DATALOG4. 60s 15s Multiple bubbles generated at a wind, keyboard noises present,
dat time, medium sized bubble, bubble generation also causes
10mL Mohr-type borosil pipette disturbances
5 12/06/2019 1045 DATALOG5. 60s 15s Multiple bubbles generated at a wind, keyboard noises present,
dat time, medium sized bubble, bubble generation also causes
10mL Mohr-type borosil pipette disturbances
6 12/06/2019 1046 DATALOG6. 60s 15s Multiple bubbles generated at a wind, keyboard noises present,
dat time, medium sized bubble, bubble generation also causes
10mL Mohr-type borosil pipette disturbances
7 12/06/2019 1047 DATALOG7. 60s 15s Multiple bubbles generated at a wind, keyboard, phone ringing

Table 1: Laboratory Log


dat time, large bubble, 25 mL Mohr- noises present, bubble
type borosil pipette generation also causes
disturbances
8 12/06/2019 1048 DATALOG8. 60s 15s Multiple bubbles generated at a wind, keyboard noises present,
dat time, large bubble, 25 mL Mohr- bubble generation also causes
type borosil pipette disturbances
9 12/06/2019 1049 DATALOG9. 60s 15s Multiple bubbles generated at a wind, keyboard noises present,
dat time, large bubble, 25 mL Mohr- bubble generation also causes
type borosil pipette disturbances
WORK FLOW OF SIGNAL PROCESSING

Signal processing of the acquired signal is done through apps and functions
available in the signal processing toolbox of MATLAB software.

The work procedure is as follows:


1. Preprocessing the signal: Application of proper filters; Signal Enveloping
(using enveloping algorithms like HILBERT , RMS, PEAK algorithms);
Smoothing and Denoising; etc.
2. Exploration of signals: Plotting of the signal(volts/spl) in time domain;
plotting of spectrogram; plotting of periodogram; conversion into audible
(.wav) file.
3. Labelling the signals: finding Peak frequency, peak amplitude.
4. Further Analysis and Conclusion from the signal.

Fig 5: Signal Processing work flow


SPECTRAL REPRESENTATION OF SIGNALS
The spectral component-X(f) of the signal x(t) is represented by an integral of
complex exponentials. The integral is called the 'Fourier Transform'. Modulus
of X(f), |X(f)| is plotted as the spectrum of our signal. |X(f)^2| is the energy
distribution with respect to frequency domain. This is also called energy
spectral density.

Fig 6: Fourier Transform algorithm

Fourier Transform(FT) is applied on 'Continuous- infinite time extent' signals.


Applying FT gives us 'continuous frequency domain'.

Discrete Fourier Transform (DFT )-


For 'discrete-finite time signals', we use Discrete Fourier Transform(DFT)
method. Fourier Transforms involves integrals which is not possible to
undertake in all possible cases. So, we try to estimate the spectrum of a signal
by doing summation rather than integration. The DFT transforms N discrete-
time samples to N discrete frequency samples. DFT, hence, gives 'discrete
frequency domain'.
DFT is computed using fast Fourier transform (FFT) algorithms and is a
faster method. FFT decomposes N point DFT into successively smaller DFT's-
making the algorithm faster. They reduce the order of computation for direct
DFT- typically from order of (N^2) to the order of (NLog2(N)). It is possible
because N point DFT is broken into N/2 point DFT's and they are summed up.
In this, they exploit the property of complex exponentials, since they have
periodicity , and , they have complex conjugate symmetry.

Fig 7: Algorithm for FFT


(Here, we have discrete frequencies W(m)= 2*PI*m/M, where m=0,1,2...M-1.)
Also the estimation of spectrum is more accurate (near to fourier transform) if
we specify large number of frequency values (i.e large M). In MATLAB this is
specified by the parameter nfft (number of frequencies to be estimated).
Discrete Time Fourier Transform(DTFT)-
The sum of {x(n*Ts)*exp(-j*2pi*n*F*Ts} over n= all integers, is called the
Discrete Time Fourier Transform (DTFT) of the sequence{x(n*Ts)}. It is
denoted by X(f).
For 'Discrete- infinite time extent' signals, we use Discrete Time Fourier
Transform(DTFT). Applying DTFT gives us spectrum in 'continuous frequency
domain'.
Note: Nyquist criterion- As per this criterion, the spectral analysis is done, by
keeping the sampling frequency at least twice of that of the maximum frequency
present in the signal. Otherwise, the signal undergoes aliasing in the higher
frequency components.
PRE-PROCESSING

The aim of Preprocessing is to improve Signal To Noise Ratio (SNR).

Fig 8: Signal to Noise Ratio.


Signal are sound waves that carry information, which can be either manifested in
the amplitude(AM) , frequency(FM) or the phase function. In general, biological
sounds measured through hydrophones will have mixture of both FM and AM
types.
Noise is of two types: Interferences from signal sources which are not of our
interest. Also, They can be randomly varying amplitude, frequency or phase
functions. Or, many such sounds combine themselves in random manner to
present to us as a random sound. Spatially varying sound speed profiles; ocean
boundary interactions, etc. are also causes of noise.
.
Filter Designing And Implementation:
A filter is a system and it transforms the signal x(t) and gives y(t) as an output.
The output is defined by the following relation.

Fig 9 : Output signal after Filter.


(The above function has a component h(t), which is the filter's impulse response.)

Filter's Frequency response (also called as complex gain) is denoted by H(f). If


we have a signal x(t) , which has the fourier transform as X(f); then
Y(f)=X(f)*H(f). The methods and parameters of filter design are chosen as such
that it should be a stable filter-BIBO stable. The system is BIBO stable would
mean that for a bounded input , bounded output will be there.
There are 2 basic Design Methods: IIR(Infinite Impluse Response) and
FIR(Finite Impulse Response). IIR produces infinite term response towards a
impulse; whereas FIR produces only finite term. This is achieved through
feedback mechanism in the filter block designing. FIR further includes design
methods like ‘halfband filters’, ‘Nyquist filters’ etc. IIR on the other hand also
includes different design methods like ‘butterworth’, ‘elliptic’, ‘comb filters’ etc.
Response type of the filter can be adjusted with respect to our needs- Lowpass,
Bandpass, Bandstop, Highpass etc. The stopband attenuation magnitude and
passband ripple magnitude is also controlled. Filter order can be increased for
better noise reduction but it implies more computation time and power.

Signal Enveloping:
Absolute pressure value of the signal is taken before calculating the SNR. This
causes redundancy in detections of the same signal. We, hence, want to allow
only the detection with highest SNR values. Hence, amplitude function, or
envelope A(t) is calculated.
The absolute pressure value of the main signal has an oscillating part as well-
which is to be excluded. So, the envelope is calculated using the absolute value
of a time series, called an 'analytic signal'. In the analytic signal, we get rid of the
oscillating part by introducing a complex term.
In the process of assigning the signal to different biological species, we extract
different signals in time domain. In such an extraction, signal enveloping is the
first step. This is because the pressure envelope is never less than the absolute
pressure.
There are 3 methods of finding the signal envelope- Peak, RMS and Hilbert
Transforms.
RMS Transforms:
In, RMS we create a zero mean signal, by squaring our signal. We use a moving
time window. The selected length of the window will impact how "smoothed" the
signal becomes. Small window lengths will lead to rugged envelope. Large
window lengths smoothens the envelope.
Fig 10 : RMS Envelope
Hilbert Transforms:

It is hard to generate an analytic signal for long time series. Analytic signal can
be generated easily with a digital filter called Hilbert transforms. It is based on
the principle that for an analytic, complex valued time signal, the imaginary part
is 90 degrees phase shifted relative to the real part. The analytic time series,
hence constructed, has original time series as the real part and the Hilbert-
transformed time series as the imaginary part of the analytical time series.
Hilbert transforms differ from ideal filters because they have a finite impulse
response; the filter is a causal filter and we apply an additional window function
to improve the gain characteristics. Also, the causality of the filter delays the
filter response by half the window length.
Fig 11 : Hilbert Envelope
Peak Transforms:
This envelope detection method involves squaring the input signal and applying
lowpass filter to this signal. Squaring the signal demodulates the input. You
then downsample this signal to reduce the sampling frequency. After this, pass
the signal through a minimum-phase, lowpass filter to eliminate the high
frequency energy.
This envelope detection method is easy to implement and can be done with a
low-order filter, which minimizes the lag of the output.
Fig 12 : Peak Envelope
EXPLORATION OF SIGNAL

Spectrogram:
It is a way to represent the Short time fourier transform (STFT). Magnitude of
STFT {X(w,t)} gives Spectrogram.

Fig 13 : Expression of STFT


Here, w is the window function- which cuts the time domain signal into short
segment, so that STFT can be applied on the short snippet. ,P(t) is the signal in
time domain
Let x be signal of length N. The spectrogram of x with window size m is the
matrix X’ whose columns are the DFT of the columns of X.

Periodogram:
PSD is a method to visualise what effects our window functions have had on
our spectrum, while constructing the spectrogram. If we construct a power
spectral density we can visualise in terms of spikes observed. Better the window
function, the sharper the peak that we obtain. Short windows which are used to
construct spectrograms, can result in low frequency resolution and that can be
further viewed in PSD.
There are two main methods of power spectral density estimation: non-parametric
and parametric.
Non-parametric methods: They have less computational cost. These include
methods like: periodograms and correlograms. Periodograms direct methods
include the sample spectrum, Bartlett's method, Welch's method, and the Daniell
Periodogram. Correlograms use the concept called as Wiener-Khinchin theorem.
Parametric methods model the signal before its power spectral density estimate
is done. There are two types of parametric methods: autoregressive methods and
subspace methods.
• PSD using Welch's method: Welch's method works upon the periodogram
by addressing the lack of the ensemble averaging which is present in the
true PSD formula.
• PSD using periodogram: It is a special case of Welch's method with a
single segment, rectangular or triangular windowing, and no overlap. It's
computationally cheap.
ANNEXURE A
#include <SD.h>
#include <Bounce.h>
#include <SPI.h>
#include <TimeLib.h>

const int chipSelect = BUILTIN_SDCARD;


unsigned long time1=0,time2=0,time3=0,time4=0,time5=0,time6=0;
int micro=0;
int minu=0,sec=0,ho=0;
short int var=0;
byte high=0,low=0;
char
filename[10][16]={"datalog1.dat","datalog2.dat","datalog3.dat","datalog4.dat","
datalog5.dat","datalog6.dat","datalog7.dat","datalog8.dat","datalog9.dat","datal
og10.dat"};
int a=1,i=0;
byte* x;
byte* y;
int d=0;
int frequencyv=56000;

time_t getTeensy3Time()
{
return Teensy3Clock.get();
}

unsigned long processSyncMessage() {


unsigned long pctime = 0L;
const unsigned long DEFAULT_TIME = 1357041600; // Jan 1 2013
#define TIME_HEADER "T"
if(Serial.find(TIME_HEADER)) {
pctime = Serial.parseInt();
return pctime;
if( pctime < DEFAULT_TIME) { // check the value is a valid time (greater
than Jan 1 2013)
pctime = 0L; // return 0 to indicate that the time is not valid
}
}
return pctime;
}
time_t t;

void setup()
{
setSyncProvider(getTeensy3Time);
Serial.begin(115200);
while (!Serial) ;
if (timeStatus()!= timeSet) {
Serial.println("Unable to sync with the RTC");
} else {
Serial.println("RTC has set the system time");
}
if (Serial.available()) {
t=processSyncMessage();
if (t != 0) {
Teensy3Clock.set(t); // set the RTC
setTime(t);
}
}
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
return;
}
pinMode(33,INPUT);
sec=second();
minu=minute();
ho=hour();
x=&high;
y=&low;
}

void loop()
{
//Sampling frequency is 56kHz
File dataFile = SD.open(filename[a-1], FILE_WRITE);
time1=micros();
time4=micros();
if(a!=1)
{
micro=micro+time1-time3;
timeUpgrade();
}
writeTime();
Serial.print("Extra Time:");
Serial.println(time1-time3);
for(int i=1;i<=3360000;i++)
{
delayMicroseconds(1);
var=analogRead(33);
Serial.println(var);
high=highByte(var);
low=lowByte(var);
if ((dataFile)) {
dataFile.write(y,1);
dataFile.write(x,1);
}
else {
Serial.println("error opening datalogX.bin");
}
}
time2=micros();
time3=micros();
Serial.print("Time required to input and write the data:");
Serial.println(time2-time4);
micro=micro+time2-time4;
timeUpgrade();
writeTime();
dataFile.close();
a++;
delay(15000);
if(a>=11)
exit(1);
}

void timeUpgrade()
{
if(micro>=1000000)
{
sec=sec+(micro/1000000);
micro=micro%1000000;
}
if(sec>=60)
{
minu=minu+sec/60;
sec=sec%60;
}
if(minu>=60)
{
ho=ho+minu/60;
minu=minu%60;
}
}

void writeTime()
{
File timeFile = SD.open("timelog.txt", FILE_WRITE);
if(d%2==0)
{
timeFile.print("Run ");
timeFile.print(a);
}
timeFile.print(" ");
timeFile.print(day());
timeFile.print(" ");
timeFile.print(month());
timeFile.print(" ");
timeFile.print(year());
timeFile.print(" ");
timeFile.print(ho);
timeFile.print(":");
if(minu < 10)
{
timeFile.print('0');
timeFile.print(minu);
timeFile.print(":");
}
else
{
timeFile.print(minu);
timeFile.print(":");
}
if(sec< 10)
{
timeFile.print('0');
timeFile.print(sec);
}
else
{
timeFile.print(sec);
}
if(micro==0)
{
timeFile.print(":000000 ");
}
else if(micro<1000)
{
timeFile.print(":000");
timeFile.print(micro);
timeFile.print(" ");
}
else if(micro<10000)
{
timeFile.print(":00");
timeFile.print(micro);
timeFile.print(" ");
}
else if(micro<100000)
{
timeFile.print(":0");
timeFile.print(micro);
timeFile.print(" ");
}
else
{
timeFile.print(":");
timeFile.print(micro);
timeFile.print(" ");
}
if(d%2==1)
timeFile.println();
timeFile.close();
d++;
}
ANNEXURE B
#include<fstream>
#include<iostream>
#include<stdlib.h>
int main()
{
std::ifstream ifile;
std::ofstream ofile;
ifile.open("/Users/Prateek/Documents/nio/Bubble Data 3/Bubble Data 3
dat/DATALOG8.dat");
ofile.open("/Users/Prateek/Documents/nio/Bubble Data 3/Bubble data 3
txt/DATALOG8.txt");
int data=0,b=0;
int data1=0;
while(ifile)
{
if(b==0)
{
ifile.read((char*)&data,2);
b=1;
data1=data;
continue;
}
ofile<<data1<<','<<std::endl;
ifile.read((char*)&data,2);
std::cout<<data1<<'\n';
data1=data;
}
ifile.close();
ofile.close();
return 1;
}
REFERENCES
1. Zimmer, Walter M.X.(2011). Passive Acoustic Monitoring of Cetacean.
2.

You might also like