Switch
Description
Switch.c is a utility designed to convert a Time-Angle (TA) lookup table (raster) into a Depth-Across (DA) lookup table. This conversion is crucial in ray tracing applications, where initial ray tracing results are often in TA space (time of flight vs. outgoing beam angle), but practical applications require results in DA space (across-track distance vs. depth).
The tool takes pre-computed lookup tables for beam angle (.beam_angle), time of flight (.time_lag), and an angle-time depth lookup table (e.g., from Ray.c), and uses them to interpolate depth values into a new grid representing across-track distance and depth.
Usage
Switch -locate <ATFilename> -pro <svp_handle>
Arguments
| Option | Description | |—|—| | -locate <ATFilename> | Required. Path to the Angle-Time (AT) depth lookup table file (e.g., from Ray.c). This file provides the depth for given angle and time. | | -pro <svp_handle> | Required. Base name for the velocity profile. The tool expects: * <svp_handle>.beam_angle: Beam angle lookup table. * <svp_handle>.time_lag: Time of flight lookup table. * It will create <svp_handle>.Switched as output. | | -v | Enable verbose output. | |
How It Works
- Initialization: Parses command-line arguments to get input/output filenames.
- File Opening and Header Reading:
- Opens the Angle-Time depth lookup table file (
ATFilename) and reads itsJHC_header(AThead). - Opens the beam angle (
.beam_angle) and time of flight (.time_lag) lookup table files and reads their respectiveJHC_headers (Ahead,Thead). - Creates the output file (
.Switched) and copiesTheadtoOhead(output header).
- Opens the Angle-Time depth lookup table file (
- Memory Allocation: Allocates memory for
AngTim(Angle-Time depth data),Ang(beam angle data),Tim(time of flight data), andOut(output Depth-Across data). - Data Reading: Reads the contents of
ATFilename,.beam_angle, and.time_lagintoAngTim,Ang, andTimarrays, respectively. - Conversion Loop: Iterates through each cell (
i,j) of the output grid (Depth-Across space, dimensions fromOhead.dx,Ohead.dy):- Retrieves
beam_anglefromAng[j * Ahead.dx + i]andtime_of_flightfromTim[j * Thead.dx + i]. - If both are valid, it uses
interp_JHCarray_value()(an external function for 2D array interpolation) to find the correspondingdepthvalue from theAngTimlookup table, given thebeam_angleandtime_of_flight. - Stores this
depthvalue in theOutarray atOut[j * Ohead.dx + i]. - If either
beam_angleortime_of_flightis invalid, the outputdepthis set to 0.0.
- Retrieves
- Output: Writes the
Outarray to the.Switchedfile. - Cleanup: Frees allocated memory and closes all files.
Output Files (JHC .r4 Array Format)
<svp_handle>.Switched: A 2D floating-point array (raster) representing depth values in Depth-Across space. Each cell contains the depth corresponding to an across-track distance and depth (derived from time of flight and beam angle). The output file contains aJHC_headerfollowed by the raw float data.
Dependencies
support.h: For general utility functions.array.h: ForJHC_headerstructure andinterp_JHCarray_valuefunction.
Notes
The conversion from Time-Angle to Depth-Across space is a critical step in using ray tracing results for multibeam sonar processing. The output Depth-Across lookup table is then used to quickly and efficiently correct raw sonar measurements for sound velocity profile effects. This tool helps to create the necessary intermediate products for accurate bathymetric mapping.