special_hack_glbeam
Description
special_hack_glbeam is a specialized utility for beam pattern correction of a JCU GLORIA file. This tool applies correction factors based on depth ranges, using 20 correction factor files to adjust the beam pattern according to the nadir depth. Additionally, it incorporates a linear-logarithmic compression function to prevent clipping of data that might otherwise exceed the maximum intensity value after correction. This version uses different compression parameters (LINEAR_LIMIT = 180.0, MAX_REPRESENTED = 512) compared to hack_glbeam.c.
Usage
special_hack_glbeam <infile> <outfile>
Arguments
| Option | Description |
|---|---|
<infile> | Required. The input JCU GLORIA file. |
<outfile> | Required. The output JCU GLORIA file with beam pattern correction and compression applied. |
How It Works
- Linear-Logarithmic Compression (
linear_log_compress):- This function takes an intensity value (
before) as input. - If
beforeis greater thanLINEAR_LIMIT(180.0), it applies a power law compression:after = (int)(pow(before - LINEAR_LIMIT, (1. / power)) + LINEAR_LIMIT). This compresses values above theLINEAR_LIMITinto a smaller range, preventing them from exceeding 255. - Otherwise,
afterremainsbefore. - A lookup table
linlog_correctedis pre-computed for efficiency.
- This function takes an intensity value (
- Read Beam Pattern Parameters: The tool reads 20 beam pattern correction files, each corresponding to a specific depth range (e.g., “ps89_025.beam_pattern”, “ps89_075.beam_pattern”, etc.). These files contain port and starboard beam pattern parameters (
stbd_par,port_par) and average values (stbd_ave,port_ave). - Initialize Parameters: For each beam pattern parameter, the reciprocal is calculated for corrections to be applied by multiplication.
- Process Input File: The tool reads the input GLORIA file record by record.
- Determine Depth Bin: For each record, it determines the appropriate depth bin based on the
altitudein the record header (altitude divided by 500 meters). If the altitude is very shallow or very deep, it uses predefined bins. Otherwise, it interpolates between two bins based on the altitude. - Apply Correction: For each pixel in the sidescan data (port and starboard):
- It calculates the
theta(angle) based on the pixel’s distance from nadir and the altitude. - It interpolates beam pattern correction parameters (
prev_parameter,post_parameter) from the loaded beam pattern files based onthetaand the determined depth bin. - These parameters are then weighted by
prev_weightandpost_weight(which depend on the altitude’s position between the two depth bins). - The raw pixel value is multiplied by the calculated parameter to get the initial
correctedvalue. - This
correctedvalue is then passed through thelinear_log_compressfunction to apply the compression, preventing values from exceeding 255. - The final
correctedvalue is clamped to a maximum of 254.
- It calculates the
- Write Output: The corrected record is written to the output file.