CliMA / LESbrary.jl

📚Generating Oceananigans large eddy simulation (LES) data for calibrating parameterizations
MIT License
28 stars 10 forks source link

Mean buoyancy budget in 2Day suite simulations #70

Closed sandreza closed 3 years ago

sandreza commented 3 years ago

Plotting the mean buoyancy in time for some of the 2Day suite simulations seems to not satisfy the mean buoyancy budget. In particular

using JLD2, Statistics, Plots
filename = pwd() * "/three_layer_constant_fluxes_hr48_Qu0.0e+00_Qb1.2e-07_f1.0e-04_Nh256_Nz128_free_convection_averaged_statistics.jld2"
file = jldopen(filename)

αg = 0.00196133

keys(file["timeseries"]["u"])
u = []
v = []
b = []
e = []
t = []
for key in keys(file["timeseries"]["u"])
    push!(u,file["timeseries"]["u"][key]*1.0)
    push!(v,file["timeseries"]["v"][key]*1.0)
    push!(b,file["timeseries"]["b"][key]*1.0)
    push!(e,file["timeseries"]["e"][key]*1.0)
    push!(t,file["timeseries"]["t"][key]*1.0)
end

plot(t, mean.(b))

yields a plot that isn't a straight line

sandreza commented 3 years ago
Screen Shot 2021-01-10 at 11 48 35 PM
sandreza commented 3 years ago

Actually, this may be due to the fact that what I grabbed are the time-averaged statistics as opposed to the instantaneous. This would explain the factor of two discrepancies in the slope as compared to the expected budget, as well as initial transient

sandreza commented 3 years ago

That was indeed the case. Using statistics.nc (instead of averaged_statistcs.nc)

using NCDatasets, Statistics, Plots
files = [
    pwd() * "/three_layer_constant_fluxes_cubic_hr48_Qu0.0e+00_Qb1.0e-08_f1.0e-04_Nh256_Nz128_free_convection_2days_Qb1e-8.nc",
    pwd() * "/checkthis.nc"
]
file = files[2]
ds = Dataset(file,"r")
field = ds["T"]
t = ds["time"][:]
meanT = zeros(length(t))
key = keys(field)
for i in eachindex(t) 
    meanT[i] = mean(field[:,i])  
end

plot(t, meanT)

αg = 0.00196133
for  i in 2:length(t)
    println(αg * (meanT[i-1] - meanT[i]) / (t[i] - t[i-1]))
end

yielded

Screen Shot 2021-01-11 at 11 28 23 AM
glwagner commented 3 years ago

Maybe we should use time_averaged_statistics.nc and instantaneous_statistics.nc as filenames?

ali-ramadhan commented 3 years ago

Yeah I'd be on board with these clearer names.

sandreza commented 3 years ago

Same here!

ali-ramadhan commented 3 years ago

These names are now in use on the master branch (switch was made in PR #56).