Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Repicking layers

Layer picks in OPR data (such as the surface and bed layers) should be pretty good, but they’re not always perfect. Sometimes the pick is offset from the true reflection peak by a few samples, and occasionally it’s just wrong. If your work relies on having exactly the right surface or bed point, you may want to consider locally repicking.

“Repicking” refers to refining these layer picks by examining the radar data in a local window around each existing pick and selecting a better value. This notebook demonstrates two approaches:

  1. Local maximum: Simply take the strongest return within a window around the existing pick.

  2. scipy.signal.find_peaks: Use peak detection with custom parameters for more control over the selection criteria.

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Load a flight line and its layer picks

We’ll start by loading a flight segment and its existing layer picks.

/home/runner/work/xopr/xopr/src/xopr/opr_access.py:577: UserWarning: Warning: Unexpected result from ops_api: ERROR: SEGMENT DOES NOT EXIST.
  warnings.warn(f"Warning: Unexpected result from ops_api: {result['data']}", UserWarning)
Available layers: ['standard:surface', 'standard:bottom']

Defining repick functions

The idea behind repicking is simple: for each trace, look at the radar data in a small window around the existing pick and choose a better twtt value. The choice of how to pick within that window is where the two approaches differ.

We define two small functions that operate on a single trace. Both have the same signature — they take a 1D trace array, a scalar pick value, and the twtt coordinate array, and return a scalar twtt value. This means either one can be plugged into the same repick() driver via xr.apply_ufunc.

The driver function repick() uses xr.apply_ufunc to apply either of the above functions across all traces. The input_core_dims=[['twtt'], []] tells xarray to pass each trace as a 1D array and each pick as a scalar. You swap the repicking strategy simply by passing a different func.

Running the repick

Both functions work on the linear-power data (not the dB version). We call repick() with each function — the only thing that changes is which func we pass and any extra keyword arguments it needs.

find_peaks_local takes a rel_prominence parameter that sets the prominence threshold as a fraction of each window’s maximum. This is important because the surface return is orders of magnitude stronger than the bed — an absolute prominence threshold would either accept every noise peak near the surface or reject every real peak near the bed.

Single-trace diagnostic

Before looking at the full flight line, it’s helpful to examine a single trace to understand what the repicking is doing. Here we plot the radar amplitude in a window around the bed pick and mark the peaks that find_peaks identifies:

<Figure size 1000x400 with 1 Axes>

Comparing the results

Let’s compare the original bed picks with the two repicked versions. First a full flight line view, then a zoom:

<Figure size 1500x400 with 2 Axes>
<Figure size 1600x500 with 4 Axes>

Quantifying the difference

It can be helpful to see how much the repicked values differ from the originals. Large differences might indicate either a successful correction or a bad pick that needs manual review.

<Figure size 1400x300 with 2 Axes>
Local max: median shift = 0.1669 μs, mean |shift| = 0.2866 μs, max |shift| = 1.0087 μs
find_peaks: median shift = 0.0675 μs, mean |shift| = 0.1384 μs, max |shift| = 0.8949 μs

Interactive radargram

The plot below uses HoloViews/Bokeh — use the scroll wheel to zoom and drag to pan.

Original picks are shown as dashed lines. Repicked versions are solid: cyan for local max, red for find_peaks.

Loading...