Skip to content

Fix silent wrong-data bugs: read_segy on pre-stack files, plan cache key, plan stage geometry - #10

Merged
GeophyAI merged 2 commits into
mainfrom
fix/silent-data-bugs
Oct 24, 2026
Merged

GeophyAI merged 2 commits into
mainfrom
fix/silent-data-bugs

Conversation

@GeophyAI

Copy link
Copy Markdown
Collaborator

Three bugs that let a run finish without an error while reading the wrong data or starting from the wrong model/geometry.

  • read_segy on pre-stack files: segyio's f.trace[:] reuses two buffers, so on any unstructured file (pre-stack gathers, write_segy output) every row came back as a copy of the last or second-to-last trace. Unstructured files now read f.trace.raw[:]; structured files still use cube, without the blanket except.
  • obs.plan materialize cache key: it named the vp source only by path/dataset/constant, so changing linear_gradient (or shape, smoothing, grid.dh, the source lift, a non-vp model, an .npy rewritten in place) hit the old cache entry and the run started from the cached model. The key now covers every init model's spec, file size/mtime, grid.dh and the lift. Existing .materialize_cache directories are invalidated once.
  • Stage geometry on the plan route: stages re-snapped positions that were already rounded to the native 12.5 m grid, so on coarse stages shots merged (Viking at 25 m: 1001 shots into 503 cells). materialize now also returns the un-rounded positions and the stage geometry is built from them, as on the SEG-Y route. Multi-stage from_plan results change accordingly and now match the SEG-Y route.

Tested: 7 new tests (the 6 bug tests fail on main); full tests/ on a V100 and on CPU with no other change; on the Viking line, read_segy matches SEGYReader on all 120,120 traces and the stage source cells match the SEG-Y route at every grid from 75 m to 12.5 m.

🤖 Generated with Claude Code

segyio's f.trace[:] reuses two buffers, so the fallback np.stack gave every
row the last or second-to-last trace on any unstructured file (pre-stack
gathers, write_segy output), with no error. Unstructured files now read
f.trace.raw[:]; structured ones still go through cube, without the blanket
except. Round-trip tests; the Viking line now matches SEGYReader on all
120120 traces.
- The cache key named the vp source only by path/dataset/constant, so a
  linear_gradient change (also shape, smoothing, grid.dh, lift, non-vp
  models, an .npy rewritten in place) hit the old entry and the run started
  from the cached model. Key on every init model's spec plus file
  size/mtime, grid.dh and the lift.
- Stages re-snapped the 12.5 m-rounded positions: at 25 m Viking's 1001
  shots merged into 503 cells, 168 moved at 75/15 m. materialize now also
  returns (and caches) the un-rounded positions and fwi builds the stage
  geometry from them, as the SEG-Y route does.
@GeophyAI
GeophyAI merged commit 7fcd5db into main Oct 24, 2026
7 checks passed
@GeophyAI
GeophyAI deleted the fix/silent-data-bugs branch October 25, 2026 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant