Using PAMGuard to track the movements of marine life around a tidal turbine

We at Coding for Conservation would like to let you know about a recent publication, authored by researchers from the Sea Mammal Research Unit, SMRU Consulting, and a couple of PAMGuard programmers. Our paper presents findings from the first in-situ passive acoustic monitoring array for marine mammals at an operational tidal turbine. This post demonstrates some of the analysis techniques we used with the PAMGuard/MATLAB library, specifically, providing some sample code for noise analysis. For a more detailed summary of the findings in this paper, check out the SMRU Consulting blog.

We were interested in tracking the fine-scale movements of marine animals in the vicinity of an operational tidal turbine. The marine renewables industry shows great potential in terms of green energy contributions, but since it’s still in its early days, we needed to be able to check out how marine life would behave around it. Would they avoid it? Could they detect it with enough time to get out of the way? Or would they collide with the blades? To answer these questions, we decided to record the sounds made by porpoises and dolphins on enough underwater microphones (hydrophones) so that we could localise and then reconstruct the 3D tracks of these animals.

We installed a passive acoustic monitoring (PAM) array, comprising 4 clusters of groups of 3 hydrophones, atop the base of the seabed-mounted turbine in Ramsey Sound, Wales. From one cluster, you could get a bearing to the animal, and when multiple clusters were ensonified, we could obtain multiple bearings to the animal; the location where these bearings from different clusters crossed would reveal the actual position of the animal.

These 12 hydrophones were all connected to a data acquisition system installed inside the turbine which in turn was connected to a PC back ashore via optical fibre. The PC on shore ran the PAMGuard software to process the data in real time. Some of the hydrophones were damaged during installations so we were collecting data from 7 hydrophones at a sample rate of 500 kHz, meaning we were collecting 3.5 million data points every second… for ~3 months. Had we saved all of the raw WAV files, would come to ~55 TB (!). Instead, we used PAMGuard to detect potentially interesting sounds in real time and saved only snippets of the raw full-bandwidth data when something interesting seemed to be happening.

The modules within PAMGuard that we used in our analyses included: 1) the click detector, 2) the whistle and moan detector, 3) the Large Aperture 3D Localiser module, to track the fine-scale movements of porpoises and dolphins on the array, and 4) the noise band analysis module. Here, we’ll focus on the noise band monitor.

1) Click detector

We configured PAMGuard to detect both porpoises and dolphins. Clicks from the 2 species were separated using the click detector classifier which examines both the click waveform and the frequency spectrum of detected clicks. For an example of how to use PAMGuard’s MATLAB library to extract information from detected clicks, check out our previous blog post and tutorial here.

2) Whistle & moan detector

We also included a whistle detector to pick up any whistling dolphins. Again, for an example of how to use PAMGuard’s MATLAB library to extract information from whistles and moans, check out our previous blog post and tutorial here.

3) Large Aperture 3D Localiser

This module uses a time-delay based ‘Mimplex’ algorithm in combination with an MCMC simulation to match the same echolocation click on different hydrophones and select the most likely position of where the sound came from (described in detail in our previous publication).

4) Noise Band Monitor

Whenever we’ve got PAM kit in the water, it’s important to measure noise levels in the recording environment. This helps us determine the probability of detecting an animal. For example, if the sound of an animal is only slightly louder than the background noise, then it can only be detected at very close ranges and thus the probability of detection is very low, making the PAM system an inefficient choice for monitoring. If you can’t quantify how far out you can detect a sound of interest, then you don’t have a handle of how effective your monitoring system is.

To set up the Noise Band Monitor: File > Add Module > Sound Processing > Noise Band Monitor. We made octave-band noise measurements in our analysis (you can modify this to 1/3 octave noise levels instead if you like). You can also select the number of decimators, controlling the lowest frequency. Then select the analysis window (“output interval”), over which you can record both the peak and mean noise levels. Values can be displayed as band energy (dB re 1 µPa) and/or spectrum level (dB re 1 µPa/√Hz). Select a filter for each band, and visualise your configuration in a Bode Plot within the module (Figure 1).


