Skip to content

Fix how NetCDFWriter outputs free surface height η #4567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

ali-ramadhan
Copy link
Member

@ali-ramadhan ali-ramadhan commented May 30, 2025

Resolves #4384

I believe the changes in this PR do fix the main issue of NetCDF output for the free surface height not working. But I'm not quite happy with this solution so I've opened a draft PR for now.

While there should be better support for windowed field output, I ended up having to explicitly check for the free surface =/ Been also wondering if it's almost easier and cleaner to just special case the free surface just like how we do for LagrangianParticles.

NetCDF tests passed locally but I will revisit this PR soon with a fresh mind.

Some potential immediate changes/improvements:

# Kind of a hack because we want η to be a ReducedField.
free_surface_outputs = (;
η = Average(model.free_surface.η, dims=3),
η = model.free_surface.η,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@navidcy
Copy link
Member

navidcy commented Jul 6, 2025

One of the tests fail at

# Data is saved without halos
wu = file["timeseries/wu/4"][1, 1, 3]
uv = file["timeseries/uv/4"][1, 1, 3]
wT = file["timeseries/wT/4"][1, 1, 3]

because of how the data is shaped now.

Changing to

 wu = file["timeseries/wu/4"][3] 
 uv = file["timeseries/uv/4"][3] 
 wT = file["timeseries/wT/4"][3] 

allows the test to pass. But is this intentional? If so, there are more things that needed to be tweaked later in OutputReaders because FieldTimeSeries assume that all dimensions are present, even if with size = 1.

@navidcy
Copy link
Member

navidcy commented Jul 6, 2025

Btw I've noticed that the changes in this PR affect also the JLD2 output writer; so perhaps the title needs updating?

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

Successfully merging this pull request may close these issues.

Unable to output η using NetCDFWriter
3 participants