replaceOMG
Description
replaceOMG is an emergency toolkit utility designed to selectively replace data fields in a “corrupted” OMG-HDCS merged file with values from an “OK” (good) version of the same file. This is useful for data recovery scenarios where specific parts of a merged file have been inadvertently altered or corrupted by other software, allowing users to restore data without re-processing the entire dataset.
The tool currently supports replacing either motion data (roll, pitch, heave, heading) or beam status flags and some profile-level sonar settings.
Usage
replaceOMG <ok_OMG_HDCS_infile> <corrupted_OMG_HDCS_outfile> [OPTIONS]
Arguments
| Option | Description | |
|---|---|---|
<ok_OMG_HDCS_infile> | Required. The path to the “good” OMG-HDCS merged file, which contains the correct data to be copied. | |
<corrupted_OMG_HDCS_outfile> | Required. The path to the “corrupted” OMG-HDCS merged file, which will be modified in place with data from the ok_infile. | |
-justMotion | Replaces only the motion-related fields (vesselHeave, vesselPitch, vesselRoll, vesselHeading) in the profile header. | |
-first <ping_num> | Specifies the starting ping number to process. This functionality is mentioned in the USAGE string but is not implemented in the main loop, which processes all profiles. | |
-last <ping_num> | Specifies the ending ping number to process. This functionality is mentioned in the USAGE string but is not implemented in the main loop, which processes all profiles. | |
-v | Enable verbose output. |
How It Works
- File Opening: Opens the
ok_OMG_HDCS_infilefor reading and thecorrupted_OMG_HDCS_outfilefor reading and writing (in-place modification). - Summary Header Check: Reads the summary headers from both files. It verifies that both files have the same
fileVersionandnumProfiles, stopping with an error if they do not match. - Profile and Beam Iteration: The tool iterates through each profile (ping) from
0tosummary.numProfiles - 1:- Reads the profile header from both the
ok_infile(profile) and thecorrupted_outfile(prof2). - Data Replacement:
- If
-justMotionis specified, it copiesvesselHeave,vesselPitch,vesselRoll, andvesselHeadingfromprofiletoprof2. - Otherwise (if
-justMotionis not specified), it copies sonar settings likepower,TVG,attenuation,pulseLength,mode,status, andnumDepthsfromprofiletoprof2. It also reads the raw beams from both files and copies only thestatusfield from theok_infile’s beams to thecorrupted_outfile’s beams.
- If
- Writing Changes: The modified
prof2(profile header) andb2(beam data) are written back to thecorrupted_OMG_HDCS_outfileat the corresponding profile index.
- Reads the profile header from both the
Output Files
The input corrupted_OMG_HDCS_outfile is modified in-place.
Dependencies
OMG_HDCS_jversion.h: For OMG-HDCS data structures.support.h: For general utility functions and error handling.
Notes
replaceOMG is an emergency tool for data recovery. It allows for quick fixes by transferring known good data from one file to another, which can save significant reprocessing time. However, users should be extremely cautious when using this tool and ensure that the “OK” file is indeed correct for the intended fields, as it directly modifies binary data. The -first and -last options are defined in the USAGE string but are not implemented in the main processing loop.