diff_MS_bp
Description
diff_MS_bp is a utility designed to compare two multi-sector beam pattern (MS_bp) files and output the difference between them. This tool is useful for analyzing changes in beam patterns over time, between different calibrations, or after applying various corrections.
It expects both input files to have an identical set of sectors (defined by parameters like sector_id, center_frequency, signal_length, waveform_id). It calculates the point-by-point difference in dB values for each angle bin.
Usage
diff_MS_bp -first <first_file> -second <second_file> -out <output_file> [-v]
Arguments
| Option | Description |
|---|---|
-first <first_file> | Required. Path to the first multi-sector beam pattern file. |
-second <second_file> | Required. Path to the second multi-sector beam pattern file. |
-out <output_file> | Required. Path for the output file which will contain the differences. |
-v | Enable verbose output. |
-Ref_dB_level <val> | (Present in USAGE but not implemented) This option likely suggests a reference dB level, but its functionality is not seen in the main function. |
How It Works
- Input Reading: Reads the two input multi-sector beam pattern files (
-firstand-second) usingload_MS_bp(an external function fromj_generic_beam_pattern.h). This function populatesFirst_BP/Second_BP(the actual beam pattern dB values) andFirst_Params/Second_Params(the TX sector parameters). - Sector Comparison:
- It first checks if both files have the same number of sectors. If not, it errors out.
- It then iterates through each sector, comparing their parameters (
sector_id,center_frequency,signal_length,signal_bandwidth). If these parameters don’t match, it issues a warning (“Apples ‘n Oranges DIFF BP”).
- Swath Flipping (Experimental/Heuristic): There’s an experimental section (
if(testflip)) that attempts to “flip” the order of swaths within the beam pattern data if thecenter_frequencyof the first sector is greater than that of the middle sector. This is a heuristic to ensure consistency if swath order might be inverted between files. - Difference Calculation: For each sector and each angle bin, it calculates the difference:
Diff_BP[i][k] = First_BP[i][k] - Second_BP[i][k]. If eitherFirst_BP[i][k]orSecond_BP[i][k]is zero, the difference is set to0. - Output: Writes the calculated differences (
Diff_BP) along with the sector parameters (First_Params) to the specified output file usingdump_MS_bp(an external function). The output file is a multi-sector beam pattern file, where the values represent the dB difference.
Output Files
<output_file>: A new multi-sector beam pattern file containing the dB differences.
Dependencies
j_generic_beam_pattern.h: ForMS_BPstructure andload_MS_bp,dump_MS_bpfunctions.support.h: For general utility functions and error handling.
Notes
This tool is valuable for quality control and detailed analysis of beam pattern stability and consistency. It helps to quantify the impact of environmental changes, system adjustments, or processing algorithms on the sonar’s angular response characteristics. The Ref_dB_level option is mentioned in the usage but not implemented, suggesting a future enhancement or a legacy feature.