Skip to content
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

(0.93.0) Use with_halos=true default for JLD2OutputWriter #3860

Merged
merged 29 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c41b892
Use `with_halos=true` default for `JLD2OutputWriter`
glwagner Oct 23, 2024
9496dbf
Update jld2_output_writer.jl
glwagner Oct 23, 2024
ce6a49e
using makie ext
navidcy Oct 24, 2024
91c2ca0
Merge branch 'main' into glw/with-halos
navidcy Oct 24, 2024
1325c8c
more makie ext
navidcy Oct 24, 2024
1cfc066
drop oceananigans from docs toml
navidcy Oct 24, 2024
9f45fdb
no need to find nodes
navidcy Oct 24, 2024
f6813fc
use makie ext
navidcy Oct 24, 2024
c691093
Update src/OutputWriters/jld2_output_writer.jl
navidcy Oct 24, 2024
ed29176
Add with_halos=false to simulation test
glwagner Oct 24, 2024
325e22e
Update doctests
glwagner Oct 24, 2024
91f42cf
Merge branch 'main' into glw/with-halos
glwagner Oct 24, 2024
94230be
drop nodes
navidcy Oct 24, 2024
4dc17f8
Merge branch 'glw/with-halos' of github.com:CliMA/Oceananigans.jl int…
navidcy Oct 24, 2024
c411449
convert doctests with file size output to examples
navidcy Oct 24, 2024
6001867
Revert "convert doctests with file size output to examples"
navidcy Oct 24, 2024
d652658
Reapply "convert doctests with file size output to examples"
navidcy Oct 24, 2024
013723a
Merge branch 'main' into glw/with-halos
glwagner Oct 24, 2024
2dc7c8d
fix example
navidcy Oct 25, 2024
f9a0579
Merge branch 'main' into glw/with-halos
navidcy Oct 25, 2024
5c43c86
bump minor release
navidcy Oct 25, 2024
9e8894d
fix docstring
navidcy Oct 25, 2024
a9e6c61
Apply suggestions from code review
navidcy Oct 25, 2024
2dda34e
homogenize examples
navidcy Oct 25, 2024
3e0e995
fix docs built
navidcy Oct 26, 2024
9bf438e
use absolute path
navidcy Oct 26, 2024
7e0cf77
use relative paths in show
navidcy Oct 26, 2024
e4abf08
Merge branch 'main' into glw/with-halos
navidcy Oct 26, 2024
fa89b25
Merge branch 'main' into glw/with-halos
navidcy Oct 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions examples/horizontal_convection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,6 @@ b_timeseries = FieldTimeSeries(saved_output_filename, "b")
ζ_timeseries = FieldTimeSeries(saved_output_filename, "ζ")

times = b_timeseries.times

## Coordinate arrays
xc, yc, zc = nodes(b_timeseries[1])
xζ, yζ, zζ = nodes(ζ_timeseries[1])
nothing #hide

χ_timeseries = deepcopy(b_timeseries)
Expand Down Expand Up @@ -329,4 +325,3 @@ lines!(ax_Nu, t, Nu; linewidth = 3)

current_figure() #hide
fig

32 changes: 9 additions & 23 deletions examples/internal_tide.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,20 +206,6 @@ wmax = maximum(abs, w_t[end])
times = u′_t.times
nothing #hide

# We retrieve each field's coordinates and convert from meters to kilometers.

xu, _, zu = nodes(u′_t[1])
xw, _, zw = nodes(w_t[1])
xN², _, zN² = nodes(N²_t[1])

xu = xu ./ 1e3
xw = xw ./ 1e3
xN² = xN² ./ 1e3
zu = zu ./ 1e3
zw = zw ./ 1e3
zN² = zN² ./ 1e3
nothing #hide

# ## Visualize

# Now we can visualize our resutls! We use `CairoMakie` here. On a system with OpenGL
Expand All @@ -235,29 +221,29 @@ n = Observable(1)
title = @lift @sprintf("t = %1.2f days = %1.2f T₂",
round(times[$n] / day, digits=2) , round(times[$n] / T₂, digits=2))

u′n = @lift u′_t[$n]
wn = @lift w_t[$n]
n = @lift N²_t[$n]
u′ = @lift u′_t[$n]
wₙ = @lift w_t[$n]
= @lift N²_t[$n]

