Add validate-sfile, a checker for SW4 velocity models - #137
Draft
lispandfound wants to merge 1 commit into
Draft
Conversation
lispandfound
force-pushed
the
nzvm/sfile-validator
branch
from
September 2, 2026 02:23
b01c0eb to
5664a7d
Compare
lispandfound
force-pushed
the
nzvm/sfile-validator
branch
from
September 2, 2026 02:52
5664a7d to
c904c06
Compare
An sfile that SW4 accepts at load time can still crash it thousands of
steps in, or -- worse -- run to completion having quietly solved the
wrong problem. The failures that cost the most time are all detectable
up front from the file alone:
Structure required groups/attributes, dataset counts match ngrids
Attributes types, value ranges, NaN/Inf
Z_interfaces strict monotonicity at every (i, j), zero/negative
thickness layers (which trigger an hv=0 division in
SW4), large topographic gradients, agreement between the
Min/max depth attribute and the data
Material Rho > 0 (zero density is the most common SW4 crash),
Cp > 0, Cs >= 0, Qp/Qs > 0 under attenuation, Vp/Vs >= 1,
nk >= 2 (nk=1 gives 0*inf=NaN in SW4's interpolation)
Boundaries grid corners in geographic coordinates
Interfaces stored at different resolutions are nearest-resampled onto a
common grid rather than skipped, because crossed and pinched layers
cluster at exactly the grid-refinement boundaries where the resolutions
differ. Nearest, not bilinear: it preserves every stored node value, so
a crossing sitting on a single coarse node is never smoothed away.
Material datasets are scanned in row chunks -- they do not fit in
memory for any real domain.
Standalone: imports nothing from `workflow`, and exits non-zero if any
check reports an error, so it can gate a run.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
lispandfound
force-pushed
the
nzvm/sfile-validator
branch
from
September 4, 2026 01:44
c904c06 to
5bb11e3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an sfile validator, which runs a number of checks over an SW4 velocity model, namely:
ngridcount matches the number of supplied grids.