7kTVG
Description
7kTVG is a utility designed to extract and process Time Varied Gain (TVG) data from Reson 7k (.s7k) files. It reads all 7k_7010_TVG records from an .s7k file, aggregates the TVG gain values for each ping, and then outputs them as a 2D floating-point array (JHC .r4 format). The output array represents ping number versus sample index, with each cell containing the TVG gain value.
This tool is useful for analyzing the TVG curves applied by the sonar, which is important for understanding backscatter measurements and for calibrating side-scan sonar data.
Usage
7kTVG -in <inputfile.s7k> -out <outputfile.r4> [-v]
Arguments
| Option | Description |
|---|---|
-in <inputfile.s7k> | Required. Path to the input Reson 7k .s7k file. |
-out <outputfile.r4> | Required. Path for the output JHC .r4 file containing the TVG array. |
-v | Enable verbose output. |
How It Works
- Initialization: Parses command-line arguments to get input/output filenames. Initializes
Reson_7K_NF,Reson_7K_DRF, andReson_7K_7010_TVGstructures. - File Opening: Opens the input
.s7kfile for reading and the output.r4file for writing. - First Pass (Metadata Collection):
- Reads through the entire input
.s7kfile once. - Identifies all
7k_7010_TVGrecords. - Determines
max_num_samples(the maximum number of samples found in any TVG record) andnum_pings(total number of TVG records).
- Reads through the entire input
- Buffer Allocation: Allocates a 1D floating-point array
outbufferof sizemax_num_samples * num_pingsto store all TVG gain values. - Second Pass (Data Extraction and Aggregation):
- Resets the file pointer of the input
.s7kfile to the beginning. - Reads through the input
.s7kfile a second time. - For each
7k_7010_TVGrecord:- Copies the
tvg_gainarray from thetvgstructure into theoutbufferat the appropriate offset (this_ping * max_num_samples).
- Copies the
- Increments
this_ping.
- Resets the file pointer of the input
- Output to JHC
.r4File:- Calls
writeJHC()(an external function) to write a JHC header to the output.r4file. The header will reflect the dimensions of the TVG array (max_num_samplesasdx,num_pingsasdy, and data type asJB_FLOAT). - Writes the aggregated
outbufferdata to the.r4file.
- Calls
- Cleanup: Frees allocated memory and closes all files.
Output File
<outputfile.r4>: A JHC.r4file (binary float array) where rows represent pings and columns represent sample indices, with each cell containing the TVG gain value.