Repository navigation
Use the solver's iteration count for plot_source_wave time windows - #875
Conversation
|
Thanks—the change to ceil correctly matches the solver’s time-window-to-iteration calculation. Further checking found two pre-existing issues, not regressions introduced by this PR, which would be useful to address here:
With these additions and tests, this would cover both the iteration-count discrepancy and the related preview edge cases. |
|
Thanks for checking this so carefully. I've pushed a follow-up commit covering all three points:
|
|
Thanks—all three requested changes look correct. I independently verified the regression tests against the old and updated code, and the related local tests pass. |
check_timewindow rounded timewindow/dt to the nearest integer, but #time_window has used ceil since b2c3e54 so the simulation always reaches the requested time. With the README example (6 ns, dt 1.926 ps) the tool plotted 3116 samples ending at 5.9995 ns while gprMax runs 3117. Use the same ceil formula so the plotted window matches the model.
Build the time axis as np.arange(iterations, dtype=float) * dt instead of np.linspace. With iterations=234 and dt=1e-12 linspace put the second sample at 9.999999999999998e-13, just below dt, so the impulse evaluator returned 1 at both of the first two samples. When the requested FFT range covers every nonnegative frequency, end the plotted range after the last nonnegative-frequency index rather than at len(freqs) // 2, which dropped the last positive bin for odd lengths (e.g. nine samples have five nonnegative bins but only four were shown). Document that the tool previews the waveform formula on whole timesteps and does not read simulation outputs or reproduce each source's sampling and gating, so output files keep their own lengths and alignment. Add tests for the plotted impulse and for the FFT range with odd and even sample counts.
27d531e to
4438ea0
Compare
|
Thanks for verifying them. I've rebased the branch onto master and resolved the conflict in |
Fixes #874
plot_source_wave.check_timewindowworked out the number of iterations for a time window in seconds withround_value(timewindow / dt) + 1. The solver's#time_windowhas usedint(np.ceil(time / dt)) + 1since b2c3e54, so the tool could use one iteration fewer than the model. When that happens the plotted waveform stops before the requested window and the logged iteration count is wrong. The README example (6 ns, dt = 1.926 ps) plots 3116 samples ending at 5.9995 ns, while gprMax runs 3117.Changes:
check_timewindownow uses the same ceil formula asTimeWindow.build. Theround_valueimport was only used there, so I removed it.test_plot_source_wave_time_window_matches_solvertotests/toolboxes/test_plotting_outputs.py. It builds aTimeWindowon a stub model and checks thatcheck_timewindowgives the same iteration count, and that the last sample reaches the requested time.Testing:
pytest tests/toolboxes/test_plotting_outputs.py: 5 passed. Before the fix, the new test fails for both cases (3116 == 3117,2728 == 2729).pytest tests/waveforms/test_gauspulse_workflow.py -k standard_plotting tests/utilities/test_toolbox_namespace.py: passed.