getGraz
Description
getGraz is a utility designed to create or update a Look-Up Table (LUT) of backscatter (Sb) values versus true grazing angle, derived from multibeam sonar data. It compares observed depths from merged files against a Digital Terrain Model (DTM) to calculate true grazing angles and stores these alongside the corresponding backscatter values.
The tool aims to correct backscatter data for the true grazing angle, accounting for seabed slopes and potentially removing the Simrad Lambertian Correction. The LUT can then be used for backscatter classification or further analysis.
Usage
getGraz <merged_file(s)> -lut <LUThandle> [OPTIONS]
Arguments
| Option | Description | |
|---|---|---|
<merged_file(s)> | Required. One or more paths to input OMG-HDCS merged files. | |
-lut <LUThandle> | Required. The handle (base name) for the Look-Up Table files. The tool will generate/update <LUThandle>.lut and <LUThandle>.num files. | |
-flat | Use a flat seafloor assumption (nadir topography only) for DTM depth. | |
-numsam <val> | Specifies the maximum number of backscatter samples to store per pixel in the LUT. | 5 |
-v | Enable verbose output. |
How It Works
- Initialization: Parses command-line arguments to set various flags, including
flat_flag(for flat seafloor),NUMSAM(max samples per pixel), and output filenames. - DTM Loading: Reads the input
.r4(float grid) DTM file (specified byoutname, which is typically derived from the DTM filename). This DTM represents the reference surface. - LUT File Setup:
- Attempts to open
<LUThandle>.lutand<LUThandle>.numfiles. - If these files do not exist, it creates them and initializes them with blank data and a JHC header.
- If they exist, it reads the existing
numarray (which stores the count of samples per pixel).
- Attempts to open
- Profile and Beam Iteration: Loops through each input merged file and then through each profile (ping) and beam within:
- Data Validation: Checks if
beams[j].observedDepthis valid and if the beam’sstatusis not flagged. - Geographic Positioning: Locates the beam’s geographic position (lat/lon) and projects it onto the DTM grid (
x,y). - DTM Depth Lookup: Retrieves
true_depth,true_east, andtrue_southfrom the DTM at the beam’s projected location. - Grazing Angle Calculation:
- Calculates
anglebased onacrossTrackanddepth(relative toCREED_DRAFT). - Calculates
beam_azi(beam azimuth). - Uses
vectangle(an external function) to compute thetrue_grazing_angleby comparing the beam’s angle and azimuth with the seafloor slope derived from the DTM.
- Calculates
- Backscatter Processing:
- If
true_grazing_angleis valid (not negative), it extractsSb(backscatter frombeams[j].reflectivity). - It then “uncorrects” the Simrad Lambertian Correction from
Sbusing10.0 * log10(pow(cos(angle * M_PI / 180.0), 2.0)).
- If
- LUT Accumulation:
- If the pixel (
x,y) in the DTM has fewer thanNUMSAMsamples already stored, it creates anSb_valuestructure withfile,profile,beam,azi,graz(true grazing angle), andSb(uncorrected backscatter). - It then writes this
Sb_valueto the.lutfile at the appropriate offset and increments the count in thenumarray for that pixel.
- If the pixel (
- Verbose Output: If
verbose_flagis set, it prints detailed information for selected beams.
- Data Validation: Checks if
- Final
numArray Update: After processing all files, it writes the updatednumarray (containing sample counts per pixel) back to the.numfile. - Cleanup: Closes all open files and frees allocated memory.
Output Files
<LUThandle>.lut: A custom binary file containing backscatter values (Sb_valuestructures) mapped by geographic pixel.<LUThandle>.num: A JHC.r4grid file containing the count ofSb_valuesamples per geographic pixel.
Dependencies
OMG_HDCS_jversion.h: For OMG-HDCS data structures.array.h: ForJHC_headerstructure and DTM data handling.support.h: For general utility functions and error handling.j_proj.h: For coordinate projection functions.backscatter.h: Forvectanglefunction.
Notes
This tool allows for the construction of spatially organized Look-Up Tables of backscatter vs. grazing angle. This is fundamental for building empirical models of the seafloor’s acoustic response, which can then be used for seafloor classification or correcting backscatter imagery. The removal of the Simrad Lambertian correction is critical for getting true backscatter values that reflect the seafloor rather than sonar processing.