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
iand each beamj:offset[j][i] depth[j][i](float, float).
Interactive Mode
After launching, plotSwath will guide the user through a series of prompts:
- Number of Plots (
noplots): Prompts for how many vertical subplots to create. - Y-axis Bounds (per plot): For each subplot, it prompts for Y-axis minimum (
ymin[i]) and maximum (ymax[i]) values. - Plotting Mode: Asks whether to plot individual beams (
-1) or individual swaths (1). - 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?”. - 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
- Initialization: Parses command-line arguments to set plotting options, input file names, plot size, and
showspikes/showallflags. - Plot Setup: Initializes the
plotlibPostScript output (plot.meta). Sets up the overall plot dimensions (xlength,ylength,xoff). - Data Loading:
- Opens the input ASCII file (
-infile). - Reads
xmin,xmax,ymin,ymax(initial ranges from file). - Reads
no_swathsandno_beams. - Reads all
offset[j][i]anddepth[j][i]values into 2D arrays.
- Opens the input ASCII file (
- Plotting Loop (per subplot):
- Divides the plotting area into
noplotsvertical 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) andyval(depth) based on the chosen swath/beam. - If
showallis set, it plots all data. If not, it plots only data within the specified Y-range. - Plots data as a line segment.
- Sets
- Adds text label for the selected swath/beam.
- Divides the plotting area into
- Cleanup: Closes all open files and
plotliboutput.
Output Files
<outfile.meta>: A PostScript metafile (.meta) containing cross-sectional views or comparisons of multibeam swath data.
Dependencies
plotlib.h: Forplotlibfunctions.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.