Figure 1. Bode plot showing noise band monitor settings.

You can visualise the noise band monitor in frequency vs. spectrum level plots and spectrum level vs. time plots, for each analysis window (Figure 2). Results are stored as binary files and the database. Display as many channels as you like.


Figure 2. Visualisation of noise band analysis in action. The screen refreshes each analysis interval and the results are saved.

The helpfiles for “Noise Band Measurement” and “Noise Band Displays and Output” provide handy guides. Next is an example piece of code demonstrating how to extract data from the binary files, and plot a time series of noise data.

Noise Band Monitor MATLAB Tutorial

This code uses the following functions:

  • 1) findBinaryFiles
  • 2) loadPamguardBinaryFile

These Matlab functions are in the most recent version of the PAMGuard-MATLAB library, and can be found freely here. Note that this code is backwards-compatible with previously collected binary files. For more details, see the PAMGuard website.

%% 1) Load data
folder = 'C:\FolderWithBinaryNoiseBandFiles\'; %wherever your noise files are
fileNames = findBinaryFiles(folder); %gets .pgdf files;
fileName = fileNames{1}; %identify file to load individually, or create a loop like in the previous example</code>

[dataSet, fileInfo] = loadPamguardBinaryFile(fileName);
% Here, you can see that this step loads in the Noise neatly for you, and
% organises it in a structure. Handy!

%% 2) Isolate channel of interest
chan2plot = dataSet(1).iChan; %default; change to whatever channel of interest, or add a loop to iterate through each channel
[~,idx] = find([dataSet.iChan] == chan2plot);
data = dataSet(idx);

%% 3) Make the noise band matrix, for ease of plotting
noise_mean = [];
noise_peak = [];
count = 0;
for rr=1:length(data)
noise_mean(count,1) = data(rr).date; %add a column for time
noise_peak(count,1) = data(rr).date; %add a column for time
for tt=1:data(rr).nBands; %iterate through each noise band
noise_mean(count,tt+1) = data(rr).noise(1,tt);
noise_peak(count,tt+1) = data(rr).noise(2,tt);
end %tt
end %rr
clear rr tt count

%% 4) Identify the low and high frequencies for each band
low = round([fileInfo.moduleHeader.loEdges]/1000,1); %Round to nearest 0.1 kHz for legend
high= round([fileInfo.moduleHeader.hiEdges]/1000,1);

%% 5) Plot the data
figure(1), clf
for qq=2:length(noise_mean(1,:)) %Loop through each noise band column
grid on; hold on;
datetick %Matlab function to show time in a non 7.36.... way
sample_interval = datestr(noise_mean(2,1)-noise_mean(1,1),'HH:MM:SS');
ylabel(['Noise Level (dB re 1 uPa) within sample interval: ' num2str(sample_interval)])
suptitle('Time Series of Noise Band Monitor')
title(['Only showing channel # ' num2str(chan2plot)])
legend(strcat(num2str(low), ' to ', num2str(high), ' kHz'))


This code will produce a figure like this from your binary noise band monitor files:


Figure 3. Demonstration of the output from the above code, showing a time-series of your noise band monitor results.

So what now? Using time, you can align your noise time series to any other relevant time series. Perhaps this is tidal flow speed, or some other environmental covariate. Check out how your noises changes according to these, etc. Investigate whether noise levels in your click detector bands fluctuate, and then consider how much this will impact your detection probability.

For questions with analysis, don’t hesitate to get in touch.

For further details, check out our publication here:

Malinka CE, Gillespie DM, Macaulay JDJ, Joy R, & CE Sparling (2018). First in-situ passive acoustic monitoring for marine mammals during operation of a tidal turbine in Ramsey Sound, WalesMarine Ecology Progress Series 590:247-266. (DOI:

Guest blog post by Chloe Malinka


(Featured photo of DeltaStream turbine from

One thought on “Using PAMGuard to track the movements of marine life around a tidal turbine

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s