sm2000 β€” Kongsberg Simrad Mesotech SM2000 Raw IQ Beamforming & Bottom Detection Library

Overview & Purpose

The sm2000 module (code/subr/sm2000.c and code/subr/sm2000.h), written by John Hughes Clarke in July 1998, provides a complete software beamforming, split-aperture phase-comparison bottom detection, and OMG HDCS output pipeline for raw element-level Quadrature (I/Q) stave time-series data recorded by the 200 kHz Kongsberg Simrad Mesotech SM2000 semicircular multibeam imaging and bathymetric sonar.

Unlike conventional multibeam echosounders that output pre-formed beams, the SM2000 logs raw 16-bit basebanded I and Q time slices across all 80 transducer elements (TRANSDUCERS = 80) arranged on a $180^\circ$ circular arc of radius $R = 0.09375\text{ m}$ (ARRAY_ARC_RADIUS). This library performs:

  1. Sync-word hunting (0x00 0x80 interleaved every 2 bytes) and raw header decoding (jSM2K_read_raw_header) plus element I/Q ingestion (jSM2K_read_IQs).
  2. Circular-arc phase-delay lookup table generation (jSM2K_calc_arc_delays, jSM2K_make_element_phase_tables) and selectable aperture shading (UNSHADED, COS_SQUARED, INVERSE_LINEAR, LINEAR, COSINE, BINOMIAL).
  3. Full-array amplitude beamforming and split-aperture (SUBARRAY_LEFT / SUBARRAY_RIGHT) complex cross-correlation beamforming across 120 formed beams (NO_FORMED_BEAMS = 120).
  4. Hybrid center-of-mass amplitude detection (AD_*) and iterative least-squares zero-crossing interferometric phase detection (PD_*) in jSM2K_do_bd().

Key Constants & Data Structures

Array Geometry & Processing Constants (sm2000.h)

Macro Value Description
TRANSDUCERS 80 Number of physical transducer elements on the semicircular receive array
MAXSAMPLES 1000 Nominal range samples per ping (sm2k_slices supports up to 4000)
HEADERSIZE 480 480 16-bit words interleaved with 480 sync byte pairs (0x00 0x80)
NO_FORMED_BEAMS 120 Number of software-formed receive beams per ping
ARRAY_ARC_SECTOR 180.0 Angular span of the transducer array arc in degrees
ARRAY_ARC_RADIUS 0.09375 Radius of the semicircular transducer array in meters ($9.375\text{ cm}$)
SM2K_FREQUENCY 200000.0 Acoustic carrier frequency in Hz ($200\text{ kHz}$)
UNSHADED .. BINOMIAL 0 .. 5 Windowing functions for aperture element shading (sm2k_type)
RAW_TRACES, AMPLITUDE_ONLY, PHASE_PLUS 0, 1, 2 Beamforming and bottom detection modes (sm2k_method)

Key Structures (sm2000.h)

  • scomplex ({ short I, Q; }) & time_slice ({ scomplex tdcr[80]; }): Raw 16-bit quadrature sample pair per element and 80-element snapshot across up to 4,000 range slices (sm2k_slices[4000]).
  • fcomplex ({ float I, Q; }): Floating-point complex sample used during phase-shifted beamforming (Out[1000], Left[1000], Right[1000]).
  • sm2000_raw_header (sm2khead): Unpacked ping header containing navigation (latitude, longitude in $10^{-5}$ minutes), attitude (heave, pitch, roll, heading), sys_time, sys_range, lever arms (fact_MS*, fact_PS*, fact_SH*), TVG factors, ping_number, sh_rate_cnt, number_of_range_samples, and clock dividers (fclk_cnt_A, fclk_cnt_B).
  • sm2000_beam & sm2000_ping (sm2kping): Per-beam bathymetric solution (depth, across, along, range_in_samples, array_relative_angle, amplitude detection AD_range/AD_min/AD_max/AD_peakrange, phase detection PD_range/PD_min/PD_max/PD_valid, peak_intensity) for all 120 beams in a ping.
  • sm2000_files (sm2kfp): Suite of 9 output file pointers opened by jSM2K_open_files(prefix) (.merged, .merged.ss_data, .merged.ph_data, .merged.bottom, .ss, .nav, .merged.fish, .ph_XZ, .in_XZ).

