comboASCIIParam
Overview
comboASCIIParam (code/tests/comboASCIIParam.c, authored by John Hughes Clarke in November 2019) ingests separate ASCII vector/matrix files exported from MATLAB (originally generated by Ivan for 3D multi-spectral backscatter analysis) representing acoustic frequency (-xval), grazing angle (-yval), and seafloor backscatter strength (-zval).
When all three files are supplied (-zval active), comboASCIIParam applies an optional static dB offset (-shiftBS), writes the unbinned 2D matrix as an OMG .r4 floating-point image (<out>.r4), exports a full 3-column ASCII table (<out>), and bins the observations into a regular 2D grid of grazing-angle bins (-grazBins) by frequency bins (-freqBins), producing both an averaged ASCII table (<out>.av) and a packed OMG .r4 raster (<out>.pack.r4). If -zval is omitted, it merges matching 1D -xval and -yval vectors into a 2-column ASCII file filtered by [minFkHz, maxFkHz].
Syntax & CLI Options
comboASCIIParam [-v] [-minFkHz <kHz>] [-maxFkHz <kHz>] [-freqBins <N>] \
[-minGraz <deg>] [-maxGraz <deg>] [-grazBins <N>] \
[-maxBS <dB>] [-shiftBS <dB>] \
-xval <freq.xval> -yval <graz.yval> [-zval <bs.zval>] -out <outfile>
| Option | Description | Default |
|---|---|---|
-xval <file> | Required. Input ASCII file containing $N_x$ frequency values (in kHz, up to $10^6$ floats). | None |
-yval <file> | Required. Input ASCII file containing $N_y$ grazing angle values (in degrees, up to $10^6$ floats). | None |
-zval <file> | Optional input ASCII file containing $N_x \times N_y$ backscatter values (in dB). Triggers 3D grid generation and binning. | Disabled |
-out <file> | Required. Base output filename. Creates <out>, and if -zval is used, <out>.r4, <out>.av, and <out>.pack.r4. | None |
-minFkHz <val> | Minimum frequency (kHz) for binning or 2D filtering. If 0, defaults to $\min(f) - 1\text{ kHz}$. | 0.0 (auto) |
-maxFkHz <val> | Maximum frequency (kHz) for binning or 2D filtering. If 0, defaults to $\max(f) + 1\text{ kHz}$. | 0.0 (auto) |
-freqBins <N> | Number of frequency bins for the packed grid (maximum FREQBINS = 200). | 100 |
-minGraz <deg> | Minimum grazing angle (degrees) for binning. | 0.0 |
-maxGraz <deg> | Maximum grazing angle (degrees) for binning. | 90.0 |
-grazBins <N> | Number of grazing angle bins for the packed grid (maximum GRAZBINS = 180). | 90 |
-maxBS <dB> | Upper outlier threshold in dB; only samples with $\text{BS} < \text{maxBS}$ are accumulated into packbs. | 100.0 |
-shiftBS <dB> | Additive calibration offset (in dB) applied to every raw Z value upon reading (the_zval[k] += shiftBS). | 0.0 |
-v | Increment verbose flag (verbose_flag++). | 0 |
Binning & Grid Generation Algorithm
1. Raw Matrix Export (<out>.r4 and <out>)
When -zval is provided, comboASCIIParam reads $N_x$ frequencies (the_xval), $N_y$ grazing angles (the_yval), and $N_z = N_x \times N_y$ backscatter values (the_zval). Each backscatter value is shifted by shiftBS:
An OMG JHC_header (OMG1 tag, data_type = 3, projection = 4, dx = noyval, dy = noxval) is written to <out>.r4 via write_JHC_header(), followed by byte-swapped IEEE-754 floats via jswapfloat_fwrite(). Simultaneously, unbinned (freq, graz, BS) triplets are written to <out>.
2. 2D Frequency vs. Grazing Angle Binning (<out>.av and <out>.pack.r4)
The bin step sizes are computed as:
\[\Delta f = \frac{f_{\max} - f_{\min}}{N_{\text{freqBins}}}, \qquad \Delta\theta_g = \frac{\theta_{g,\max} - \theta_{g,\min}}{N_{\text{grazBins}}}\]For each sample $(i, j)$, the nearest bin indices (igraz, ifreq) are computed by rounding:
All samples within bounds that satisfy $Zā_{i,j} < \text{maxBS}$ are averaged inside packbs[igraz][ifreq]. Non-zero averaged cells ($ | \overline{\text{BS}} | > 1\text{ dB}$ and $\overline{\text{BS}} < \text{maxBS}$) are written as freq graz BS rows to <out>.av, and the 2D packbs array is exported with an OMG1 JHC_header to <out>.pack.r4 for visualization in jview. |
Example Usage
# Combine MATLAB frequency, grazing angle, and backscatter dumps into binned ASCII and .r4 grids
comboASCIIParam -minFkHz 90 -maxFkHz 170 -freqBins 50 \
-minGraz 0 -maxGraz 90 -grazBins 90 \
-maxBS -5.0 -shiftBS -25.0 \
-xval camp_freq.xval -yval camp_graz.yval -zval camp_bs.zval \
-out camp_multispec
For frequency-dependent calibration detrending and altitude/attenuation SNR masking on these datasets, see comboASCIIParam2.