Updated LTSA code

My first blog post for conservationcoding.com was how to make a long term spectral average (LTSA) in PAMGuard. However, since then, the PAMGuard MATLAB library has been updated for the new version 2.0+. So, in a very short blog post, here’s the updated code.

To make this code work you need LTSA data collected in PAMGuard using the LTSA module. This can run in real time or port processing of wav files. If throwing data away, e.g. by saving only detection data during real time operation it’s very useful to have a LTSA- it doesn’t take up much memory space but provides some useful context of the overall soundscape. So for example, if you detect lots of porpoises but on manual inspection the clicks look a bit suspect, you can refer to the LTSA to see if an echosounder might have been present or perhaps there’s lots of broadband noise. I wrote in a previous post how to set up the PAMGuard LTSA module and here I’ve provided  some example data including the updated function.

The updated function is pretty simple to use and, if correct data acquisition card peak to peak voltage, hydrophone sensitivity and total gain is correctly input should provide a proper root hertz measurment of spectral density.

folder='E:\Google Drive\SMRU_research\Gill nets 2016\SoundTrap4c_wet_test_2\Binary1c\20170707';
channel=0; %use channel zero (these data are form one channel anyway)
plotLTSA=true; %true to autimaticall plot the LTSA
hsens=-171;%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=100000000; %time end
climits=[10,60]; %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';

The example script above plots a days data from a SoundTrap. The only variable that needs changing is folder which should point to wherever you’ve saved the example data or your own PAMGuard LTSA data.  If you use the example files you should see the LTSA below . Note some 200kHz echosounders are very obvious but other than that, in this example, there’s not a lot going on. If you play around with the colour limits e.g. caxis([20 35]) you’ll start to see a few other featuresLTSA_example

Ok, that’s it for now. Thanks for reading.

6 thoughts on “Updated LTSA code

  1. Hi,
    Thank you very much for sharing all this.
    I cannot find the function fftamplitude_2dB (line 146 of the load_LTSA_folder.m function)… I googled it and found that it is also a java method of PAMGuard… is there a link? If so, is there a wrapping matlab function missing in your example?
    Thank you very much in advance,
    Cheers,
    Chloe

    Like

  2. Hi I’m having a problem with running this line:

    %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);

    I get a error saying: Unrecognized function or variable ‘load_LTSA_folder’.
    but I have downloaded the matlab packages suggested…

    Like

  3. Hi Jamie,

    Thanks for the post. Unfortunatly, I too am struggling with error:

    Undefined function ‘fftamplitude_2dB’ for input arguments of type ‘double’.

    Error in load_LTSA_folder (line 146)
    ltsa_spectrumdB(:,i)=fftamplitude_2dB(ltsa_spectrum(:,i).^2,sR, fftllen, true, vp2p, hsens, gain);

    as mentioned in other comments.

    I have downloaded the folder PamguardMatlab_20200113 but can not find the fftamplitude_2dB function, is it elsewhere?

    any assistance appreciated, cheers,
    Matt

    Like

Leave a reply to Ali Cancel reply