-
Notifications
You must be signed in to change notification settings - Fork 259
Description
@ali-ramadhan and I are interesting in expanding FieldTimeSeries to support NetCDF.
None of us is super familiar with FTS, but it seems like, for the most part, all we need would be to figure out a way to reconstruct grids based on NetCDF output and figure out how to deal with memory access if the data is PartlyInMemory. Is that correct or are there other items that we pay attention to?
For the former we can output the relevant grid parameters to file and reconstruct it in a way that's already done for JLD2 whenever the grid can't be restored directly:
Oceananigans.jl/src/OutputReaders/field_time_series.jl
Lines 489 to 529 in 82ad840
| if grid isa RectilinearGrid # we can try... | |
| @info "Initial attempt to transfer grid to $architecture failed." | |
| @info "Attempting to reconstruct RectilinearGrid on $architecture manually..." | |
| Nx = file["grid/Nx"] | |
| Ny = file["grid/Ny"] | |
| Nz = file["grid/Nz"] | |
| Hx = file["grid/Hx"] | |
| Hy = file["grid/Hy"] | |
| Hz = file["grid/Hz"] | |
| xᶠᵃᵃ = file["grid/xᶠᵃᵃ"] | |
| yᵃᶠᵃ = file["grid/yᵃᶠᵃ"] | |
| zᵃᵃᶠ = file["grid/zᵃᵃᶠ"] | |
| x = file["grid/Δxᶠᵃᵃ"] isa Number ? (xᶠᵃᵃ[1], xᶠᵃᵃ[Nx+1]) : xᶠᵃᵃ | |
| y = file["grid/Δyᵃᶠᵃ"] isa Number ? (yᵃᶠᵃ[1], yᵃᶠᵃ[Ny+1]) : yᵃᶠᵃ | |
| z = file["grid/Δzᵃᵃᶠ"] isa Number ? (zᵃᵃᶠ[1], zᵃᵃᶠ[Nz+1]) : zᵃᵃᶠ | |
| topo = topology(grid) | |
| N = (Nx, Ny, Nz) | |
| # Reduce for Flat dimensions | |
| domain = Dict() | |
| for (i, ξ) in enumerate((x, y, z)) | |
| if topo[i] !== Flat | |
| if !(ξ isa Tuple) | |
| chopped_ξ = ξ[1:N[i]+1] | |
| else | |
| chopped_ξ = ξ | |
| end | |
| sξ = (:x, :y, :z)[i] | |
| domain[sξ] = chopped_ξ | |
| end | |
| end | |
| size = Tuple(N[i] for i=1:3 if topo[i] !== Flat) | |
| halo = Tuple((Hx, Hy, Hz)[i] for i=1:3 if topo[i] !== Flat) | |
| RectilinearGrid(architecture; size, halo, topology=topo, domain...) | |
| else | |
| throw(err) | |
| end |
We were also wondering if this is worth doing over one PR and a few small ones.
cc @glwagner