-
Notifications
You must be signed in to change notification settings - Fork 230
Unable to output η using NetCDFWriter #4384
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
Comments
Hi @HXC303! Apologies for the oversight here. We recently refactored For now you can output Oceananigans.jl/test/test_netcdf_writer.jl Lines 2530 to 2645 in a84b3f8
|
Now that's what I call a workaround What is the challenge here? Is it that we can't properly compute the intersection of indices? |
I don't think there's really a challenge, just an oversight on my part in that I forgot to fix this behavior by dispatching on I suppose this was antithetical to test-driven development. I should have let the test keep failing so that I actually fix the code! |
Well, that is good news then that ultimately it's a simple thing to fix! |
(#3260 might be related; at least the initial motivation was the same: trying to save free surface wasn't working) |
Does #4401 fix it? |
Ok it doesn't fix it for me -- basically NetCDFWriter does not seem to support windowed fields, if I am not mistaken. cc @tomchor @ali-ramadhan |
this looks bad to me: Oceananigans.jl/ext/OceananigansNCDatasetsExt.jl Lines 57 to 65 in bd708ef
shouldn't we be using Oceananigans.jl/src/OutputWriters/output_construction.jl Lines 33 to 43 in bd708ef
|
I'm starting to look into this issue. Indeed not supporting using Oceananigans
using Oceananigans.Fields: WindowedField
grid = LatitudeLongitudeGrid(CPU();
topology = (Bounded, Bounded, Bounded),
size = (8, 8, 4),
halo = (3, 4, 2),
longitude = (-1, 1),
latitude = (-1, 1),
z = (-100, 0)
)
model = HydrostaticFreeSurfaceModel(; grid,
closure = ScalarDiffusivity(ν=4e-2, κ=4e-2),
buoyancy = SeawaterBuoyancy(),
tracers = (:T, :S)
) julia> model.free_surface.η isa WindowedField
false PS: Agree that we should be using |
Based on these definitions: Oceananigans.jl/src/Fields/field.jl Lines 21 to 35 in dfe0b6e
Oceananigans.jl/src/Fields/field.jl Lines 357 to 358 in dfe0b6e
shouldn't a const WindowedField = Field{<:Any, <:WindowedData, <:Any, <:Any, <:Any, <:Any, <:Any} Looking through the tests, no test explicitly tests for this and it seems like reductions on EDIT: This post is wrong. It's const WindowedField = Field{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:WindowedData} is correct. |
Hmmm, maybe the distinction is that the free surface has at least one julia> typeof(model.velocities.u.data)
OffsetArrays.OffsetArray{Float64, 3, Array{Float64, 3}}
julia> typeof(model.free_surface.η.data)
OffsetArrays.OffsetArray{Float64, 3, Array{Float64, 3}} but julia> typeof(model.velocities.u.indices)
Tuple{Colon, Colon, Colon}
julia> typeof.(model.free_surface.η.indices)
(Colon, Colon, UnitRange{Int64}) So if If we can decide what type of field |
I think you're right, it looks like |
I don't really see Oceananigans.jl/test/test_field.jl Lines 477 to 492 in dfe0b6e
Should we define a new type of const XWindowedIndices = Tuple{<:UnitRange, Colon, Colon}
const YWindowedIndices = Tuple{Colon, <:UnitRange, Colon}
const ZWindowedIndices = Tuple{Colon, Colon, <:UnitRange}
const XYWindowedIndices = Tuple{<:UnitRange, <:UnitRange, Colon}
const XZWindowedIndices = Tuple{<:UnitRange, Colon, <:UnitRange}
const YZWindowedIndices = Tuple{Colon, <:UnitRange, <:UnitRange}
const XYZWindowedIndices = Tuple{<:UnitRange, <:UnitRange, <:UnitRange}
const WindowedIndices = Union{XWindowedIndices, YWindowedIndices, ZWindowedIndices, XYWindowedIndices, XZWindowedIndices, YZWindowedIndices, XYZWindowedIndices}
const WindowedField = Field{<:Any, <:Any, <:Any, <:Any, <:Any, <:WindowedIndices} ? I guess either way something like this definition using |
If we don't need the definition then its best not to introduce needless code, perhaps? |
Hmmm, the way I see it it's either dispatch on a definition or do if statements on |
That makes sense, just trying to understand. Where in |
It may be easier / cleaner to special case the non-windowed case with |
I’m trying to output the free surface η using NetCDFWriter, but I encountered an error. Below is an example:
This results in the error:
I also tried specifying:
indices=(:,:,grid.Nz+1)
,but then got:I attempted with_halos=true, but that led to:
How can I correctly output the η variable with NetCDFWriter?
The text was updated successfully, but these errors were encountered: