Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add funwave writer for the WK_NEW_DATA2D wavemaker format#157

Merged
rafa-guedes merged 3 commits into
mainfrom
funwave-new-data2d
Jun 16, 2026
Merged

Add funwave writer for the WK_NEW_DATA2D wavemaker format#157
rafa-guedes merged 3 commits into
mainfrom
funwave-new-data2d

Conversation

@rafa-guedes

Copy link
Copy Markdown
Collaborator

Summary

New to_funwave_new output method on the spec accessor to write spectra as individual wave components in the WaveCompFile format expected by the FUNWAVE-TVD WK_NEW_DATA2D wavemaker (Salatin et al. 2021). Unlike the gridded WK_DATA2D format written by the existing to_funwave, this format describes one wave component per spectral bin.

Details

  • The file layout (NumFreq, PeakPeriod, then blocks of frequencies, directions, amplitudes and an optional block of phases) was verified against the reader implementation in FUNWAVE-TVD src/wavemaker.F and the official examples in simple_cases/wave_coherence, in addition to the manual section.
  • Component amplitudes use the same convention as the existing writer (a = sqrt(8 E df dd) / 2), which FUNWAVE consumes identically in both the WK_DATA2D and WK_NEW_DATA2D wavemakers.
  • phases=False omits the phase block so FUNWAVE generates random phases itself.
  • Directions are converted to the cartesian going-to convention and clipped to [-90, 90] by default, matching the model behaviour which discards components outside that range.
  • 1D spectra and multiple spectra (written into a zip archive) are supported, mirroring to_funwave; the single-file/zip dispatch and direction conversion are factored into a shared _write_funwave helper.

Test plan

  • New tests cover file structure, energy round trip (component amplitudes recover hs(tail=False)), direction clipping, phase omission, multi-spectra zip output and 1D spectra
  • All funwave IO tests pass (10 passed)
  • ruff format clean

🤖 Generated with Claude Code

rafa-guedes and others added 3 commits June 11, 2026 23:30
New to_funwave_new method to write spectra as individual wave components
in the WaveCompFile format expected by the FUNWAVE-TVD WK_NEW_DATA2D
wavemaker. The file layout (NumFreq, PeakPeriod, then blocks of
frequencies, directions, amplitudes and optional phases) follows the
reader implementation in FUNWAVE-TVD src/wavemaker.F and the official
examples in simple_cases/wave_coherence. The existing single-file / zip
dispatch and direction conversion are factored out of to_funwave into a
shared helper.

Co-Authored-By: Claude Fable 5 <[email protected]>
New read_funwave_new function to reconstruct gridded spectra from
FUNWAVE-TVD WK_NEW_DATA2D wave component files, by summing component
energies a^2/2 over the frequency-direction bins defined by the unique
frequencies and directions in the file. The reader lives in its own
input module as required by the read function discovery mechanism, and
is also registered as the funwave_new engine for xr.open_dataset. The
official two-wave example file from the FUNWAVE-TVD repository is added
as a sample file and tested against its analytical Hs.

Co-Authored-By: Claude Fable 5 <[email protected]>
@rafa-guedes rafa-guedes merged commit 1bb774a into main Jun 16, 2026
10 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.

1 participant