axis_kwargs = (xlabel = "x [km]",
ylabel = "z [km]",
limits = ((-grid.Lx/2e3, grid.Lx/2e3), (-grid.Lz/1e3, 0)), # note conversion to kilometers
axis_kwargs = (xlabel = "x [m]",
ylabel = "z [m]",
limits = ((-grid.Lx/2, grid.Lx/2), (-grid.Lz, 0)),
titlesize = 20)

fig = Figure(size = (700, 900))

fig[1, :] = Label(fig, title, fontsize=24, tellwidth=false)

ax_u = Axis(fig[2, 1]; title = "u'-velocity", axis_kwargs...)
hm_u = heatmap!(ax_u, xu, zu, u′n; nan_color=:gray, colorrange=(-umax, umax), colormap=:balance)
hm_u = heatmap!(ax_u, u′ₙ; nan_color=:gray, colorrange=(-umax, umax), colormap=:balance)
Colorbar(fig[2, 2], hm_u, label = "m s⁻¹")

ax_w = Axis(fig[3, 1]; title = "w-velocity", axis_kwargs...)
hm_w = heatmap!(ax_w, xw, zw, wn; nan_color=:gray, colorrange=(-wmax, wmax), colormap=:balance)
hm_w = heatmap!(ax_w, wₙ; nan_color=:gray, colorrange=(-wmax, wmax), colormap=:balance)
Colorbar(fig[3, 2], hm_w, label = "m s⁻¹")

ax_N² = Axis(fig[4, 1]; title = "stratification N²", axis_kwargs...)
hm_N² = heatmap!(ax_N², xN², zN², N²n; nan_color=:gray, colorrange=(0.9Nᵢ², 1.1Nᵢ²), colormap=:magma)
hm_N² = heatmap!(ax_N², N²ₙ; nan_color=:gray, colorrange=(0.9Nᵢ², 1.1Nᵢ²), colormap=:magma)
Colorbar(fig[4, 2], hm_N², label = "s⁻²")

fig
Expand Down
34 changes: 16 additions & 18 deletions examples/langmuir_turbulence.jl
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,6 @@ time_series = (;
wv = FieldTimeSeries("langmuir_turbulence_averages.jld2", "wv"))

times = time_series.w.times
xw, yw, zw = nodes(time_series.w)
xu, yu, zu = nodes(time_series.u)
nothing #hide

# We are now ready to animate using Makie. We use Makie's `Observable` to animate
Expand Down Expand Up @@ -309,43 +307,43 @@ nothing #hide

wₙ = @lift time_series.w[$n]
uₙ = @lift time_series.u[$n]
Bₙ = @lift time_series.B[$n][1, 1, :]
Uₙ = @lift time_series.U[$n][1, 1, :]
Vₙ = @lift time_series.V[$n][1, 1, :]
wuₙ = @lift time_series.wu[$n][1, 1, :]
wvₙ = @lift time_series.wv[$n][1, 1, :]
Bₙ = @lift view(time_series.B[$n], 1, 1, :)
Uₙ = @lift view(time_series.U[$n], 1, 1, :)
Vₙ = @lift view(time_series.V[$n], 1, 1, :)
wuₙ = @lift view(time_series.wu[$n], 1, 1, :)
wvₙ = @lift view(time_series.wv[$n], 1, 1, :)

k = searchsortedfirst(grid.zᵃᵃᶠ[:], -8)
wxyₙ = @lift interior(time_series.w[$n], :, :, k)
wxzₙ = @lift interior(time_series.w[$n], :, 1, :)
uxzₙ = @lift interior(time_series.u[$n], :, 1, :)
wxyₙ = @lift view(time_series.w[$n], :, :, k)
wxzₙ = @lift view(time_series.w[$n], :, 1, :)
uxzₙ = @lift view(time_series.u[$n], :, 1, :)

wlims = (-0.03, 0.03)
ulims = (-0.05, 0.05)

lines!(ax_B, Bₙ, zu)
lines!(ax_B, Bₙ)

lines!(ax_U, Uₙ, zu; label = L"\bar{u}")
lines!(ax_U, Vₙ, zu; label = L"\bar{v}")
lines!(ax_U, Uₙ; label = L"\bar{u}")
lines!(ax_U, Vₙ; label = L"\bar{v}")
axislegend(ax_U; position = :rb)

lines!(ax_fluxes, wuₙ, zw; label = L"mean $wu$")
lines!(ax_fluxes, wvₙ, zw; label = L"mean $wv$")
lines!(ax_fluxes, wuₙ; label = L"mean $wu$")
lines!(ax_fluxes, wvₙ; label = L"mean $wv$")
axislegend(ax_fluxes; position = :rb)

hm_wxy = heatmap!(ax_wxy, xw, yw, wxyₙ;
hm_wxy = heatmap!(ax_wxy, wxyₙ;
colorrange = wlims,
colormap = :balance)

Colorbar(fig[1, 3], hm_wxy; label = "m s⁻¹")

hm_wxz = heatmap!(ax_wxz, xw, zw, wxzₙ;
hm_wxz = heatmap!(ax_wxz, wxzₙ;
colorrange = wlims,
colormap = :balance)

Colorbar(fig[2, 3], hm_wxz; label = "m s⁻¹")

ax_uxz = heatmap!(ax_uxz, xu, zu, uxzₙ;
ax_uxz = heatmap!(ax_uxz, uxzₙ;
colorrange = ulims,
colormap = :balance)

Expand Down
8 changes: 3 additions & 5 deletions src/OutputWriters/jld2_output_writer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ext(::Type{JLD2OutputWriter}) = ".jld2"
JLD2OutputWriter(model, outputs; filename, schedule,
dir = ".",
indices = (:, :, :),
with_halos = false,
with_halos = true,
array_type = Array{Float64},
file_splitting = NoFileSplitting(),
overwrite_existing = false,
Expand Down Expand Up @@ -71,9 +71,7 @@ Keyword arguments
will save xy-slices of the bottom-most index.

- `with_halos` (Bool): Whether or not to slice halo regions from fields before writing output.
Note, that to postprocess saved output (e.g., compute derivatives, etc)
information about the boundary conditions is often crucial. In that case
you might need to set `with_halos = true`.
Preserving halo region data can be useful for postprocessing.
navidcy marked this conversation as resolved.
Show resolved Hide resolved

- `array_type`: The array type to which output arrays are converted to prior to saving.
Default: `Array{Float64}`.
Expand Down Expand Up @@ -165,7 +163,7 @@ JLD2OutputWriter scheduled on TimeInterval(20 minutes):
function JLD2OutputWriter(model, outputs; filename, schedule,
dir = ".",
indices = (:, :, :),
with_halos = false,
with_halos = true,
array_type = Array{Float64},
file_splitting = NoFileSplitting(),
overwrite_existing = false,
Expand Down