deRefract
Description
deRefract is a utility designed to apply corrections for refraction and other empirical adjustments to multibeam sonar data. It can apply either a set of subjective empirical correction coefficients (defined in swathed and interpolated along the line) or an “empirical hack angular correction” for poorly refraction-corrected data. The tool can process both standard OMG-HDCS merged files and USL-HDCS observed depth files.
It allows for fine-tuning of depth and across-track values to compensate for sound speed variations in the water column and instrument-specific biases.
Usage
deRefract <mergefile(s)> [-v] (-coeffs | -hackfn <filename>) [OPTIONS]
Arguments
| Option | Description |
|---|---|
<mergefile(s)> | Required. One or more paths to OMG-HDCS merged files or USL-HDCS line directories. These files are modified in place. |
-v | Enable verbose output. |
Correction Methods (Choose one)
| Option | Description | |—|—| | -coeffs | Apply empirical correction coefficients loaded from a .ref_coeffs file. | | -hackfn <filename> | Apply a hack function based on an external file (tidefilename). This uses the older, pre-coefficient method. |
Coefficient-Based Options (-coeffs)
| Option | Description | |—|—| | -depthshift | Apply a depth shift based on the coefficient data. | | -perc_depth | Apply a percentage depth correction based on the coefficient data. |
Older Hackfn Options (-hackfn)
| Option | Description | |—|—| | -beams <val> | Specifies the number of beams for the hack function (if not 60). | 60 | | -symm | Applies corrections symmetrically to port and starboard sides. | | -roll_offset <val> | Applies a constant roll offset (in degrees). |
File Type
| Option | Description | |—|—| | -hdcs | Process USL-HDCS observed depth files instead of OMG-HDCS merged files. |
Other Options
| Option | Description | |—|—| | -mode <value> | Only apply corrections to profiles (pings) with this specific mode value. | 999 (all modes) |
How It Works
- File Processing: The tool iterates through each provided merged file (or USL-HDCS directory).
- Summary Header Reading & File Type Handling: Reads the summary header and handles both OMG-HDCS and USL-HDCS file formats, mapping USL-HDCS data to OMG structures.
- Coefficient Loading (
-coeffs): If-coeffsis used, it attempts to readref_coeffdata from a.ref_coeffsfile and sets them up. If not found, it uses null coefficients. It also callsjREF_decide_array_typeto set the array type based onsummary.toolType. - Hackfn Method Setup (
-hackfn): If-hackfnis used (and not-coeffs), it loads original depth and range data fromtidename. It then calculatesdangle(angular shift) ordep_shift(depth shift/multiplier) values per beam based on thedepthshiftorperc_depthflags, using a least-squares fit ifdepthshiftis active. - Profile and Beam Iteration: For each profile (ping) in the file:
- Mode Filtering: If
-modeis specified, it only processes pings whoseprofile.modematches themode_choice. - Reads the raw beams for the current profile (converting USL-HDCS beams to OMG format if
hdcs_flagis set). - For each beam
ithat has anobservedDepthandreflectivity:- Coefficient-Based Correction (
-coeffs):- Gets coefficients for the current ping using
get_coeffs. - Sets up refraction coefficients using
set_up_ref_coefficients. - Calls
get_refracted_locationto calculatedepth_outandacross_outfromdepth_inandacross_inbased on the refraction coefficients. - Updates
beams[i].observedDepthandbeams[i].acrossTrack.
- Gets coefficients for the current ping using
- Hackfn-Based Correction (pre-coefficient method):
- If
depthshiftis active, it modifiesbeams[i].observedDepthusingdepthmove[i]ordepth_multiplier[i]. - Otherwise (for angle shift), it calculates
orig_anglefromorig_depthandorig_range. It appliesangshift(fromdangle[i]orsymangle[i]) androll_offsetto getreal_angle. It then recalculatesreal_depthandreal_rangefrom thisreal_angleandslant_range, updatingbeams[i].observedDepthandbeams[i].acrossTrack.
- If
- Coefficient-Based Correction (
- Mode Filtering: If
- In-Place Update: The modified
beams(with corrected depths and across-track values) are written back to the merged file (or USL-HDCS file) for the current profile.
Output Files
The input merged files are modified in-place.
Dependencies
OMG_HDCS_jversion.h: For OMG-HDCS data structures.support.h: For general utility functions and error handling.ref_coeffs.h: For refraction coefficient structures and functions.
Notes
This tool offers both a modern (coefficient-based) and a legacy (hack function) approach to correcting bathymetric data for refraction and other systematic biases. Due to its empirical nature, careful validation of the applied corrections is essential. The tool modifies merged files in place, so backups are recommended.