Skip to content

Use the receiver half-step fallback for legacy files in the Marimo reader - #887

Merged
agianno merged 1 commit into
gprMax:masterfrom
SajalDevX:fix/marimo-legacy-magnetic-time-offset
Oct 11, 2026
Merged

agianno merged 1 commit into
gprMax:masterfrom
SajalDevX:fix/marimo-legacy-magnetic-time-offset

Conversation

@SajalDevX

Copy link
Copy Markdown
Contributor

Summary

Fixes #886

The Marimo h5_reader defaulted a missing TimeSampleOffset attribute to 0.0 for every receiver component. The Plotting/Utilities toolboxes (trace_time.receiver_time_offset, used by read_time_history, plot_Ascan, plot_Bscan, outputfiles_merge) treat the same legacy datasets as -dt/2 for H*/I*, matching what fields_outputs writes into current files. The Marimo dashboards therefore plotted legacy magnetic-field and current traces half a step late, and subtract_receiver_reference rejected a current-format target against a legacy background with "target and background sample times differ" for H/I components even though the recordings were identical.

What changed

  • gprMax/toolboxes/Marimo/h5_reader.py: when a receiver dataset has no TimeSampleOffset, fall back to receiver_time_offset(component, sample_interval) from gprMax.toolboxes.Utilities.trace_time (in _read_receivers and in the get_time_axis fallback) instead of 0.0. Imports sorted per the pre-commit isort profile; docstring updated.
  • gprMax/toolboxes/Marimo/README.md: one sentence documenting the legacy fallback.
  • Tests:
    • tests/toolboxes/test_marimo_h5_reader.py: new legacy_h5_file fixture (metadata attributes stripped); test_legacy_file_component_time_offset checks component_meta and get_time_axis for E (0) and H (-dt/2); test_legacy_file_matches_current_file_and_plotting_toolbox checks the legacy axis equals both the current-file axis and read_time_history(...).time.
    • tests/toolboxes/test_physical_trace_consumers.py: test_legacy_background_without_sampling_metadata_matches_current_target subtracts a legacy background from a current target for Ez, Hx, Ix.

How tested

  • Before the fix the new H/I cases fail: get_time_axis returns 0.0 for legacy Hx/Hz, and the subtraction test raises ValueError: target and background sample times differ for Hx/Ix (5 failed, 5 passed for -k legacy).
  • After the fix: pytest tests/toolboxes/test_marimo_h5_reader.py tests/toolboxes/test_physical_trace_consumers.py tests/toolboxes/test_plotting_outputs.py tests/toolboxes/test_outputfiles_merge.py -> 111 passed; the Marimo processing/trace-matrix/hyperbola suites also pass (201 passed in total across the Marimo tests).
  • black --line-length 100 and isort --profile black --line-length 100 clean on h5_reader.py and test_marimo_h5_reader.py; only the new lines were touched in test_physical_trace_consumers.py, which already exceeds the 100-column pre-commit setting upstream (pyproject.toml still says 120).

Notes

  • Files written by current gprMax always carry TimeSampleOffset, so their behaviour is unchanged; only legacy/third-party files without per-dataset metadata are affected.
  • get_time_axis without receiver/component still returns the E-field (whole-step) axis, as before.

…ader

The Marimo h5_reader defaulted a missing TimeSampleOffset attribute to 0.0
for every receiver component. Current gprMax files and the Plotting and
Utilities toolboxes place H and I samples at -dt/2 for the same legacy files
(trace_time.receiver_time_offset), so the dashboards plotted legacy magnetic
field and current traces half a step late, and background subtraction between
a current target and a legacy background raised "target and background sample
times differ" for identical H/I recordings.

Reuse receiver_time_offset when per-dataset metadata is absent so all
toolboxes agree on the sample-zero time, and document the fallback.
@agianno
agianno merged commit b3e28b1 into gprMax:master Oct 11, 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.

Marimo h5_reader places legacy H/I receiver samples half a time step late (disagrees with plot_Ascan/trace_time)

2 participants