subtractSurface
Overview
subtractSurface compares every valid multibeam sounding in one or more OMG HDCS .merged survey lines against a bilinearly interpolated .r4 reference surface (<r4prefix>.r4) and writes the vertical residual (real_depth - measured_depth, in millimeters) directly into each beam’s offset (file versions 2–4) or depthAccuracy (version 1) field in-place.
Syntax & CLI Options
subtractSurface [-v] [-proc] [-add_dyn_draft_shift] [-latshift <min>] [-lonshift <min>] <r4prefix> <merged_files...>
| Flag / Argument | Description |
|---|---|
-v | Verbose per-beam residual output. |
-proc | Compare processedDepth (instead of observedDepth) against the reference surface. |
-add_dyn_draft_shift | Subtract profile.longperiod_heaveCorrection / 1000.0 (dynamic draft / squat) from the measured beam depth before computing the residual. |
-latshift <min> | Latitude shift in arc-minutes applied to beam coordinates before projecting onto the reference grid (default: 0.0). |
-lonshift <min> | Longitude shift in arc-minutes applied to beam coordinates before projecting onto the reference grid (default: 0.0). |
<r4prefix> | Reference .r4 grid prefix (reads <r4prefix>.r4). |
<merged_files...> | One or more OMG HDCS .merged survey line files (modified in-place). |
How It Works
- Reference Surface Loading:
- Opens
<r4prefix>.r4, reads itsJHC_header(data_type == 3), and loads the floating-point depth array (final_data) into memory.
- Opens
- Beam-by-Beam Residual Computation:
- Opens each
<merged_file>in read-write mode ("r+") and loops over all unflagged profiles (profile.status == 0). - For each valid beam (
observedDepth > 0,status != 22 && status != 1):- Computes the beam’s geographic position (
locate_beam), applies-latshift/-lonshift, and projects onto fractional grid coordinates(x, y)viaProject. - Computes the tide-reduced beam depth (using
processedDepthif-procis set, elseobservedDepth, and optionally applyinglongperiod_heaveCorrectionif-add_dyn_draft_shiftis set). - Bilinearly interpolates the reference surface depth
real_depthfrom the 4 surrounding grid nodes (get_lookup_value), requiring all 4 neighbors to be non-zero. - Stores
(real_depth - depth) * 1000.0intobeams[n].offset(for HDCS v2–v4) orbeams[n].depthAccuracy(v1), or0.0if outside the valid reference surface.
- Computes the beam’s geographic position (
- Writes the updated beam records back into the
.mergedfile (OMG_HDCS_put_raw_beams).
- Opens each
Examples
Compute beam-by-beam depth residuals against a reference patch-test grid
subtractSurface -proc ref_patch line01.merged line02.merged
Evaluate residuals with a trial navigation offset of +0.02’ latitude and -0.03’ longitude
subtractSurface -latshift 0.02 -lonshift -0.03 ref_surface survey_line.merged
Workflow Context
- Upstream:
weigh_grid(builds the reference.r4bathymetric surface). - Downstream:
swathEd(visualizes the storedoffset/ residual across beams to diagnose roll, pitch, latency, sound speed, or dynamic draft artifacts).