<p>In the PAMGuard Matlab library at <a href="https://github.com/PAMGuard/PAMGuardMatlab" rel="nofollow noreferrer">https://github.com/PAMGuard/PAMGuardMatlab</a> there is a function LoadPamguardBinaryFolder which will load all data from a folder with sub folders. This will save you looping through individual files. See Matlab help for how to set axis values on a colour plot.</p>

CC BY-SA 4.0
2022-08-16T09:09:43.617Z
2022-08-16T09:09:43.617Z
Doug Gillespie
<p>I am trying to produce an LTSA of a 3 week period of data from 2018 and the same period in 2020. My 2018 data was collected using a SoundTrap on a 10 min on/10 min off duty cycle. I have processed the files in PAMGuard to create LTSA binary files and found the below code from the very helpful <a href="https://conservationcoding.com/2018/03/04/updated-ltsa-code/" rel="noreferrer">Conservation Coding blog</a>.</p>
<pre><code>folder='D:\PAMGUARD\PAMBinary\Depl953\20180626';
channel=0; %use channel zero (these data are form one channel anyway)
plotLTSA=true; %true to autimaticall plot the LTSA
hsens=-172.3;%hydrophone sensitivity in dB re 1V/uPa
vp2p=2; %peak to peak voltage in dB
gain=0; %gain in dB
day_num_start=0; %time start
day_num_end=200000000; %time end
climits=[40,120]; %colour limits in dB root Hertz
 
%load and plot LTSA data
[ltsa_spectrum, ltsa_time, interval, ltsa_spectrumdB] = load_LTSA_folder(...
    folder, channel, day_num_start, day_num_end, plotLTSA, hsens, vp2p, gain, climits); 
 
%make a colour bar showing the spectral density
colormap jet;
ax = gca;
c=colorbar;
c.Label.FontSize = 12;
c.Label.Interpreter='tex';
c.Label.String = 'dB re 1\muPa \surdHz';
</code></pre>
<p>This plots the following LTSA:</p>
<p><a href="https://i.sstatic.net/ZENVF.jpg" rel="noreferrer"><img src="https://i.sstatic.net/ZENVF.jpg" alt="enter image description here" /></a></p>
<p>My questions are:</p>
<ol>
<li>PAMGuard binary files are organised in folders by day. Is there a simple way to load more than one folder at a time so I can plot 3 weeks on one LTSA or do I need to loop through each folder?</li>
<li>How can I make my x-axis dates/times as opposed to time in minutes?</li>
<li>This may resolve itself after addressing (2), but, how can I include the duty cycle in the LTSA aka have 'blank' where there was no data? I want this because I want to plot the same 3-week period from 2018 and 2020 in a multiplot figure to allow qualitative comparison of course-scale noise variability within and between years.</li>
</ol>
<p>Thanks!</p>

CC BY-SA 4.0
2022-08-04T17:06:52.820Z
Hi Laura, do you have access to matlab by chance?
Cory Hom-Weaver
<pamguard><ltsa>
Date ticked LTSA using PAMGuard binaries from duty cycled soundtrap data
# Date ticked LTSA using PAMGuard binaries from duty cycled soundtrap data

(Asked by: username_0 on 2022-08-04)

I am trying to produce an LTSA of a 3 week period of data from 2018 and the same period in 2020. My 2018 data was collected using a SoundTrap on a 10 min on/10 min off duty cycle. I have processed the files in PAMGuard to create LTSA binary files and found the below code from the very helpful [Conservation Coding blog](https://conservationcoding.com/2018/03/04/updated-ltsa-code/).

```
folder='D:\PAMGUARD\PAMBinary\Depl953\20180626';
channel=0; %use channel zero (these data are form one channel anyway)
plotLTSA=true; %true to autimaticall plot the LTSA
hsens=-172.3;%hydrophone sensitivity in dB re 1V/uPa
vp2p=2; %peak to peak voltage in dB
gain=0; %gain in dB
day_num_start=0; %time start
day_num_end=200000000; %time end
climits=[40,120]; %colour limits in dB root Hertz
 
%load and plot LTSA data
[ltsa_spectrum, ltsa_time, interval, ltsa_spectrumdB] = load_LTSA_folder(...
    folder, channel, day_num_start, day_num_end, plotLTSA, hsens, vp2p, gain, climits); 
 
%make a colour bar showing the spectral density
colormap jet;
ax = gca;
c=colorbar;
c.Label.FontSize = 12;
c.Label.Interpreter='tex';
c.Label.String = 'dB re 1\muPa \surdHz';

```

This plots the following LTSA:

[![enter image description here](https://i.sstatic.net/ZENVF.jpg)](https://i.sstatic.net/ZENVF.jpg)

My questions are:

1. PAMGuard binary files are organised in folders by day. Is there a simple way to load more than one folder at a time so I can plot 3 weeks on one LTSA or do I need to loop through each folder?
2. How can I make my x-axis dates/times as opposed to time in minutes?
3. This may resolve itself after addressing (2), but, how can I include the duty cycle in the LTSA aka have 'blank' where there was no data? I want this because I want to plot the same 3-week period from 2018 and 2020 in a multiplot figure to allow qualitative comparison of course-scale noise variability within and between years.

Thanks!

**Tags:** pamguard, ltsa

> **Comments:**
> **username_1**: Hi username_0, do you have access to matlab by chance?  

---

## 1 answers

### Answer by username_2 on 2022-08-16. Score: 3

In the PAMGuard Matlab library at <https://github.com/PAMGuard/PAMGuardMatlab> there is a function LoadPamguardBinaryFolder which will load all data from a folder with sub folders. This will save you looping through individual files. See Matlab help for how to set axis values on a colour plot.


---

