edReject

Description

edReject is a specialized utility for automatically flagging spurious soundings within OMG-HDCS merged files using “Ed’s method”. This method focuses on detecting various types of “spikes” or sudden discontinuities in the depth profile across the swath, such as simple spikes, or flat-topped/bottomed spikes.

The tool calculates depth gradients (delta) between adjacent beams and flags beams where these gradients exceed a user-defined threshold (eps) or show specific patterns indicative of spikes.

Usage

edReject <mergefile(s)> [-v] [-eps <value>]

Arguments

Option Description  
<mergefile(s)> Required. One or more paths to OMG-HDCS merged files to be processed. These files are modified in place.  
-v Enable verbose output (present in the main function arguments but not explicitly used in the provided code snippet).  
-eps <value> (Present in USAGE but commented out in main’s argument parsing) Intended to specify the epsilon threshold for depth gradients. Default 0.1 is hardcoded in the Eds_method function. 0.1

How It Works

  1. File Processing: The tool iterates through each provided merged file.
  2. Summary Header Reading: Reads the summary header for basic file information.
  3. Profile and Beam Iteration: For each profile (ping) in the file:
    • Reads the current profile header and raw beams.
    • Data Preparation: Populates an abeam array (allbeams) with the acrossTrack and observedDepth values (converted to meters) for each beam.
    • Ed’s Method Application: Calls the Eds_method function to perform the core spike detection logic:
      • Gradient Calculation: For each beam i (from 1 to nodepths - 1), it calculates allbeams[i].delta as the depth difference between allbeams[i] and allbeams[i-1], divided by the absolute across-track difference.
      • Spike Detection Rules: It then iterates through the beams and applies various rules based on allbeams[i].delta and its neighbors to identify spikes:
        • Spikes close to zero: Flags beams adjacent to zero-depth readings if their delta exceeds eps.
        • Simple spikes: Flags beam_flags[i] (using bitwise OR) if allbeams[i].delta is positive and allbeams[i+1].delta is negative (spike up then down), or vice-versa.
        • Spikes with high flat: Flags beam_flags[i] if allbeams[i].delta is a strong positive/negative gradient, followed by a flat section, and then a strong negative/positive gradient.
      • Target Detection (Commented Out): There’s a section for “Target detection” that attempts to set *profile_flag = 'T' if any beam_flags[i] is non-zero and has adjacent non-zero flags. This part is currently not fully implemented or utilized to update the profile.edflag.
    • Flagging & Storing: The flags generated by Eds_method (stored in flags array) are assigned to beams[i].calibratedBackscatter. The profile.edflag is also updated.
    • Write Back: The modified profile header and beams are written back to the merged file.

Output Files

  • The input merged files are modified in-place.
  • The profile.edflag field in the merged file’s profile header is set to ‘T’ if targets are detected, otherwise it is ‘0’.
  • The beams[i].calibratedBackscatter field is used to store individual beam flags (0 for good, non-zero for flagged).

Dependencies

  • OMG_HDCS_jversion.h: For OMG-HDCS data structures.
  • support.h: For general utility functions and error handling.

Notes

“Ed’s method” is a heuristic approach to spike detection that relies on local depth gradients and specific patterns. While the eps threshold is hardcoded in the function, it’s designed to be effective for specific types of data artifacts. Repurposing calibratedBackscatter for storing flags suggests this tool is used for diagnostic or intermediate flagging purposes, and these flags might be reset or further processed by other tools. The -eps option is listed in the usage but not actively parsed, meaning the default value is always used.