diffOMG
Description
diffOMG is a utility for comparing two OMG-HDCS merged data files. It can generate an .r4 (float grid) file representing the depth differences between corresponding beams in the two input files. Additionally, it can output statistics (average and absolute difference/standard deviation) of these differences per beam angle, or it can compare profile header information (like orientation data).
This tool is invaluable for quality control, verifying data processing steps, and analyzing subtle differences between datasets.
Usage
diffOMG -first <OMG_HDCS_datafile1> -second <OMG_HDCS_datafile2> -out <diff.r4file> [OPTIONS]
Arguments
| Option | Description | |
|---|---|---|
-first <OMG_HDCS_datafile1> | Required. Path to the first OMG-HDCS merged data file. | |
-second <OMG_HDCS_datafile2> | Required. Path to the second OMG-HDCS merged data file. | |
-out <diff.r4file> | Required. Base name for the output difference file. This will be an .r4 file for depth differences, and also .stats and .abs_stats for statistical outputs. | |
-v | Enable verbose output. | |
-dumpaverage | Output an .avdepth file containing the average depths. | |
-shift <val> | Shift beams in the second file by this amount before comparison (e.g., -1 to compare beam j in first file with beam j-1 in second). | 0 |
-skip <val> | Skip pings when calculating differences (e.g., 10 to process every 10th ping). | 1 |
-average <val> | Average val pings together when writing to the .r4 output. | 1 |
-width <val> | When outputting to .r4, represent the swath as nopixels (250) pixels wide, where the entire swath width is val meters. Used instead of -average. | 0 (disabled) |
-profile_header | Compare profile header information (pitch, roll, heave) instead of beam depths. This mode outputs to .stats only. | |
-stdev | Calculate standard deviation of differences instead of absolute mean difference. | |
-bias <biasfile> | Apply a bias correction from a biasfile (format: beam_idx bias_value). |
How It Works
- Input Reading & Initialization:
- Opens the two input merged files and creates output files (
.r4for differences,.avdepthfor average depths,.statsand.abs_statsfor statistics). - Reads summary headers from both input files, issuing a warning if their
numProfilesdiffer. - If a
-biasfile is provided, it reads the per-beam bias values intobiases[].
- Opens the two input merged files and creates output files (
- Profile Header Comparison (
-profile_headermode):- If
-profile_headeris specified, it iterates through pings, reads profile headers from both files, and prints (to.stats) the roll, pitch, and heave values from both profiles, along with their differences.
- If
- Beam Depth Difference Calculation (Default Mode):
- If
-profile_headeris not specified:- Sets up the header for the output
.r4file. - Initializes arrays for
av_diff(average difference),abs_diff(absolute difference/standard deviation),notoav(count of valid comparisons),differences(for single ping differences), andavdepth. - Iterates through pings (potentially skipping with
-skip):- Reads raw beams from both input files for the current ping.
- For each beam
j(potentially shifted byshiftin the second file):- If both beams have valid
observedDepth, it calculatesthis_differenceas the percentage difference between their depths, and subtracts anybiases[j]. - Accumulates
this_differenceintodifferences[j](for.r4output),av_diff[j], andabs_diff[j]. Incrementsnotoav[j]. - If
swathwidthis specified, it populatesswath[]with differences based on across-track position.
- If both beams have valid
- Output to
.r4: Writesdifferences[](orswath[]) to the.r4output file, potentially averaging overaveragepings.
- Statistical Output: After processing all pings, it calculates final
av_diff[i]andabs_diff[i](average and absolute difference/standard deviation) per beam index. It writes these statistics (beam angle vs. average/abs difference) to the.statsand.abs_statsfiles.
- Sets up the header for the output
- If
- Cleanup: Closes all open files.
Output Files
<diff.r4file>.r4: A JHC-format.r4file containing depth differences (if not in-profile_headermode).<diff.r4file>.avdepth: An.avdepthfile containing average depths (if-dumpaverageis used).<diff.r4file>.stats: An ASCII file with statistics of differences (mean, standard deviation).<diff.r4file>.abs_stats: An ASCII file with absolute statistics of differences.
Dependencies
OMG_HDCS_jversion.h: For OMG-HDCS data structures.array.h: ForJHC_headerstructure and.r4file handling.support.h: For general utility functions and error handling.
Notes
diffOMG provides a powerful means to compare different processing versions of the same data, or to inter-compare independent surveys. The -min_within_pixels (not shown in arguments, but relevant for difference tools) or -shift options can help mitigate small spatial misalignments. The output statistics per beam angle are crucial for identifying angle-dependent biases.