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

  1. File Opening: Opens the input beam pattern file (-in) for reading and creates an output file (<input_file>.filt or specified by -out) for writing.
  2. Beam Pattern Loading:
    • If -rolling is 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 -rolling is active, it reads a ping_number and then 180 inten values (beam intensity). The diff and bcount arrays are not read in this mode.
      • Otherwise (for a single BP), it reads angle, inten, diff, and bcount for all 180 angle bins.
  3. Gap Filling (Linear Interpolation):
    • It identifies the begin and end of the “useable” part of the beam pattern (where inten[i] is not 0.0).
    • It then iterates from begin to end, searching for gaps (where inten[i] is 0.0).
    • When a gap is found:
      • It finds the gap_start (the last valid inten before the gap) and gap_end (the next valid inten after the gap).
      • It linearly interpolates the inten (and diff if not rolling) values for all bins within the gap based on the values at gap_start and gap_end.
  4. Output Writing: Writes the processed (gap-filled) beam pattern data to the output file.
    • If -rolling is active, it writes the ping_number and then the 180 inten values.
    • Otherwise, it writes angle, inten, diff, and bcount for all 180 bins.

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.