modarray
Description
modarray is a utility designed to modify lookup arrays, specifically to calculate the “aspherical spreading component” derived from beam refraction. It processes input files representing time-lag and beam-angle (in JHC image format) to determine how the apparent angular change of a beam deviates from the normal angular change. This resulting “aspherical” component is then output as a new JHC image file.
Usage
modarray -water <file_prefix> [-first <record>] [-last <record>]
Arguments
| Option | Description |
|---|---|
-water <file_prefix> | Required. Specifies a prefix for related water column files. The tool expects to find <file_prefix>.time_lag and <file_prefix>.beam_angle. It will output <file_prefix>.aspherical. |
-first <record> | Specifies the first record number to include in processing. |
-last <record> | Specifies the last record number to include in processing. |
How It Works
- Input Loading:
- The tool opens three files: a time-lag file (
.time_lag), a beam-angle file (.beam_angle), and creates an aspherical output file (.aspherical). These are expected to be JHC image files, typically containingfloatdata. - It reads the
JHC_headerfrom the time-lag and beam-angle files to get image dimensions (dx,dy). - The entire image data for time-lag (
times) and beam-angle (beams) is loaded into memory as arrays offloat.
- The tool opens three files: a time-lag file (
- Aspherical Component Calculation:
- The tool iterates through each pixel (
j,i) of the image, from the inner regions (skipping the edges for derivative calculations). - For each pixel:
- Range Calculation: It calculates the
rangeusing the time-lag value at that pixel (*(times + j + (i * time_head.dx)) * 1500.0, assuming speed of sound 1500 m/s). - Normal Angular Change (
normal_del_angle): This is calculated as the arctangent of(2 * asph_head.xstep / range). This represents the expected angular change across a pixel given its range. - Apparent Angular Change (
del_angle): This is derived from the spatial derivatives of thebeamsarray:del_vert = top - bottom;(vertical derivative of beam angles)del_hori = right - left;(horizontal derivative of beam angles)del_angle = sqrt(del_hori^2 + del_vert^2);(magnitude of the apparent angular change).
- Ratio Calculation: The
asphericalcomponent is calculated as the ratiodel_angle / normal_del_angle. This ratio indicates how much the apparent angular change deviates from the expected normal angular change.
- Range Calculation: It calculates the
- If any input data is invalid (e.g.,
rangeis zero or neighboring beam-angle values are missing), the outputasphericalvalue is set to -1.
- The tool iterates through each pixel (
- Output File: The calculated
asphericalcomponents are written asfloatvalues to the output file (.aspherical), preceded by aJHC_header.