Skip to content

Match only the named series when merging output files - #970

Merged
agianno merged 1 commit into
gprMax:masterfrom
SajalDevX:fix/merge-series-discovery
Nov 17, 2026
Merged

agianno merged 1 commit into
gprMax:masterfrom
SajalDevX:fix/merge-series-discovery

Conversation

@SajalDevX

Copy link
Copy Markdown
Contributor

Fixes #969

Follow-up to #953. The outputfiles_merge command line still found its inputs with glob(basefilename + "*.h5"), so any HDF5 file starting with the base name was merged as a trace. Next to another plain run such as cylinder_Bscan_2D_wet, merging cylinder_Bscan_2D silently added the extra traces and --remove-files deleted that other series too. Next to the shipped cylinder_Bscan_2D_study outputs the documented merge command failed with "Receiver identity StudyID differs between files". A base path containing [ or ] found nothing.

Changes:

  • The CLI now uses discover_files from outputfiles_trace.py, the same rule the SEG-Y, SEG-2 and DT1 exporters use since Match only the named series when exporting A-scan files #953: the base name is escaped and only stems made of the base name plus an optional run number are accepted. The old _merged exclusion and natural sort are covered by it, and the -o destination is still skipped. merge_files itself is unchanged.
  • Added a CLI regression test in tests/toolboxes/test_outputfiles_merge.py with a second series sharing the prefix, run with --remove-files in a plain folder and in a folder with brackets.

Testing:

  • New test fails on master (assert (3, 5) == (3, 3) for the plain folder, exit status 2 for survey[1]) and passes with the fix.
  • pytest tests/toolboxes/test_outputfiles_merge.py tests/toolboxes/test_outputfiles_segy.py tests/toolboxes/test_outputfiles_seg2.py tests/toolboxes/test_outputfiles_dt1.py tests/toolboxes/test_output_path_safety.py tests/toolboxes/test_plotting_outputs.py tests/toolboxes/test_receiver_identity.py: 117 passed, 1 skipped (reframe not installed).
  • Checked with real gprMax runs: cylinder_Bscan_2D -n 3 plus a 2-trace cylinder_Bscan_2D_wet run now merges 3 traces and leaves the wet files in place. With both shipped examples run in one folder, merging cylinder_Bscan_2D and cylinder_Bscan_2D_study each gives 60 traces, and a br[1] folder works.

The outputfiles_merge command line globbed basefilename + "*.h5", so any
HDF5 file whose name started with the base name was merged as a trace.
Merging cylinder_Bscan_2D next to a cylinder_Bscan_2D_wet run silently
produced a B-scan with the extra traces, and --remove-files then deleted
the other series too. Next to the shipped cylinder_Bscan_2D_study outputs
the documented command failed with "Receiver identity StudyID differs
between files". The base name was also used as a glob pattern, so a path
containing [ or ] found no files.

Use discover_files, which the SEG-Y, SEG-2 and DT1 exporters already use,
so only the base name followed by an optional run number is merged.
@agianno

agianno commented Nov 17, 2026

Copy link
Copy Markdown
Member

Thanks—this is a focused correction that reuses the existing series-discovery helper. Our tests confirmed that unrelated study files are neither merged nor deleted, including paths containing literal brackets.

Real 3D, TM and two-cell TE scans preserved all merged field samples exactly. The merge implementation and solver physics are unchanged. Looks suitable to merge.

@agianno
agianno merged commit 7298a1c into gprMax:master Nov 17, 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.

outputfiles_merge merges (and with --remove-files deletes) other output series that share the base name

2 participants