Skip to content

Print globally averaged surface temperature for one-degree example #540

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

Merged
merged 10 commits into from
May 30, 2025
Merged
Changes from all commits
Commits
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
15 changes: 8 additions & 7 deletions examples/one_degree_simulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ using Oceananigans
using Oceananigans.Units
using Dates
using Printf
using Statistics

# ### Grid and Bathymetry

Expand Down Expand Up @@ -44,8 +45,8 @@ grid = ImmersedBoundaryGrid(underlying_grid, GridFittedBottom(bottom_height);
#
# We include temperature and salinity surface restoring to ECCO data from 1993 thoughout the water column.

start_date = DateTime(1993, 1, 1)
stop_date = DateTime(1993, 12, 1)
start_date = DateTime(1993, 6, 1)
stop_date = DateTime(1994, 5, 1)
Comment on lines +48 to +49
Copy link
Member

Choose a reason for hiding this comment

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

why?

Copy link
Member Author

Choose a reason for hiding this comment

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

because then the solution won't be biased to heat up as much at the beginning (eg starting during northern hemisphere winter)

dates = range(start_date, step=Month(1), stop=stop_date)
ecco_temperature = Metadata(:temperature; dates, dataset=ECCO4Monthly())
ecco_salinity = Metadata(:salinity; dates, dataset=ECCO4Monthly())
Expand Down Expand Up @@ -117,15 +118,15 @@ function progress(sim)
u, v, w = ocean.model.velocities
T = ocean.model.tracers.T
e = ocean.model.tracers.e
Tmin, Tmax = minimum(T), maximum(T)
Tmin, Tmax, Tavg = minimum(T), maximum(T), mean(view(T, :, :, ocean.model.grid.Nz))
emax = maximum(e)
umax = (maximum(abs, u), maximum(abs, v), maximum(abs, w))

step_time = 1e-9 * (time_ns() - wall_time[])

msg1 = @sprintf("Time: %s, iter: %d", prettytime(sim), iteration(sim))
msg2 = @sprintf(", max|u|: (%.1e, %.1e, %.1e) m s⁻¹, ", umax...)
msg3 = @sprintf(", extrema(T): (%.1f, %.1f) ᵒC, ", Tmin, Tmax)
msg3 = @sprintf(", extrema(T): (%.1f, %.1f) ᵒC, mean(T(z=0)): %.1f ᵒC", Tmin, Tmax, Tavg)
msg4 = @sprintf(", maximum(e): %.2f m² s⁻², ", emax)
msg5 = @sprintf(", wall time: %s \n", prettytime(step_time))

Expand Down Expand Up @@ -157,13 +158,13 @@ ocean.output_writers[:surface] = JLD2Writer(ocean.model, outputs;

# We are ready to press the big red button and run the simulation.

# After we run for a short time (here we set up the simulation with `stop_time = 10days`),
# After we run for a short time (here we set up the simulation with `stop_time = 20days`),
# we increase the timestep and run for longer.

run!(simulation)

simulation.Δt = 20minutes
simulation.stop_time = 360days
simulation.stop_time = 365days
run!(simulation)

# ### A pretty movie
Expand Down Expand Up @@ -222,7 +223,7 @@ axe = Axis(fig[3, 1])
hm = heatmap!(axs, sn, colorrange = (0, 0.5), colormap = :deep, nan_color=:lightgray)
Colorbar(fig[1, 2], hm, label = "Surface speed (m s⁻¹)")

hm = heatmap!(axT, Tn, colorrange = (-1, 30), colormap = :magma, nan_color=:lightgray)
hm = heatmap!(axT, Tn, colorrange = (-1, 32), colormap = :magma, nan_color=:lightgray)
Colorbar(fig[2, 2], hm, label = "Surface Temperature (ᵒC)")

hm = heatmap!(axe, en, colorrange = (0, 1e-3), colormap = :solar, nan_color=:lightgray)
Expand Down