plotSwath

Description

plotSwath is an interactive plotting utility designed to visualize multibeam sonar data in terms of across-track offset and depth, typically from output generated by SwathEditor. It allows users to plot either individual beams across all swaths or individual swaths across all beams, providing a cross-sectional view of the bathymetry or a comparison of beam responses.

The tool is interactive, prompting the user for plotting choices, Y-axis ranges, and allows for displaying all data or only data that is within a certain range.

Usage

plotSwath -infile <file1> [-outfile <filename.meta>] [-size <dx> <dy>] [-width <val>] [-showspikes] [-showall]

Arguments

Option Description  
-infile <file1> Required. Specifies an input ASCII file containing swath data from SwathEditor.  
-outfile <filename.meta> Specifies the output PostScript metafile name. plot.meta
-size <dx> <dy> Specifies the plot size in centimeters. 15.0 22.0
-width <val> Sets the total across-track width for plotting.  
-showspikes Displays data points that might be considered “spikes” (i.e., outside the normal range).  
-showall Displays all data points, regardless of validity.  
-sparse (Present in USAGE, but implementation not fully shown for plotting) Intended for sparse plotting.  

Input File Format (ASCII from SwathEditor)

The input ASCII file is expected to contain:

  • xmin xmax (float, float): Initial X-axis range (across-track offset).
  • ymin ymax (float, float): Initial Y-axis range (depth).
  • no_swaths (int): Number of swaths.
  • no_beams (int): Number of beams per swath.
  • Then, for each swath i and each beam j: offset[j][i] depth[j][i] (float, float).

Interactive Mode

After launching, plotSwath will guide the user through a series of prompts:

  1. Number of Plots (noplots): Prompts for how many vertical subplots to create.
  2. Y-axis Bounds (per plot): For each subplot, it prompts for Y-axis minimum (ymin[i]) and maximum (ymax[i]) values.
  3. Plotting Mode: Asks whether to plot individual beams (-1) or individual swaths (1).
  4. Selection (per line): If plotting beams, asks “what SWATH # (0-no_swaths-1) do you want to plot?”. If plotting swaths, asks “what BEAM # (0-no_beams-1) do you want to plot?”.
  5. Continue Plotting (multiple lines per subplot): After plotting one line in a subplot, it asks if the user wants to plot another line in the same subplot.

How It Works

  1. Initialization: Parses command-line arguments to set plotting options, input file names, plot size, and showspikes/showall flags.
  2. Plot Setup: Initializes the plotlib PostScript output (plot.meta). Sets up the overall plot dimensions (xlength, ylength, xoff).
  3. Data Loading:
    • Opens the input ASCII file (-infile).
    • Reads xmin, xmax, ymin, ymax (initial ranges from file).
    • Reads no_swaths and no_beams.
    • Reads all offset[j][i] and depth[j][i] values into 2D arrays.
  4. Plotting Loop (per subplot):
    • Divides the plotting area into noplots vertical subplots.
    • For each subplot:
      • Draws the subplot border.
      • Draws X-axis grid lines and labels.
      • Prompts for Y-axis range (ymin[i], ymax[i]).
      • Prompts for plotting mode (beam_swath).
      • Data Plotting:
        • Prompts the user to select a specific swath or beam.
        • Iterates through nopoints (beams or swaths depending on mode):
          • Sets xval (across-track offset) and yval (depth) based on the chosen swath/beam.
          • If showall is set, it plots all data. If not, it plots only data within the specified Y-range.
          • Plots data as a line segment.
      • Adds text label for the selected swath/beam.
  5. Cleanup: Closes all open files and plotlib output.

Output Files

  • <outfile.meta>: A PostScript metafile (.meta) containing cross-sectional views or comparisons of multibeam swath data.

Dependencies

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

Notes

plotSwath is a powerful interactive tool for visualizing and analyzing multibeam data in cross-section. It’s particularly useful for quality control, identifying systematic errors (e.g., roll bias, sound speed errors), and understanding the shape of the seafloor across the swath. The interactive selection of plotting modes (by beam or by swath) provides flexibility for different analytical needs. The -sparse option is listed but not implemented.