diff --git a/quarto/tutorials/matlabrpython/ProcessingPGDFs.qmd b/quarto/tutorials/matlabrpython/ProcessingPGDFs.qmd index 01ead07..4bfbada 100644 --- a/quarto/tutorials/matlabrpython/ProcessingPGDFs.qmd +++ b/quarto/tutorials/matlabrpython/ProcessingPGDFs.qmd @@ -5,7 +5,7 @@ fileusage: notlisted ## Introduction -Various [modules in PAMGuard](https://www.pamguard.org/coremodules.html) produce [binary files](https://www.pamguard.org/olhelp/utilities/BinaryStore/docs/binarystore_overview.html). Custom libraries written in MATLAB, R and Python exist to help you further process these files. In this tutorial, we will process a folder of [Click Detector](https://www.pamguard.org/olhelp/detectors/clickDetectorHelp/docs/ClickDetector_clickDetector.html) binary files, count clicks per minute and create a concatenated string of porpoise detections. +Various [modules in PAMGuard](https://www.pamguard.org/coremodules.html) produce [binary files](https://www.pamguard.org/olhelp/utilities/BinaryStore/docs/binarystore_overview.html). Custom libraries written in MATLAB, R and Python exist to help you further process these files. In this tutorial, we will process a folder of [Click Detector](https://www.pamguard.org/olhelp/detectors/clickDetectorHelp/docs/ClickDetector_clickDetector.html) binary files, count clicks in a binary file, plot [Whistle and Moan Detector](https://www.pamguard.org/olhelp/detectors/whistleMoanHelp/docs/whistleMoan_Overview.html) contours and a [long term spectral average](https://www.pamguard.org/olhelp/sound_processing/LTSA/Docs/LTSA.html), demonstrating just a small fraction of what can done with these libraries. ::: callout-note ### Version @@ -468,27 +468,27 @@ The `data` variable produced by the code above will contain at least the followi +---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | R | Meaning | +===============+==============================================================================================================================================================================================================+ -| `millis` | The start time of the whistle in milliseconds. | +| `millis` | The start time of the whistle in milliseconds. | +---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| `startSample` | The first sample of the whistle often used for finer-scale time delay measurements. | +| `startSample` | The first sample of the whistle often used for finer-scale time delay measurements. | +---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| `uid` | A unique identifier for the whistle. | +| `uid` | A unique identifier for the whistle. | +---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| `channelMap` | The channel map for this whistle (one integer, made up of 32 bits, where each bit has a value 0 or 1 specifying the existence of that channel in the `contour`. | +| `channelMap` | The channel map for this whistle (one integer, made up of 32 bits, where each bit has a value 0 or 1 specifying the existence of that channel in the `contour`. | +---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| `nSlices` | The number of slices the whistle's `contour` is created from. | +| `nSlices` | The number of slices the whistle's `contour` is created from. | +---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| `amplitude` | The amplitude of the whistle. | +| `amplitude` | The amplitude of the whistle. | +---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| `minFreq` | The minimum frequency of the contour in Hz | +| `minFreq` | The minimum frequency of the contour in Hz | +---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| `maxFreq` | The maximum frequency of the contour in Hz | +| `maxFreq` | The maximum frequency of the contour in Hz | +---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| `sliceData` | An array of contour slices, with each slice `x` containing: \| \| - `sliceData[x]$sliceNumber`: book-keeping; \| \| - `sliceData[x]$nPeaks`: number of peaks; \| \| - `sliceData[x]$peakData`: peak data; \| | +| `sliceData` | An array of contour slices, with each slice `x` containing: \| \| - `sliceData[x]$sliceNumber`: book-keeping; \| \| - `sliceData[x]$nPeaks`: number of peaks; \| \| - `sliceData[x]$peakData`: peak data; \| | +---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| `contour` | An array of the same length as `sliceData` where each element `contour(x)` is the first frequency peak which defines the contour (`sliceData[x]$peakData[0][1]`). \| | +| `contour` | An array of the same length as `sliceData` where each element `contour(x)` is the first frequency peak which defines the contour (`sliceData[x]$peakData[0][1]`). \| | +---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| `contWidth` | An array of the same length as `sliceData` where each element `contWidth(x)` is the width of the first frequency peak in that contour slice (`sliceData(x)$peakData[0][2]-sliceData(x)$peakData[0][0]`). \| | +| `contWidth` | An array of the same length as `sliceData` where each element `contWidth(x)` is the width of the first frequency peak in that contour slice (`sliceData(x)$peakData[0][2]-sliceData(x)$peakData[0][0]`). \| | +---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ ## Python @@ -501,31 +501,31 @@ data = binaryFile.data The `data` variable produced by the code above will contain at least the following attributes. Please familiarise yourself with them, before continuing on to the next section. -+----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| Python | Meaning | -+==================================+=================================================================================================================================================================+ -| `millis` | The start time of the whistle in milliseconds. | -+----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| `start_sample` | The first sample of the whistle often used for finer-scale time delay measurements. | -+----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| `uid` | A unique identifier for the whistle. | -+----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| `channel_map` | The channel map for this whistle (one integer, made up of 32 bits, where each bit has a value 0 or 1 specifying the existence of that channel in the `contour`. | -+----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| `n_slices` | The number of slices the whistle's `contour` is created from. | -+----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| `amplitude` | The amplitude of the whistle. | -+----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| `slice_numbers` | An array of numbers: each element `slice_numbers[x]` containing a book-keeping number for a slice. | -+----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| `n_peaks` | A parallel array to `slice_numbers`, each element `n_peaks[x]` containing the number of peaks in that slice. | -+----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| `peak_data` | A parallel array to `slice_numbers`, each element `peak_data[x]` containing a sub-array of peak frequency-related data for that slice. | -+----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| `contour` | A parallel array to `slice_numbers`, each element `contour[x]` containing the peak frequency of that slice (`peak_data[x][1]`). | -+----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| `cont_width` | A parallel array to `slice_numbers`, each element `slice_numbers[x]` containing the frequency width of that slice (`peak_data[x][2] - peak_data[x][0]`). | -+----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ ++-----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| Python | Meaning | ++=================+=================================================================================================================================================================+ +| `millis` | The start time of the whistle in milliseconds. | ++-----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| `start_sample` | The first sample of the whistle often used for finer-scale time delay measurements. | ++-----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| `uid` | A unique identifier for the whistle. | ++-----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| `channel_map` | The channel map for this whistle (one integer, made up of 32 bits, where each bit has a value 0 or 1 specifying the existence of that channel in the `contour`. | ++-----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| `n_slices` | The number of slices the whistle's `contour` is created from. | ++-----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| `amplitude` | The amplitude of the whistle. | ++-----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| `slice_numbers` | An array of numbers: each element `slice_numbers[x]` containing a book-keeping number for a slice. | ++-----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| `n_peaks` | A parallel array to `slice_numbers`, each element `n_peaks[x]` containing the number of peaks in that slice. | ++-----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| `peak_data` | A parallel array to `slice_numbers`, each element `peak_data[x]` containing a sub-array of peak frequency-related data for that slice. | ++-----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| `contour` | A parallel array to `slice_numbers`, each element `contour[x]` containing the peak frequency of that slice (`peak_data[x][1]`). | ++-----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| `cont_width` | A parallel array to `slice_numbers`, each element `slice_numbers[x]` containing the frequency width of that slice (`peak_data[x][2] - peak_data[x][0]`). | ++-----------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ ::: ## Exercise 5: Plotting Whistle Contours