calcRayDiff
Description
calcRayDiff is a specialized utility designed to compare two sound velocity profiles (SVPs) by calculating the depth differences predicted by ray tracing through each SVP. It takes two SVP files (typically from a BOT MVP100/200/XXX profiler), builds Time-Angle (TA) lookup tables for each, differences their predicted depths, and then reprojects these differences into Across-track/Depth (XZ) space.
The primary purpose of this tool is to provide a graphical output (currently a PGM image) that quantifies the absolute scale of depth anomalies at every depth-across track position, which can be encountered by a shipboard sonar. This helps users understand the impact of using one SVP over another on multibeam bathymetry.
Usage
calcRayDiff -pro1 <file1> -pro2 <file2> -outimage <image_file> [-tdcr_dep <val>] [-maxangle <val>] [-v]
Arguments
| Option | Description | |
|---|---|---|
-pro1 <file1> | Required. Path to the first SVP file (MVP format). | |
-pro2 <file2> | Required. Path to the second SVP file (MVP format). | |
-outimage <image_file> | Required. Output PGM (Portable Graymap) image file, showing depth differences. | |
-tdcr_dep <val> | Transducer depth (meters). | 2.5 |
-maxangle <val> | Maximum beam angle to trace (degrees). | 75.0 |
-v | Enable verbose output. |
How It Works
- Initialization: Parses command-line arguments to get input/output filenames and ray tracing parameters (
transducer_depth,maxangle). - SVP Reading (
read_MVP()):- Opens the two input SVP files (
-pro1,-pro2). - Calls
read_MVP()to parse the MVP-formatted SVP files. This function reads depth-velocity pairs (ZVpair) and stores them inraw_zv1andraw_zv2arrays. It skips initial header lines from the MVP format. - Closes the SVP files.
- Opens the two input SVP files (
- Water Column Initialization (
jWC_init()):- Initializes two
watercolumnstructures (wc1,wc2) usingjWC_init()(an external function). These structures will hold the processed SVPs and ray trace results. - Determines
max_depthandmax_rangebased on the input SVPs andmaxangle.
- Initializes two
- SVP Interpolation (
jWC_interp_zv()):- Interprets the raw SVP data within
wc1andwc2into a finely layered model (e.g., constant velocity layers). This prepares the water column for ray tracing.
- Interprets the raw SVP data within
- Ray Tracing (
jWC_trace()):- Performs ray tracing through
wc1andwc2to generate internal Time-Angle (TA) lookup tables for depth.
- Performs ray tracing through
- Time Series Resampling (
jWC_resample_timeseries()):- Resamples the ray trace results into a uniform time-angle grid for easier comparison.
- Across-track/Depth (XZ) Interpolation (
jWC_interp_XZ()):- Interpolates the ray trace results into an XZ grid (Across-track/Depth) for
wc1.
- Interpolates the ray trace results into an XZ grid (Across-track/Depth) for
- Difference Calculation (
AT_difference()):- Creates a new
farray(AT_diff) to store the differences in depth betweenwc1.AT_depthandwc2.AT_depthin Time-Angle space.
- Creates a new
- Reprojection to XZ Space (
AT_to_XZ_reproject()):- Creates a new
farray(XZ_diff) to store the depth differences in Across-track/Depth space. - Uses the XZ-interpolated time and angle grids from
wc1(wc1.XZ_time,wc1.XZ_angle) to map theAT_diffvalues into theXZ_diffgrid.
- Creates a new
- Output to PGM (
write_out_PGM()):- Writes the
XZ_diffarray as a PGM (Portable Graymap) image, where pixel intensity represents the magnitude of the depth difference.
- Writes the
- Cleanup: Frees all allocated
farrayandwatercolumnmemory.
Output Files
<image_file>: A PGM (Portable Graymap) image file quantifying depth anomalies.
Helper Functions
read_MVP(FILE *grazfile, ZVpair *zvp, int *novals, int vflag): Reads depth-velocity pairs from an MVP-formatted SVP file.getc_line(FILE *file, char *string, int printit): Reads a line from a file.AT_difference(farray *at1z, farray *at2z, farray *atdiffz): Calculates the difference between twofarraystructures.AT_to_XZ_reproject(farray *xzdiff, farray *atdiff, farray *xztime, farray *xzangle): Reprojects data from Time-Angle space to Across-track/Depth space.write_out_PGM(farray *fa): Writes anfarrayto a PGM image file.
Dependencies
support.h: For general utility functions.j_watercolumn.h: Forwatercolumnstructure and ray tracing functions (jWC_init,jWC_interp_zv,jWC_trace,jWC_resample_timeseries,jWC_interp_XZ,jWC_free).j_farray.h: Forfarraystructure (a generic 2D floating-point array structure with associated metadata).
Notes
calcRayDiff is a specialized tool for quality control and validation of sound velocity profiles. It provides a powerful visual aid for understanding the impact of SVP uncertainty or choice on multibeam depth measurements. The output PGM image directly highlights areas where significant depth anomalies are predicted due to differences in SVPs, which can guide further investigation or processing strategies.