r2sonic2image
Description
r2sonic2image is a utility (possibly a debugging or work-in-progress tool) that reads R2Sonic multibeam sonar .r2s files, specifically focusing on Full Time Series (FTS) snippet data and bathymetry data. Its primary function appears to be to extract and analyze snippet intensity information relative to bathymetric bottom detections for a given ping. While named r2sonic2image, the provided code snippet mainly prints information to standard output and does not produce a graphical image file.
It can be used to investigate the raw snippet waveforms around the detected bottom to understand detection quality or characteristics.
Usage
r2sonic2image -r2s <input.r2s> [-ping <ping_number>] [-v]
Arguments
| Option | Description | |
|---|---|---|
-r2s <input.r2s> | Required. Path to the input R2Sonic .r2s file. | |
-ping <ping_num> | Specifies the ping number (0-indexed) to process. | 0 (default) |
-v | Enable verbose output. |
How It Works
- Initialization: Parses command-line arguments to get the input
.r2sfilename and thepingnumber to process. - File Opening: Opens the input
.r2sfile for reading. Createsimage.8bit(for the 8-bit output image) andimage.txt(for detailed text output). - R2Sonic Indexing: Calls
build_R2SONIC_INDEX()(an external function) to build an index of the.r2sfile, locating all FTS (R2SONIC_ID_FTS0) and Bathy (R2SONIC_ID_BTH0) records. - Bathy and Snippet Data Extraction:
- Seeks to the
file_offsetof the specifiedping’s Bathy record and reads theR2SONIC_BATHYdata (bathy). - Finds the corresponding snippet ping (
snippet_ping) usingfind_R2SONIC_PING_MATCH(). - Iterates through potential sub-packets of the snippet data (as snippets can be fragmented across multiple records) and reads
R2SONIC_FTSdata (fts).
- Seeks to the
- Snippet-Bathy Correlation and Output:
- For each beam in the
bathyrecord:- If snippet data is available for the beam (
fts.snippet[i].num_samplesis not zero), it calculates:sample: The sample index within the snippet corresponding to the beam’stwtt(two-way travel time).intensity: The intensity value at thatsamplein the snippet.sample_corr: A corrected sample index using a constant offset (0.045 - 0.119 * cos(angle)) totwtt.intensity_corr: The intensity at the corrected sample.sample_center: The center sample of the snippet.intensity_center: The intensity at the center sample.
- It prints these calculated values for the beam.
- It then prints all snippet samples (
fts.snippet[i].first_sample + j) and their intensities (fts.snippet[i].samples[j]) for the current beam.
- If snippet data is available for the beam (
- For each beam in the
- Cleanup: Frees the R2Sonic index and closes the input file.
Output Files
- Prints detailed information about beam-snippet correlation and snippet time series to standard output.
image.8bit: (No explicit generation in snippet) Potentially an intended output for a graphical image.image.txt: (No explicit generation in snippet) Potentially an intended output for a text file.
Dependencies
R2Sonic_parser.h: For R2Sonic data structures and parsing functions (build_R2SONIC_INDEX,read_R2SONIC_BATHY,read_R2SONIC_FTS).support.h: For general utility functions and error handling.math.h: For mathematical functions.
Notes
While named r2sonic2image, the primary output of this tool appears to be textual information printed to standard output for debugging and analysis, rather than a graphical image file. It’s useful for in-depth investigation of snippet data in relation to bottom detections, helping to understand the raw acoustic returns and potentially refine bottom tracking algorithms. The tool relies on internal R2Sonic data structures for interpretation.