Skip to content

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

Closed

Description

@SajalDevX

Describe the bug

discover_files in gprMax/toolboxes/Utilities/outputfiles_trace.py finds the A-scan series with glob.glob(basefilename + "*.h5"). Any .h5 file whose name starts with the base name is treated as part of the series, not just <base>1.h5, <base>2.h5, ... So when two series share a prefix in the same folder, the exporters silently mix them into one survey.

This happens with the shipped examples: examples/gpr/basic/cylinder_Bscan_2D.in and examples/gpr/basic/cylinder_Bscan_2D_study.in sit in the same folder. After running both, exporting cylinder_Bscan_2D to SEG-Y, SEG-2 or DT1 also includes every cylinder_Bscan_2D_study<N>.h5 trace. The file is written without any error and the trace count is wrong.

A second, smaller problem: the base name is used as a glob pattern, so a path containing [ or ] (for example a folder run[1]) finds no files and the CLI reports "No original A-scan files match".

To Reproduce

  1. Run both examples in examples/gpr/basic/ (cylinder_Bscan_2D.in -n 60 and cylinder_Bscan_2D_study.in).
  2. python -m gprMax.toolboxes.Utilities.outputfiles_segy examples/gpr/basic/cylinder_Bscan_2D Ez
  3. The output reports 120 traces instead of 60 (the study traces are appended). The same happens with outputfiles_seg2 and outputfiles_dt1.

Smaller version with three files of one series and two of the other:

Code snippets

from gprMax.toolboxes.Utilities.outputfiles_trace import discover_files

# folder contains cylinder_Bscan_2D1..3.h5 and cylinder_Bscan_2D_study1..2.h5
print([p.name for p in discover_files("basic/cylinder_Bscan_2D")])
# ['cylinder_Bscan_2D1.h5', 'cylinder_Bscan_2D2.h5', 'cylinder_Bscan_2D3.h5',
#  'cylinder_Bscan_2D_study1.h5', 'cylinder_Bscan_2D_study2.h5']

# python -m gprMax.toolboxes.Utilities.outputfiles_segy basic/cylinder_Bscan_2D Ez
# Written 5 traces x 50 samples to basic/cylinder_Bscan_2D_Ez.sgy

print(discover_files("br[1]/cylinder_Bscan_2D"))
# []

Expected: only cylinder_Bscan_2D1.h5 to cylinder_Bscan_2D3.h5 (and a single unnumbered cylinder_Bscan_2D.h5 if that is the only run), and paths with brackets should work.

OS

Linux

Python version

Python 3.13

gprMax version

master (15d1aeb)

Activity

  1. KanishJebaMathewM commented on Nov 8, 2026

    @KanishJebaMathewM

    Hi! I'm interested in contributing to gprMax and exploring opportunities for GSoC 2027.

    I wanted to ask whether the gprMax team is planning to participate in Google Summer of Code 2027, and whether there are plans to propose new project ideas for the upcoming edition.

    I understand that official organization selections haven't been announced yet. Just looking for an early indication from the maintainers.

    Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions