stackBP
Description
stackBP is a utility designed to combine multiple ASCII beam pattern (BP) files, typically generated by getBeamPattern or newGetBP, into a single, weighted average beam pattern. This is useful for creating a more robust and representative beam pattern by averaging over multiple acquisitions or different data lines.
The averaging is weighted by the bcount (number of samples) in each bin, ensuring that bins with more data contribute more to the final average.
Usage
stackBP <beampatt_file(s)> [-verbose]
Arguments
| Option | Description | |
|---|---|---|
<beampatt_file(s)> | Required. One or more paths to input ASCII beam pattern files. These files are typically named beampatt or similar and contain angle, intensity, difference, and count for each bin. | |
-verbose | Enable verbose output. |
How It Works
- Initialization: The tool initializes arrays to store the summed intensity (
Inten), difference (theDiff), and total count (Bcount) for each of the 180 angle bins. - File Iteration: It iterates through each provided input beam pattern file:
- For each file, it reads the four columns of data (angle, intensity, difference, beam count) for each of the 180 bins.
- It accumulates
Inten[j]by addingintensity[j] * bcount[j](weighted sum). - It accumulates
Bcount[j]by addingbcount[j]. - It also keeps track of
totintenandtotcountfor a global average.
- Weighted Averaging: After processing all input files:
- For each angle bin
j, ifBcount[j]is non-zero, it calculates the weighted average intensity by dividingInten[j]byBcount[j]. - It also calculates a global
totinten(weighted average intensity across all bins and all files).
- For each angle bin
- Output Writing:
- An output file named
beampatt.stackis created. - For each angle bin
j, it writes four values to the output file:- Angle (
(float) j) - Weighted average intensity (
Inten[j]) - Difference from the global average (
totinten - Inten[j]) - Total count for that bin (
Bcount[j])
- Angle (
- If
Bcount[j]is zero (meaning no data for that bin), the intensity and difference are written as0.0.
- An output file named
Output Files
beampatt.stack: An ASCII file containing the stacked and averaged beam pattern.
Dependencies
support.h: For general utility functions.
Notes
Stacking multiple beam patterns helps to reduce noise and provide a more statistically robust representation of the sonar’s angular response. The weighted averaging ensures that data with higher confidence (more samples) contributes more to the final result. The output format is compatible with plotBP for visualization.