smthBP
Description
smthBP is a utility designed to smooth the beam pattern output generated by getBeamPattern (or newGetBP). It applies a weighted moving average filter to the intensity and difference values of the beam pattern, helping to reduce noise and reveal underlying trends.
The smoothing is weighted by the bcount (number of samples in each bin), giving more influence to bins with more data.
Usage
smthBP -in <infile> -out <outfile> [-halfwidth <value>] [-v]
Arguments
| Option | Description | |
|---|---|---|
-in <infile> | Required. The path to the input beam pattern file (typically an ASCII file generated by getBeamPattern or newGetBP). | |
-out <outfile> | Required. The path for the smoothed output beam pattern file. | |
-halfwidth <value> | Specifies the half-width of the smoothing window. A halfwidth of 1 means a 3-point window, 2 means a 5-point window, etc. | 1 |
-v | Enable verbose output. |
How It Works
- Input Reading: Opens the input beam pattern file and reads its contents. The file is expected to have four columns: angle, intensity (
inten), difference (diff), and beam count (bcount) for 180 angle bins. - Midsignal Calculation: It calculates a
midsigvalue, which is a weighted average ofinten(intensity) from a specific range of angle bins (typically25-65and115-155), weighted by theirbcount. Thismidsigserves as a reference point for normalization. - Weighted Smoothing:
- It allocates memory for
smthinten,smthdiff, andsmthbcountarrays. - For each angle bin
jin the rangehalfwidthto180 - halfwidth - 1:- It calculates a weighted sum of
intenvalues within the smoothing window (j - halfwidthtoj + halfwidth), usingbcountas weights. - The smoothed intensity (
smthinten[j]) is the weighted average. - The smoothed difference (
smthdiff[j]) is calculated asmidsig - smthinten[j]. - The smoothed beam count (
smthbcount[j]) is the sum ofbcountvalues within the window.
- It calculates a weighted sum of
- Bins outside this range (at the edges) are not smoothed and are typically left as
0.0.
- It allocates memory for
- Output Writing: Writes the smoothed beam pattern data (angle,
smthinten,smthdiff,smthbcount) to the specified output file in a format similar to the input.
Output Files
<outfile>: A new ASCII file containing the smoothed beam pattern.
Dependencies
support.h: For general utility functions and error handling.
Notes
Smoothing beam patterns helps to reduce noise and reveal the underlying average response. The weighted averaging ensures that angular bins with more data contribute more reliably to the smoothed result. This tool is often used as a post-processing step before applying beam pattern corrections to backscatter data.