snapshot β Reson SeaBat Beamformed Amplitude & Phase Snapshot Parser
Overview & Purpose
The snapshot module (code/subr/snapshot.c and code/subr/snapshot.h) reads, unpacks, and manages memory for binary Reson SeaBat βsnapshotβ filesβsingle-ping full water-column beamformed amplitude and phase captures recorded by Reson SeaBat 81xx-series multibeam echosounders.
Each snapshot file begins with a 121-byte big-endian extended header (snapshot_header) containing UTC time, vessel navigation (latitude, longitude), attitude (heave, roll, pitch, heading), and sonar operating settings (sound_speed, sample_rate, pulse_width_microsec, ping_rate, range_setting, power, gain, tvg_spread, tvg_absorp, beam_width, and beam_count). Following the header is a sequence of num_packets range-slice data packets (snapshot_data), each containing a 16-bit unsigned amplitude and a 16-bit signed phase value for every beam in the swath.
Key Constants & Data Structures
Constants (snapshot.h)
#define SIZE_OF_SNAPSHOT_HEADER 121: Exact on-disk byte size of the binary snapshot file header.
snapshot_header Structure (121 bytes on disk)
typedef struct {
unsigned short extended_header;
unsigned short packet_size;
unsigned char utc_time[32];
double latitude;
double longitude;
double heave;
double roll;
double pitch;
double heading;
unsigned char start_character;
unsigned char packet_id;
unsigned short packet_size_2; /* beam count / inner packet size */
unsigned short header_id; /* 0xffff */
unsigned int time_sec;
unsigned int time_millis;
unsigned short sound_speed;
unsigned short sample_rate;
unsigned char pulse_width_microsec;
unsigned short ping_rate;
unsigned short range_setting;
unsigned short power;
unsigned short gain;
unsigned short projector_setting;
unsigned char tvg_spread;
unsigned char tvg_absorp;
unsigned char beam_width;
unsigned short beam_count;
unsigned char end_character;
unsigned short check_sum;
} snapshot_header;
snapshot_data & snapshot Structures
typedef struct {
unsigned char start_character;
unsigned char packet_id;
unsigned short packet_size;
unsigned short packet_number;
unsigned short *amplitude; /* [beam_count] */
signed short *phase; /* [beam_count] */
unsigned char end_character;
unsigned short check_sum;
} snapshot_data;
typedef struct {
snapshot_header header;
snapshot_data data;
unsigned short **amplitude; /* [beam_count][num_packets] */
signed short **phase; /* [beam_count][num_packets] */
int num_packets;
} snapshot;
Public Functions & Signatures
1. Whole-File Snapshot Management
int init_snapshot(snapshot *the_snapshot)Zeroesthe_snapshot->header, setsamplitudeandphase2D pointers toNULL, setsnum_packets = 0, and initializesthe_snapshot->dataviainit_snapshot_data().int read_snapshot(snapshot *the_snapshot, FILE *infile)Reads an entire snapshot file intothe_snapshot:- Determines the file length via
fseek(infile, 0, SEEK_END)andftell(). - Rewinds to offset
0and callsread_snapshot_header(&the_snapshot->header, infile). - Computes the per-slice packet size (
9 + 4 * beam_countbytes) and total range slicesnum_packets = (file_length - 121) / packet_size. - Dynamically allocates/reallocates the 2D
[beam_count][num_packets]arraysthe_snapshot->amplitudeandthe_snapshot->phase. - Loops through all
num_packetsslices, callingread_snapshot_data()and transposing each slice into[beam][packet]order.
- Determines the file length via
int print_snapshot(snapshot *the_snapshot)Prints the snapshot header metadata tostdoutby callingprint_snapshot_header(&the_snapshot->header).int free_snapshot(snapshot *the_snapshot)Frees all per-beam rows and top-level pointer arrays inthe_snapshot->amplitudeandthe_snapshot->phase, then resets the struct viainit_snapshot().
2. Low-Level Header & Packet Helpers
int read_snapshot_header(snapshot_header *header, FILE *infile)ReadsSIZE_OF_SNAPSHOT_HEADER(121) bytes frominfileand unpacks all fields using big-endian deserialization helpers fromjb_endian.h(get_BE_short,get_BE_int,get_BE_double,get_BE_char).int print_snapshot_header(snapshot_header *header)Prints a human-readable dump of all navigation, attitude, and sonar settings inheader(scalingping_rate / 1000.0,tvg_spread / 4.0, andbeam_width / 10.0).int init_snapshot_data(snapshot_data *data)Setsdata->amplitude = NULLanddata->phase = NULL.int read_snapshot_data(snapshot_data *data, int num_beams, FILE *infile)Reads one range-slice packet (9 + 4 * num_beamsbytes) frominfileand unpacks the packet framing plusnum_beamspairs of big-endian 16-bitamplitudeandphasesamples.
How It Fits Into the OMG Architecture
- Water-Column Snapshot Inspection & Imaging (
jonnyb/gom_stuff/read_snapshot.c,jonnyb/gom_stuff/snapshot2pgm.c): Useinit_snapshot(),read_snapshot(),print_snapshot(), andfree_snapshot()to inspect Reson SeaBat water-column snapshot headers and render beam-vs-range amplitude and phase matrices into Portable GrayMap (.pgm) images.