Skip to content

Commit eaedad2

Browse files
glwagnernavidcy
andauthored
Print globally averaged surface temperature for one-degree example (#540)
* improve one degree further * Update examples/one_degree_simulation.jl * Update one_degree_simulation.jl * Update examples/one_degree_simulation.jl * add ᵒC * Update one_degree_simulation.jl * Update one_degree_simulation.jl * Update make.jl * Update one_degree_simulation.jl * Update make.jl --------- Co-authored-by: Navid C. Constantinou <[email protected]>
1 parent 589ce95 commit eaedad2

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

examples/one_degree_simulation.jl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ using Oceananigans
1313
using Oceananigans.Units
1414
using Dates
1515
using Printf
16+
using Statistics
1617

1718
# ### Grid and Bathymetry
1819

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

47-
start_date = DateTime(1993, 1, 1)
48-
stop_date = DateTime(1993, 12, 1)
48+
start_date = DateTime(1993, 6, 1)
49+
stop_date = DateTime(1994, 5, 1)
4950
dates = range(start_date, step=Month(1), stop=stop_date)
5051
ecco_temperature = Metadata(:temperature; dates, dataset=ECCO4Monthly())
5152
ecco_salinity = Metadata(:salinity; dates, dataset=ECCO4Monthly())
@@ -117,15 +118,15 @@ function progress(sim)
117118
u, v, w = ocean.model.velocities
118119
T = ocean.model.tracers.T
119120
e = ocean.model.tracers.e
120-
Tmin, Tmax = minimum(T), maximum(T)
121+
Tmin, Tmax, Tavg = minimum(T), maximum(T), mean(view(T, :, :, ocean.model.grid.Nz))
121122
emax = maximum(e)
122123
umax = (maximum(abs, u), maximum(abs, v), maximum(abs, w))
123124

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

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

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

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

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

163164
run!(simulation)
164165

165166
simulation.Δt = 20minutes
166-
simulation.stop_time = 360days
167+
simulation.stop_time = 365days
167168
run!(simulation)
168169

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

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

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

0 commit comments

Comments
 (0)