Skip to content

Match only the named series when exporting A-scan files - #953

Merged
agianno merged 2 commits into
gprMax:masterfrom
SajalDevX:fix/trace-export-series-discovery
Nov 12, 2026
Merged

agianno merged 2 commits into
gprMax:masterfrom
SajalDevX:fix/trace-export-series-discovery

Conversation

@SajalDevX

Copy link
Copy Markdown
Contributor

Fixes #952

The SEG-Y, SEG-2 and DT1 exporters find their input series with discover_files, which globbed basefilename + "*.h5". Any HDF5 file starting with the base name was exported as a trace, so running the two shipped examples cylinder_Bscan_2D.in and cylinder_Bscan_2D_study.in in examples/gpr/basic/ and then exporting cylinder_Bscan_2D silently appended all the study traces. The base name was also used as a glob pattern, so a folder like run[1] found nothing.

Changes:

  • discover_files now escapes the base name for glob and keeps only files whose stem is the base name followed by an optional run number. The old _merged exclusion is covered by this.
  • Added a CLI regression test in tests/toolboxes/test_outputfiles_segy.py with a second series sharing the prefix, run once in a plain folder and once in a folder with brackets.

Testing:

  • New test fails on master (assert 5 == 3 for the plain folder, no files found for survey[1]) and passes with the fix.
  • pytest tests/toolboxes/test_outputfiles_segy.py tests/toolboxes/test_outputfiles_seg2.py tests/toolboxes/test_outputfiles_dt1.py: 37 passed.
  • Checked the SEG-Y and SEG-2 CLIs by hand on the two-series folder: both now write 3 traces instead of 5.

outputfiles_merge.py has the same glob(basefilename + "*.h5") pattern in its __main__ block. I left it alone here to keep this small, but I can follow up if you want the same rule there.

discover_files globbed basefilename + "*.h5", so any HDF5 file whose name
started with the base name was exported as a trace. With the shipped
cylinder_Bscan_2D and cylinder_Bscan_2D_study examples run in the same folder,
exporting cylinder_Bscan_2D to SEG-Y, SEG-2 or DT1 silently added the study
traces. The base name was also used as a glob pattern, so a path containing
[ or ] found no files.

Escape the base name and accept only stems that are the base name followed by
an optional run number.
rehanxt5 pushed a commit to rehanxt5/gprMax that referenced this pull request Nov 10, 2026
…mponents

test_rotated_virtual_fields[True-double-+-1-2-TE] failed twice on hosted CI
(PRs gprMax#953 and gprMax#955, neither of which touches the solver) with a "relative
error" of 2e-3 while the actual difference between the reference and virtual
runs was ~5e-13 on a field of amplitude 216. The comparison scaled each trace
component by its own peak with a floor of 1e-12 of the global peak, so the
three identically-zero out-of-plane components of a reduced 2D run were
compared against an absolute tolerance of ~4e-18, far below double round-off.
Any residual there, however small, failed the test. The divergence itself only
appears on the hosted runners and could not be reproduced locally with MKL or
OpenBLAS numpy, any thread count, repeated in-process runs or CPU contention.

Add normalized_trace_error() to the 2D validation module: components that
carry signal are still scaled by their own peak, while components whose
reference peak is below 1e-6 of the global peak are measured against the global
peak. Use it in the three tests that shared the old floor, and hold the
inactive grid components of the reduced run to the same round-off bound
instead of exact zero.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@agianno

agianno commented Nov 11, 2026

Copy link
Copy Markdown
Member

The implementation looks correct and fixes a genuine file-series mixing problem. Our independent discovery, ordering, CLI and simulation-export checks found no regression.

Before merging, please update from current master to include #956’s SIBC comparison-test correction and obtain green CI on the updated candidate. The existing failed CPU test does not call the changed exporter code. No exporter or waveport-physics change is requested.

@SajalDevX

Copy link
Copy Markdown
Contributor Author

Thanks @agianno! Updated from master so it now includes #956. I'll keep an eye on CI.

@agianno
agianno merged commit 2ac28bd into gprMax:master Nov 12, 2026
14 checks passed
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.

SEG-Y/SEG-2/DT1 exporters pick up other output series that share the base name

2 participants