downGrade
Description
downGrade is a utility designed to reduce the resolution of JCU GLORIA format sidescan files. It can decimate the data both along-track (by averaging multiple pings) and across-track (by averaging multiple pixels within a ping). An optional βdestripingβ mode allows for a different aggregation method across-track, potentially for noise reduction.
Usage
downGrade [-v] [-across <pixels>] [-along <pings>] [-destripe] -in <infile> -out <outfile>
Arguments
| Option | Description | Β |
|---|---|---|
-v | Enable verbose output. | Β |
-across <pixels> | Specifies the number of pixels to average across-track. | 1 |
-along <pings> | Specifies the number of pings to average along-track. | 1 |
-destripe | If specified, when aggregating along-track, instead of averaging, the maximum pixel value will be retained. | (None) |
-in <infile> | Required. The input JCU GLORIA format file. | Β |
-out <outfile> | Required. The output JCU GLORIA format file with reduced resolution. | Β |
How It Works
- Input File Reading: The tool opens the specified input JCU GLORIA file (
inname) and output file (outname). - Parameter Validation: It checks if
acrossandalongparameters are within reasonable bounds. - Along-Track Aggregation: The tool iterates through the input file, processing pings in blocks of
alongpings:- Initialize Sums: For each block, it initializes
sumlat,sumlon,sumalt,sumtimefor header fields, andtracecount[k],tracesum[k]for pixel values across the swath. - Read Pings: It reads
alongconsecutive pings into a temporary arraytrace. - Across-Track Aggregation (
pack_across): For each ping in the block,pack_acrossis called to perform across-track averaging (or aggregation). This function takes astbd_dataarray and anaverparameter (which isacross), and averagesacrosspixels together, reducing the resolution of that ping. - Accumulate Header and Pixel Data:
- It accumulates
altitude,lat,lon, andtimefrom thealongpings. - For each pixel position
kacross the swath:- If
destripe_flagis set,tracesum[k]will store the maximum pixel value encountered in that position over thealongpings. - Otherwise,
tracesum[k]will store the sum of pixel values. tracecount[k]stores the number of valid (non-255) pixels for each position.
- If
- It accumulates
- Initialize Sums: For each block, it initializes
- Calculate Averaged Record: After processing
alongpings:- Header Averaging:
altitude,lat,lon, andtimeare averaged for the block.aziis recalculated usinggetazifrom the averageddxanddy. - Pixel Averaging: For each pixel position
k:- If
destripe_flagis not set,outrecord.stbd_data[k]is the average oftracesum[k] / tracecount[k]. - If
destripe_flagis set,outrecord.stbd_data[k]is thetracesum[k](which holds the maximum value).
- If
outrecord.header.small_pixelis adjusted byacross.
- Header Averaging:
- Write Output: The averaged
outrecordis written to the output file. - Loop: This process repeats until all pings in the input file have been processed.
Helper Functions:
pack_across(data, aver): Reduces the across-track resolution of a single data trace by averagingaverconsecutive pixels.getdxdy(azi, dx, dy): Calculates x and y components from an azimuth.getazi(dx, dy, azi): Recalculates azimuth from x and y components.