getRollResidual
Description
getRollResidual is a utility designed to estimate and output the residual roll error (or, more generally, the across-track slope) present in multibeam sonar data. It does this by calculating the across-track slope of the seafloor for each ping using a least-squares fit to the observed depths and across-track positions of the beams. It then applies a moving average filter to these slopes to identify the long-term trend, and outputs both the raw slope and the filtered slope.
This tool is useful for identifying and quantifying residual roll biases in the data, which may be due to uncorrected vessel motion or misalignment.
Usage
getRollResidual <filename.merged> [-testonly]
Arguments
| Option | Description |
|---|---|
<filename.merged> | Required. The path to the input OMG-HDCS merged file. |
-testonly | (Present in USAGE but not implemented) This option likely suggests a test mode, but its functionality is not seen in main. |
How It Works
- File Opening: Opens the input merged file for reading (
r+). - Summary Header Reading: Reads the summary header to determine
summary.numProfiles. - Memory Allocation: Allocates memory for arrays to store
across_track_slope(raw slope per ping) andslope_fit(filtered slope). - Profile Iteration (Calculate Raw Slopes): Loops through each profile (ping) in the merged file:
- Reads the current profile header and raw beams.
- Extracts valid
observedDepthandacrossTrackvalues intoyvalsandxvalsarrays, respectively. - Least-Squares Fit: Performs a linear least-squares regression (
do_least_squares) onxvalsvs.yvalsto calculateintercept,slope, andfitfor the current ping. - Stores the calculated
slope(converted to degrees) inacross_track_slope[i]. - Calculates a
slope_fit[i]based on thefitandintercept(a measure of how well the data fits the slope). Ifinterceptis zero,slope_fit[i]is set to999.0.
- Profile Iteration (Calculate Filtered Slopes and Output): Loops through each profile again (or prints directly in the same loop if
filter_lengthlogic is applied toacross_track_slope):- For pings that are not near the edges of the file (to ensure a full
filter_lengthwindow):- Calculates a
filtered_slopeby averagingacross_track_slopevalues within a moving window offilter_length(hardcoded to40) pings.
- Calculates a
- Outputs the ping number, the raw
across_track_slope[i], and thefiltered_slopeto standard output.
- For pings that are not near the edges of the file (to ensure a full
Output Files
The tool prints a three-column ASCII listing to standard output:
- Ping number
- Raw across-track slope (in degrees) for that ping
- Filtered across-track slope (in degrees) for that ping
Dependencies
OMG_HDCS_jversion.h: For OMG-HDCS data structures.support.h: For general utility functions and error handling.
Notes
Residual roll errors can introduce significant artifacts in multibeam data if not properly corrected. This tool helps to quantify these errors by analyzing the apparent across-track slope in the data. The moving average filter helps to distinguish systematic biases from short-period noise. The output is suitable for further analysis or input into correction algorithms. The -testonly option is listed but not implemented.