omg_sdf
Overview & Purpose
omg_sdf is the binary reader and parser for Klein Sonar Data Format (SDF) and SDF Extension (SDFX) records generated by Klein 3000, 3500, 4000, 5000, and 5900 series sidescan and interferometric bathymetric sonars. Klein SDF files consist of variable-length βpagesβ synchronization-marked by 0xFFFFFFFF (SDF_PING_MARKER), containing a versioned page header (Version 2, 3, or 4) followed by sonar-specific acoustic channel arrays (3501, 3502, 5004, 5902, 5903, 5910, 5911, 5920) and embedded SDFX extension records (bathymetry calibration/settings, Klein Motion Sensor KMS, Applanix POSMV messages 1/102/112, and Greensea INS records).
Key Data Structures, Constants & Macros
Constants
SDF_PING_MARKER(0xFFFFFFFF): 32-bit synchronization marker preceding each SDF page.- Header Sizes:
SDF_HEADER_V2_SIZE(176bytes),SDF_HEADER_V3_SIZE(256bytes),SDF_HEADER_V4_SIZE(512bytes).
Core Structs
SDF_Header: Unified structure supporting SDF page header versions 2, 3, and 4:- Version 2 (176 bytes):
num_bytes,page_version,configuration,ping_number,num_samples,beams_to_display,error_flags,range,speed_fish,sound_speed,res_mode,tx_waveform,resp_div,resp_freq,manual_speed_switch,despeckle_switch,speed_filter_switch, TPU date/time, NMEA fix time,heading,pitch,roll,depth,altitude,temperature,speed,ship_heading,magnetic_variation,ship_lat/lon,fish_lat/lon. - Version 3 Extension (+80 bytes = 256 bytes):
tvg_page,header_size,fix_time_year/month/day,aux_pitch/roll/depth/altitude,cable_out,f_seconds,altimeter,sample_freq,depressor_type,cable_type,shieve_x/y/z_offset,gps_height,raw_data_config. - Version 4 Extension (+256 bytes = 512 bytes): Sub-bottom profiler parameters (
sbp_tx_waveform,sbp_preamp_gain,sbp_data_raw,sbp_num_samples,sbp_sample_freq,sbp_tx_waveform_version),wing_angle,emergency_switch_state,layback_method,layback_fish_lat/lon,fish_heading_offset,pressure_sensor_offset,tpu_sw_version,capability_mask,tx_version,num_samples_extra,post_process_version,motion_sensor_type, timing reference counts,altitude_bathy,ping_interval,sdf_extension_size,seconds_of_week, pressure sensor calibration,processed_ping_number, andreserved3[30].
- Version 2 (176 bytes):
- Acoustic Page Payload Structs:
SDF_5004: Klein 5000 multi-beam sidescan (ss[10]), port/stbd interferometric bathymetry (bathy_intensity[2],bathy_angle[2],bathy_quality[2],bathy_x/y/z[2]),roll,pitch,heave, raw I/Q staves (raw_port_i/q[15],raw_stbd_i/q[15]), andsubbottom[4].SDF_3501,SDF_3502,SDF_5902,SDF_5910,SDF_5920: Port/starboard floating-point sidescan arrays (float *fss[2]).SDF_5911: Klein 5900 bathymetry (bathy_intensity/angle/quality/x/y/z[2],roll,pitch,heave,bathy_SNR[2],bathy_uncertainty[2]).
- SDFX Extension Structs:
SDFX_Header: 64-byte extension record header (id,num_bytes,header_version,record_version,reserved[12]).SDFX_Bathy_Calibration(id = 200) &SDFX_Bathy_Processed_Settings(id = 203): Transducer stave spacing, phase corrections, depression angles, and bathymetry scale factors.SDFX_KMS_Raw(id = 301) &SDFX_KMS_Processed(id = 302): Klein Motion Sensor raw and processed attitude records.SDFX_POSMV_Common,SDFX_POSMV_1(id = 303),SDFX_POSMV_102(id = 304),SDFX_POSMV_112(id = 305): Embedded Applanix POS MV navigation, attitude, and time records.SDFX_GREENSEA(id = 0x0310/784): Greensea INS motion, position, acceleration, and gyro record.
SDF_Reader: Master stateful reader holding file pointers,OMG_Buffer inbuffer,bytes_to_skip,SDF_Header, all channel structs, and dynamic arrays ofSDFX_*records.
Public Functions & Signatures
- File & Record Navigation:
int init_SDF_Reader(SDF_Reader *reader)/int free_SDF_Reader(SDF_Reader *reader)int open_SDF_File(SDF_Reader *reader, char *inname)/int close_SDF_File(SDF_Reader *reader)int seek_SDF_Record(SDF_Reader *reader): Scans byte-by-byte until matching the 4-byte little-endianSDF_PING_MARKER(0xFFFFFFFF).int read_SDF_Record(SDF_Reader *reader): Peeksnum_bytes, loads the entire page intoreader->inbuffer, callsparse_SDF_Header(), and dispatches onpage_versiontoparse_SDF_5004,parse_SDF_3501,parse_SDF_3502,parse_SDF_5902β5920, andparse_SDFX().
- Header, Channel & SDFX Parsers/Printers:
init_SDF_Header,parse_SDF_Header,print_SDF_Headerinit_SDF_5004,parse_SDF_5004,print_SDF_5004,parse_SDF_3501,parse_SDF_3502,parse_SDF_5902,parse_SDF_5903,parse_SDF_5910,parse_SDF_5911,parse_SDF_5920parse_SDFX,parse_SDFX_Header,parse_SDFX_Bathy_Calibration(print_...),parse_SDFX_Bathy_Processed_Settings(print_...),parse_SDFX_KMS_Raw(print_...),parse_SDFX_KMS_Processed(print_...),parse_SDFX_POSMV_Common(print_...),parse_SDFX_POSMV_1(print_...),parse_SDFX_POSMV_102(print_...),parse_SDFX_POSMV_112(print_...),parse_SDFX_GREENSEA(print_...).
How It Fits Into the OMG Architecture
omg_sdf powers the code/sdf/ toolset (sdfTool, sdf2omg, sdf2nav, sdf2orientation), enabling inspection and conversion of Klein sidescan, interferometric bathymetry, and embedded POS MV / Greensea / KMS motion data into OMG HDCS files.