BDplot

Description

BDplot is a specialized plotting utility designed to process and visualize Bottom Detection (BD) data from multibeam sonars, particularly focusing on the raw amplitude and phase time series. It performs advanced signal processing, including Rayleigh distribution modeling, noise filtering, and least-squares fitting, to identify the optimal bottom pick (detection) and associated phase/amplitude characteristics.

The tool can generate various plots to aid in understanding bottom detection performance, phase residuals, and noise levels. It processes raw intensity/phase time series extracted from a binary file (likely generated by another tool).

Usage

BDplot <infile> [-outfile <metafile_name>] [OPTIONS]

Arguments

Option Description Default / Example
-infile <file1> Required. Specifies an input file containing processed data (likely generated by getAngularResponse or a similar tool), usually a binary file with amplitude and phase time series. ek60_data.bd
-outfile <metafile_name> Specifies the output PostScript metafile name. plot.meta

Plotting Mode (Choose one)

| Option | Description | |—|—| | -swath | Plot by swath. | | -beam | Plot by beam. | | -onebeam | Plot a single beam. | | -bdplot | (Default) Plot time series. |

Data to Show (Choose one)

| Option | Description | |—|—| | -inten | Show intensity (amplitude). | | -phase | Show phase. | | -phaseresid | Show phase residuals. | | -smthphase | Show smoothed phase. | | -smthinten | Show smoothed intensity. |

Data Processing

| Option | Description | |—|—| | -doall | Perform all BD (bottom detection) calculations and dump results to ASCII files (ampli.detects, phase.detects). | | -recalc | Recalculate Noise/Rayleigh data. | | -noise / -nonoise | Show or hide noise. | | -noiselevel <dB> | Set the noise level threshold. | -30 | | -rayleigh / -norayleigh | Apply or ignore Rayleigh distribution for noise modeling. | | -invalid <val> | Set a value to consider as invalid data. | 0.0 | | -tight_phase | Apply tighter phase processing criteria. | | -sequence | Process data by sequence. | | -showall_ampl | Show all amplitudes. | | -recalc_all | Recalculate all parameters (amplitude, phase). |

Plot Customization

| Option | Description | |—|—| | -xrange <min> <max> / -intrange <min> <max> | Set X-axis (time) range and intensity range for Y-axis. | | | -tit1 <string> / -tit2 <string> | Set main and secondary titles. | | | -xlab <string> / -ylab <string> | Set X and Y axis labels. | |

Debugging

| Option | Description | |—|—| | -v | Enable verbose output. | |

How It Works

  1. Initialization: Parses command-line arguments to set plotting options, file names, and processing parameters. Initializes arrays for storing time series data, phase information, and Bottom Detection results.
  2. Rayleigh LUT Building: If show_rayleigh is active, buildRayleighLUT() is called to create a lookup table for Rayleigh noise distribution.
  3. Data Loading (load_info):
    • Reads metadata from the input file header (e.g., shotno, nobeams, roll, pitch, nominal_depth).
    • Reads beam pattern information (BP) and other parameters into global arrays.
  4. Raw Data Recalculation (recalc_NR):
    • If recalc_all is set, recalc_NR() is called. This function reconstructs time series data (Time_Series, Phase_Series) from raw input and applies Rayleigh noise (addRayleigh()) and general noise (apply_noise()).
    • removeTVG() is called to remove Time-Varying Gain.
  5. Bottom Detection (do_BD):
    • Performs amplitude detection: Calculates a running average of intensity and identifies the maximum amplitude to estimate a cenloc. It refines this cenloc using a center-of-mass approach, accounting for noise level.
    • Performs phase detection: Calculates phase coherence by fitting a least-squares line to the phase residuals. It identifies a cenloc for phase detection, potentially refining it iteratively (tighten_up_phase).
    • The results (BD depth, across-track, etc.) are stored in AmpBDT and PhsBDT arrays.
  6. Plot Generation (using plotlib library):
    • Initializes the PostScript output (plot_open).
    • Based on plot_mode, it structures the plots (e.g., multiple plots for each beam in a swath).
    • Draws axes and labels if specified.
    • Plots the selected time series data (intensity, phase, residuals) using lines and points, with colors and styles controlled by options.
  7. doalldetects mode: If doalldetects is active, it skips the plotting and instead iterates through all swaths and beams, performs bottom detection, and dumps the amplitude and phase BD results to ASCII files (ampli.detects, phase.detects).
  8. Cleanup: Calls plot_close to finalize PostScript output and closes input files.

Output Files

  • <outfile_name>: A PostScript metafile (.meta) containing the generated plot(s).
  • ampli.detects: An ASCII file with amplitude bottom detection results (if -doall is used).
  • phase.detects: An ASCII file with phase bottom detection results (if -doall is used).

Dependencies

  • plotlib.h: For plotlib functions.
  • support.h: For general utility functions.
  • math.h: For mathematical functions.

Notes

BDplot is a powerful diagnostic tool for assessing the performance of bottom detection algorithms in multibeam sonars. It allows engineers and scientists to visualize the raw acoustic data and the results of various picking and filtering processes, helping to optimize system settings and improve data quality. The interactive controls and various plotting modes provide flexibility for detailed analysis.