filterBP
Description
filterBP is a utility designed to process and filter beam pattern (BP) files, typically generated by getBeamPattern or newGetBP. Its primary function is to fill gaps in the beam pattern data using linear interpolation.
This tool is useful for creating continuous beam patterns for further analysis or application, especially when the original data might have sparse coverage in certain angular bins.
Usage
filterBP -in <file.bp> [-out <file.bp.filt>] [-rolling] [-posTol <val>] [-negTol <val>] [-v]
Arguments
| Option | Description | |
|---|---|---|
-in <file.bp> | Required. The path to the input beam pattern file (ASCII format). | |
-out <file.bp.filt> | The path for the output filtered beam pattern file. Default is <input_file>.filt. | |
-rolling | Indicates that the input file contains multiple “rolling” beam patterns (each with a ping number). | |
-posTol <val> | (Present in USAGE but not implemented) These options likely intend to define positive tolerance thresholds, but their functionality is not seen in the main function. | |
-negTol <val> | (Present in USAGE but not implemented) These options likely intend to define negative tolerance thresholds, but their functionality is not seen in the main function. | |
-v | Enable verbose output. |
How It Works
- File Opening: Opens the input beam pattern file (
-in) for reading and creates an output file (<input_file>.filtor specified by-out) for writing. - Beam Pattern Loading:
- If
-rollingis specified, it first reads the total number of beam patterns (num_beam_patterns) from the input file. - It then iterates through each beam pattern (
bp_count):- If
-rollingis active, it reads aping_numberand then 180intenvalues (beam intensity). Thediffandbcountarrays are not read in this mode. - Otherwise (for a single BP), it reads
angle,inten,diff, andbcountfor all 180 angle bins.
- If
- If
- Gap Filling (Linear Interpolation):
- It identifies the
beginandendof the “useable” part of the beam pattern (whereinten[i]is not0.0). - It then iterates from
begintoend, searching for gaps (whereinten[i]is0.0). - When a gap is found:
- It finds the
gap_start(the last validintenbefore the gap) andgap_end(the next validintenafter the gap). - It linearly interpolates the
inten(anddiffif notrolling) values for all bins within the gap based on the values atgap_startandgap_end.
- It finds the
- It identifies the
- Output Writing: Writes the processed (gap-filled) beam pattern data to the output file.
- If
-rollingis active, it writes theping_numberand then the 180intenvalues. - Otherwise, it writes
angle,inten,diff, andbcountfor all 180 bins.
- If
Output Files
<file.bp.filt>: The output filtered beam pattern file (ASCII format).
Dependencies
support.h: For general utility functions and error handling.
Notes
Beam patterns generated from real data often contain gaps due to sparse data coverage in certain angular bins. This tool helps to smooth out and interpolate these gaps, creating a more continuous and usable beam pattern for further processing, such as applying corrections to backscatter data. The posTol and negTol options are listed in the usage but not implemented in the current code.