k16to8

Overview

k16to8 converts 16-bit Knudsen echosounder/sub-bottom waveform envelope files (.merged.16_data) into 8-bit trace files (.merged.ss_data) with a rich set of radiometric and signal-processing corrections: linear or logarithmic compression, 40 log R to 30 log R TVG adjustment (-adjustTVG_40to30), two-way water-column attenuation compensation (-atten_coeff), ensonified-area normalization (-do_ensonified_area), frequency-domain bandpass filtering (-filter), signed full-waveform rectification (-Signed), and external sonar interference blanking (-remove_otherTX).

Usage

k16to8 (-v) (-log | -lin) (-max16 8000) (-min16 10) (-Signed) (-non1600) \
       (-filter 3000 8000) (-noLF | -noHF) (-adjustTVG_40to30) \
       (-do_ensonified_area -area_scaler 1000) (-atten_coeff 50) \
       (-custom_dump file_prefix -first N -last M -remove_heave) \
       (-remove_otherTX -max_depth_of_interference 10 -tx_threshold 2000) \
       -in infile.merged.16_data -out outfile.merged.ss_data

CLI Options

Flag Arguments Default Description
-in <infile> required Input 16-bit trace file (<prefix>.merged.16_data); automatically opens <prefix>.merged when geometry/metadata options are enabled.
-out <outfile> required Output 8-bit trace file (<prefix>.merged.ss_data); also writes <outfile>.convert recording min16 max16.
-lin / -log none -lin (PACK16_LINEAR) Use linear or logarithmic (PACK16_LOG) 16-to-8-bit scaling.
-min16 / -max16 <value> 1 / 65535 Minimum and maximum 16-bit sample thresholds mapped to 0–255.
-Signed none unsigned Treat input 16-bit samples as signed (signed short) and rectify/process accordingly.
-non1600 none fixed 1600 samples Read variable trace lengths (beams[side].no_samples) and byte offsets (beams[side].offset * 2) from the companion .merged file.
-noLF / -noHF none both channels present Indicate that only the HF (beam[0]) or LF (beam[1]) channel is present in .16_data.
-filter <low_Hz> <high_Hz> none Apply a bandpass filter between low_Hz and high_Hz (also enables -non1600).
-adjustTVG_40to30 none 0 Remove 40 log R TVG applied by the sounder and replace with 30 log R spherical spreading TVG.
-do_ensonified_area none 0 Normalize trace amplitudes by the pulse-limited/beam-limited ensonified area on the seabed.
-area_scaler <value> 100.0 Scaling multiplier used with -do_ensonified_area.
-atten_coeff <dB_per_km> 0 Apply a two-way absorption loss correction in dB/km along the trace.
-remove_otherTX none 0 Detect and suppress acoustic cross-talk spikes from other shipboard sonars by substituting samples from the previous trace (last_row).
-max_depth_of_interference <meters> 10.0 Depth window (in meters above/below bottom) within which cross-talk suppression is restricted.
-tx_threshold <value> 2000 16-bit amplitude jump threshold for triggering -remove_otherTX.
-custom_dump <prefix> none Dump subsetted raw 16-bit, 8-bit, and ASCII traces (<prefix>.HF.16bit, .LF.16bit, .HF.8bit, .LF.8bit, .ascii).
-first / -last <ping> 0 / 10000000 First and last ping numbers for -custom_dump.
-remove_heave none 0 Shift traces vertically by profile.vesselHeave during -custom_dump.
-v none 0 Enable verbose output.

How It Works

  1. Trace Reading & Companion .merged Lookup: Reads big-endian 16-bit trace arrays (fread_BE_short) from -in. Whenever radiometric, filtering, or variable-length options (-non1600, -filter, -do_ensonified_area, -atten_coeff, -remove_otherTX, -custom_dump) are active, strips the .16_data extension (mem_stripext(inname)) to read OMG_HDCS_profile_header and OMG_HDCS_beam metadata from the .merged file.
  2. Radiometric & Interference Corrections: Optionally suppresses cross-talk bursts (-remove_otherTX), applies FFT bandpass filtering (-filter), compensates for two-way attenuation (-atten_coeff), adjusts 40 log R to 30 log R TVG, and normalizes for ensonified area (-do_ensonified_area).
  3. 16-to-8-Bit Collapse: Compresses each processed trace to 8-bit via jK_collapse_16_to_8(), writes it to -out, and logs the min/max scaling range to <outfile>.convert.

Practical Examples

Re-compress 16-bit Knudsen traces to 8-bit with logarithmic scaling and attenuation correction

k16to8 -log -min16 20 -max16 15000 -non1600 -atten_coeff 8.5 \
       -in line01.merged.16_data -out line01.merged.ss_data