stackOMG
Description
stackOMG is a utility designed to stack and average beam data (depth and across-track offset) from multiple records (pings) within one or more OMG-HDCS merged files. It computes a weighted average of observedDepth and acrossTrack for each beam number, providing a consolidated view of the seafloor profile.
The tool can process a specific range of pings or iterate through entire files. It can also perform a least-squares fit on the averaged data to determine a best-fit slope and intercept.
Usage
stackOMG <OMG_HDCS_datafile(s)> [-mode <value>] [-verbose] [-list]
Arguments
| Option | Description | |
|---|---|---|
<OMG_HDCS_datafile(s)> | Required. One or more paths to input OMG-HDCS merged files. If no files are provided on the command line, it prompts for them interactively. | |
-mode <value> | Only process pings that match this specific profile.mode value. | 999 (process all modes) |
-verbose | Enable verbose output. | |
-list | Instead of generating a stack.plot file, it outputs an ASCII listing of averaged depths and offsets to the console or a file (not explicitly specified but implied by list_flag). |
Interactive Mode (if no files specified on command line)
If no filenames are provided on the command line, the tool will:
- Prompt for an input OMG file name.
- Prompt for
firstandlastrecord numbers (pings) to stack. - After processing, ask “another file?”, allowing for iterative stacking from multiple sources.
How It Works
- Initialization: Initializes arrays to store the sum of depths (
depth), sum of across-track offsets (offset), and count (count) for each beam number (up toMAX_BEAMS_TO_STACK). - File and Ping Iteration:
- It iterates through each specified merged file (either from the command line or interactively).
- For each file, it reads the summary header.
- It then iterates through a specified range of pings (either
firsttolastif provided, or0tosummary.numProfilesby default). - For each ping, it reads the profile header and raw beams.
- Mode Filtering: If
-modeis specified, it only processes pings whoseprofile.modematches themode_choice. - Accumulation: For each valid beam (status
0andobservedDepthpresent), it accumulates:depth[j] += (float) beam[j].observedDepth / 1000.0offset[j] += (float) beam[j].acrossTrack / 1000.0count[j]++
- Averaging: After processing all selected pings from all files:
- For each beam
j, ifcount[j]is non-zero, it calculates the average depth and across-track offset by dividing the accumulated sums bycount[j].
- For each beam
- Least-Squares Fit: Performs a linear least-squares regression (
do_least_squares) on the averagedoffset(X) anddepth(Y) data to find anintercept,slope, andfitvalue. This is useful for determining the average slope of the seafloor in the stacked profile. - Output:
- If
-listis used, it prints the averaged depths and offsets for each beam to the console. - Otherwise, it creates an output file named
stack.plotand writes various diagnostic information, including:- Hardcoded parameters (e.g.,
15.0 20.0,5). - A depth range derived from
depth[15]. - For each beam, its averaged
offset,depth, andcount. - The results of the least-squares fit (
intercept,slope,fit). leveldepth(detrended depths based on the least-squares slope) andleveldepth - depth(residuals).
- Hardcoded parameters (e.g.,
- If
Output Files
stack.plot: An ASCII file containing averaged beam data and least-squares fit results.- Console output if
-listis used.
Dependencies
OMG_HDCS_jversion.h: For OMG-HDCS data structures.support.h: For general utility functions and error handling.
Notes
stackOMG is useful for generating an average cross-section of the seafloor from multiple pings, which can help to smooth out noise and reveal underlying bathymetric trends. The least-squares fit provides a simple model of the averaged seafloor slope. The interactive mode allows for flexible selection of input files and ping ranges. The tool creates a new file, ensuring the integrity of the original.