Public Functions & Signatures

1. Raw Header & Element IQ Reading

  • int jSM2K_read_raw_header(FILE *file): Hunts for the 0x00 0x80 sync byte pattern, verifies 240 sync pairs across the 1,920-byte raw header block, strips the interleaved sync bytes, byte-swaps fields into sm2khead and sm2kping, updates sm2k_Sample_Period, and triggers jSM2K_calc_arc_delays() if the sampling frequency changed.
  • int jSM2K_read_IQs(FILE *file): Reads TRANSDUCERS * 4 * number_of_range_samples bytes of raw element I/Q data into sm2k_slices[] and byte-swaps each short via swap_short().

2. Array Geometry & Software Beamforming

  • void jSM2K_calc_mount_angles(void): Populates Td_angle[80] with each transducer element’s mounting angle in tenths of a degree across the $180^\circ$ arc.
  • void jSM2K_calc_arc_delays(void): Computes the circular-arc geometric path delay $(1 - \cos\theta) R \cdot f / c$ (in degrees of phase) for off-axis angles $0.0^\circ$ to $89.9^\circ$ in $0.1^\circ$ increments (sm2k_angular_delays[900]).
  • void jSM2K_setup_beamforming(void) / void jSM2K_calc_desired_angles(float roll) / void jSM2K_build_wts(...): Computes desired steering angles for all 120 beams (with optional roll stabilization) and builds element shading weights angular_weights[120][1800].
  • void jSM2K_make_element_phase_tables(int beamnum) / void jM2k_phase_shift(scomplex svectin, int element, fcomplex *fvectout): Builds per-element $\cos\phi$ / $\sin\phi$ phase rotation tables for beam beamnum and rotates each element’s (I, Q) vector to focus the circular arc onto a plane wavefront.
  • void jSM2K_form_beam_ts(int j): Forms the time series (Magnitude[] and PhaseLag[]) for beam j using RAW_TRACES, full-aperture AMPLITUDE_ONLY, or split-aperture cross-correlation PHASE_PLUS (get_cmplxXcorr_sm2000).

3. Bottom Detection, Depth Projection & Output

  • void jSM2K_find_first_arrival(void): Scans raw element amplitudes across the central half of the array to detect the first water-column bottom return (sm2k_first_arrival) exceeding sm2k_threshold.
  • void jSM2K_do_bd(int num, float *mag, float *phase, int start_win, int end_win): Performs 4-iteration center-of-mass amplitude bottom detection (AD_range) followed (when sm2k_method == PHASE_PLUS) by 5-window phase-coherence selection and iterative window-tightening least-squares zero-crossing detection (PD_range).
  • void jSM2K_calc_depths(int num): Converts range_in_samples and roll-corrected array_relative_angle into depth and across-track coordinates.
  • void jM2k_write_omg_rec(FILE *file, int recno, float minmag, float maxmag): Writes the 120 formed beams into a 128-beam OMG HDCS v3 .merged record (toolType = SM2000).
  • int jSM2K_open_files(char *prefix) / int jSM2K_reopen_files(char *prefix) / int jSM2K_close_files(void): Manage the suite of 9 output files per survey line.

How It Fits Into the OMG Architecture

  • SM2000 Processing (grid/sm2000toOMG.c, image/TAtoXZ.c): Drive the full SM2000 raw IQ beamforming, bottom detection, water-column polar-to-Cartesian (XZ) imaging, and OMG HDCS conversion pipeline.
  • Split-Aperture / Quadrature Signal Processing (netcdf/hdf5EC150read.c, subr/ek_IQ.c): Reuse complex IQ amplitude/phase utilities (fl_get_amplitude, fl_get_phase, get_cmplxXcorr_sm2000) for Simrad EK80/EC150 ADCP/echosounder quadrature processing.