xtf2glo
Description
xtf2glo is a utility designed to convert XTF (Extended Triton Format) sidescan data into the JCU GLORIA format. It processes various XTF header types, extracting sonar data (typically high-frequency, low-frequency, and optionally sub-bottom profiles). The tool offers options for logarithmic or linear scaling of intensity values, byte swapping for endianness correction, and side swapping for correct port/starboard orientation. It also extracts and logs any raw serial data found in the XTF stream.
Usage
xtf2glo [-havesub] [-swapside] [-swapbyte] [-log] [-addISIStime] [-otherdt] [-min16bitval <value>] [-max16bitval <value>] -in <infile> -out <outfile_prefix>
Arguments
| Option | Description | Β |
|---|---|---|
-havesub | If specified, the tool will attempt to extract sub-bottom profile data and write it to a separate output file (.sub_ss). | Β |
-swapside | If specified, port and starboard sides will be swapped during conversion. | Β |
-swapbyte | If specified, byte swapping will be performed on multi-byte values. This is typically needed when the XTF fileβs endianness differs from the processing systemβs. | Β |
-log | Activates logarithmic scaling of intensity values. | Β |
-addISIStime | When extracting raw serial data, adds an ISIS-style timestamp to the beginning of each serial string. | Β |
-otherdt | Uses an alternative method for calculating the raw time sample, potentially for different XTF data types. | Β |
-min16bitval <value> | Specifies the minimum 16-bit value for linear scaling. Used with non-logarithmic scaling. | 0 |
-max16bitval <value> | Specifies the maximum 16-bit value for linear scaling. Used with non-logarithmic scaling. | 65535 |
-in <infile> | Required. The input XTF data file. | Β |
-out <outfile_prefix> | Required. The prefix for the output JCU GLORIA files. The tool will generate: <outfile_prefix>.hig_ss (high-frequency sidescan), <outfile_prefix>.low_ss (low-frequency sidescan), and <outfile_prefix>.serial (ASCII serial data). If -havesub is used, also <outfile_prefix>.sub_ss. | Β |
How It Works
- Initialization and Argument Parsing: The tool sets up parameters for scaling, byte swapping, and output file prefixes based on command-line arguments. It also initializes
logvalandloglutarrays if logarithmic scaling is enabled. - File Opening: Opens the input XTF file and creates multiple output files for high-frequency sidescan (
.hig_ss), low-frequency sidescan (.low_ss), raw serial data (.serial), and optionally sub-bottom profile (.sub_ss). - Read XTF File Header: Calls
readXTFheader(fromxtf_funcs.c) to read and convert the XTF file header into a structuredXTFFILEHEADERobject. - Process XTF Data Packets (Main Loop):
- It enters a loop, continuously reading XTF data packets using
readXTFdata(fromxtf_funcs.c). - Packet Type Handling: A
switchstatement handles differentHeaderTypes:XTF_HEADER_SONAR: This is the primary data type for sidescan.- Calls
conv_to_jcugloto process the sonar data. - Writes the resulting high-frequency (
higrec) and low-frequency (lowrec) GLORIA records to their respective files. - If
-havesubis enabled, also writessubrec.
- Calls
XTF_HEADER_RAW_SERIAL: Callsstrip_out_serialto extract and process raw ASCII serial data, which is then written to the.serialfile. If-addISIStimeis specified, a timestamp is prepended to the serial string.- Other header types (Attitude, Bathy, etc.) are recognized and their counts incremented, but their data is not further processed into GLORIA records in this specific implementation.
- Error Handling:
readXTFdataincludes logic to skip corrupted records and attempt to resynchronize the file pointer.
- It enters a loop, continuously reading XTF data packets using
conv_to_jcugloFunction:- Takes the XTF
buffer,FileHead, and pointers to GLORIA records (higrec,lowrec,subrec). - It converts the XTF Ping Header (
cXTFPINGHEADER) into a structuredXTFPINGHEADERand then populates the common GLORIA header fields (time, lat, lon, altitude, heading, fishdepth) from this XTF ping header. - It then iterates through each sonar channel specified in
PingHeader.NumChansToFollow:- Converts the XTF Ping Channel Header (
cXTFPINGCHANHEADER). - Reads the raw intensity data (
BytesPerSamplecan be 1 or 2). - Applies logarithmic (
-log) or linear scaling to convert raw intensity to 8-bit. - Averages multiple XTF samples into 512 GLORIA pixels (
avfact). - Assigns the processed 8-bit data to the
stbd_dataorport_dataarrays oflowrecorhigrecbased onChanHeader.ChannelNumberandswapside. Sub-bottom data (Channel 4) is placed insubrec.stbd_data.
- Converts the XTF Ping Channel Header (
- Takes the XTF
strip_out_serialFunction: Extracts ASCII data fromXTFRAWSERIALHEADERrecords.- Loop Termination: The main loop continues until the end of the input file or an unrecoverable error occurs.
- File Closing: All opened files are closed.