Oceananigans.jl
Oceananigans.jl copied to clipboard
Extend `NetCDFWriter` to support `TripolarGrid` and `MutableVerticalDiscretization`
@ali-ramadhan, @tomchor, and the team did an outstanding job revamping the NetCDFWriter in PR #4046.
I’d like to build on that work and extend NetCDFWriter to support:
- Tripolar grids (
TripolarGrid) - Z-star vertical coordinates (
MutableVerticalDiscretization)
Current Limitation
At the moment, NetCDFWriter cannot even be defined if the grid uses either of these two features.
Before PR #4046, it was at least possible to write NetCDFs for these grids (definitely for 2, possibly for 1), though grid metrics were not included.
Proposed Plan
I suggest a two-step approach:
A. Enable NetCDFWriter for tripolar grids and z-star coordinates
- This step ensures
NetCDFWritercan handle these grids, without writing out grid metrics.
B. Extend NetCDFWriter to include grid metrics
- For
MutableVerticalDiscretization, writing Δz may be tricky since it changes at each time step.
Since step A seems more straightforward, I propose tackling that first.
Any immediate thoughts on this plan, @ali-ramadhan, @tomchor? (If you're interested in helping out, that would be appreciated as well. :)) I’m also tagging @simone-silvestri, who has led the work on 1. and 2. (if I’m not mistaken).
Note JLD2Writer also needs to implement a design that saves down the fluctuating grid metrics at each save point (also, FieldTimeSeries should work properly, and that requires also making space for a time-series of the fluctuating / mutable grid metrics).
also, FieldTimeSeries should work properly, and that requires also making space for a time-series of the fluctuating / mutable grid metrics
Just to clarify: When you say "FieldTimeSeries should work properly," do you mean that it currently doesn't work as expected?
I suggest a two-step approach:
A. Enable
NetCDFWriterfor tripolar grids and z-star coordinates* This step ensures `NetCDFWriter` can handle these grids, **without** writing out grid metrics.
I agree this makes sense as a first step as it should be on the simple side. I'd recommend dedicating a PR solely for that.
B. Extend
NetCDFWriterto include grid metrics* For `MutableVerticalDiscretization`, writing Δz may be tricky since it changes at each time step.
I can't talk about the computation of metrics here, but after they're computed, the writing should be relatively straightforward since they can be written just like any other time-evolving variable. As @glwagner mentioned though, the JLD2Writer also needs this, so it would be nice to coordinate there somehow.
(If you're interested in helping out, that would be appreciated as well. :))
I'd be happy to help out if I can. That said, I haven't used tripolar or mutable vertical coordinate grids before so I'm not sure how useful I can be haha
Just to clarify: When you say "FieldTimeSeries should work properly," do you mean that it currently doesn't work as expected?
Yeah, at the moment FieldTimeSeries does not account for changing grid metrics so even if u (for example) is a FieldTimeSeries on a zstar grid
u[1].grid == u[2].grid
I think that the metrics should be saved like fields are saved, using the same syntax. Currently output writers save down the time at which data is saved. On a grid that has MutableVerticalDiscretization, it should also save the vertical discretization (or information that can be used to construct it) at the same times.
I think that the metrics should be saved like fields are saved, using the same syntax. Currently output writers save down the time at which data is saved. On a grid that has MutableVerticalDiscretization, it should also save the vertical discretization (or information that can be used to construct it) at the same times.
That makes sense.
I think I will first start working on a PR that enables the NetCDFWriter for TripolarGrid without MutableVerticalDiscretization.
As a next step, we can coordinate an effort for JLD2Writer, FielTimeSeries, and NetCDFWriter to output/use the vertically changing grid metrics correctly for MutableVerticalDiscretization.
maybe two efforts:
- support tripolar grid with netcdf
- interface for saving time-dependent metrics in jld2writer
then
- extend interface for time dependent metrics to netcdf
Just resurfacing this as I posted an issue to add support for OrthogonalSphericalGrids more generally (including TripolarGrid) to NetCDFWriter. @NoraLoose did you end up working on this?
@NoraLoose did you end up working on this?
@vtamsitt, I got distracted by other things, so didn't end up working on this.
@NoraLoose did you end up working on this?
@vtamsitt, I got distracted by other things, so didn't end up working on this.
Thanks @NoraLoose, no worries. I'm drafting a PR for this and seems like just adding OrthogonalSphericalGrids will be fairly straightforward.