Summary
Both write_restart_file and write_partial_restart_file in src/roguewave/wavewatch3/io.py validate the spectra array's directions axis (shape[2]) against parent_restart_file.number_of_frequencies instead of number_of_directions:
Impact
For any grid where number_of_frequencies != number_of_directions, writing a valid spectra array of the correct shape raises a spurious ValueError. Conversely, if a future change ever produced a genuinely wrong-shaped directions axis that happened to equal the frequency count, this check would silently pass instead of catching it.
Why this was never caught
tests/restart_files/'s fixture restart file has number_of_frequencies == number_of_directions == 36 (see test_number_of_directions/test_number_of_frequencies in test_restart_file.py), so shape[2] != number_of_frequencies and shape[2] != number_of_directions are indistinguishable for that fixture. Neither test_io.py's write_partial_restart_file/reassemble_restart_file_from_parts tests nor anything else in the suite exercises a grid with unequal counts.
Real-world reproduction
Sofar's own esm-run-scripts/preprocess_waves/setup/containerized/grid.sh defines grid configs with frequency_bins=50, direction_bins=36 — writing a restart against one of these would trip this bug today.
Suggested fix
Change shape[2] != parent_restart_file.number_of_frequencies to shape[2] != parent_restart_file.number_of_directions in both functions, and add a test fixture (or a second synthetic grid) with n_freq != n_dir so this class of bug can't hide again.
Summary
Both
write_restart_fileandwrite_partial_restart_fileinsrc/roguewave/wavewatch3/io.pyvalidate the spectra array's directions axis (shape[2]) againstparent_restart_file.number_of_frequenciesinstead ofnumber_of_directions:write_restart_file, lines 177–179write_partial_restart_file, lines 254–256Impact
For any grid where
number_of_frequencies != number_of_directions, writing a valid spectra array of the correct shape raises a spuriousValueError. Conversely, if a future change ever produced a genuinely wrong-shaped directions axis that happened to equal the frequency count, this check would silently pass instead of catching it.Why this was never caught
tests/restart_files/'s fixture restart file hasnumber_of_frequencies == number_of_directions == 36(seetest_number_of_directions/test_number_of_frequenciesintest_restart_file.py), soshape[2] != number_of_frequenciesandshape[2] != number_of_directionsare indistinguishable for that fixture. Neithertest_io.py'swrite_partial_restart_file/reassemble_restart_file_from_partstests nor anything else in the suite exercises a grid with unequal counts.Real-world reproduction
Sofar's own
esm-run-scripts/preprocess_waves/setup/containerized/grid.shdefines grid configs withfrequency_bins=50, direction_bins=36— writing a restart against one of these would trip this bug today.Suggested fix
Change
shape[2] != parent_restart_file.number_of_frequenciestoshape[2] != parent_restart_file.number_of_directionsin both functions, and add a test fixture (or a second synthetic grid) withn_freq != n_dirso this class of bug can't hide again.