@@ -191,6 +191,25 @@ function plot_divergence(outdir, closure_name, nles, Φ, data_index, ax, color,
191191 ax. yscale = log10
192192end
193193
194+ function _plot_histogram (ax, data, label, color, linestyle, linewidth)
195+ hist_data = hist! (ax, [p[2 ] for p in data]; bins = 10 , color = (:transparent , 0.0 ))
196+ centers = hist_data. plots[1 ][1 ][]
197+ x_values = [p[2 ] for p in centers] # x-values are frequencies
198+ y_values = [p[1 ] for p in centers] # y-values are bin centers
199+ lines! (
200+ ax,
201+ x_values,
202+ y_values,
203+ label = label,
204+ linestyle = linestyle,
205+ linewidth = linewidth,
206+ color = color,
207+ )
208+
209+ # update axis limits
210+ ax = _update_ax_limits (ax, x_values, y_values)
211+ end
212+
194213function plot_energy_evolution (
195214 outdir,
196215 closure_name,
@@ -209,7 +228,6 @@ function plot_energy_evolution(
209228 end
210229 energyhistory = namedtupleload (energy_dir). energyhistory;
211230
212- # add No closure only once
213231 if closure_name == " INS_ref"
214232 label = " No closure "
215233 if _missing_label (ax, label) && haskey (energyhistory, Symbol (" nomodel" ))
@@ -273,6 +291,7 @@ function plot_energy_evolution(
273291 end
274292
275293 label = Φ isa FaceAverage ? " FA" : " VA"
294+ # prior
276295 lines! (
277296 ax,
278297 energyhistory. model_prior[data_index];
@@ -281,6 +300,7 @@ function plot_energy_evolution(
281300 linewidth = PLOT_STYLES[:prior ]. linewidth,
282301 color = color, # dont change this color
283302 )
303+ # post
284304 lines! (
285305 ax,
286306 energyhistory. model_post[data_index];
@@ -294,6 +314,110 @@ function plot_energy_evolution(
294314 x_values = [point[1 ] for v in values (energyhistory) for point in v[data_index]]
295315 y_values = [point[2 ] for v in values (energyhistory) for point in v[data_index]]
296316 ax = _update_ax_limits (ax, x_values, y_values)
317+
318+ end
319+
320+ function plot_energy_evolution_hist (
321+ outdir,
322+ closure_name,
323+ nles,
324+ Φ,
325+ data_index,
326+ ax,
327+ color,
328+ PLOT_STYLES,
329+ )
330+ # Load learned parameters
331+ energy_dir = joinpath (outdir, closure_name, " history.jld2" )
332+ if ! ispath (energy_dir)
333+ @warn " Energy history not found in $energy_dir "
334+ return
335+ end
336+ energyhistory = namedtupleload (energy_dir). energyhistory;
337+
338+ if closure_name == " INS_ref"
339+ label = " No closure "
340+ if _missing_label (ax, label) && haskey (energyhistory, Symbol (" nomodel" ))
341+ _plot_histogram (
342+ ax,
343+ energyhistory. nomodel[data_index],
344+ label,
345+ PLOT_STYLES[:no_closure ]. color,
346+ PLOT_STYLES[:no_closure ]. linestyle,
347+ PLOT_STYLES[:no_closure ]. linewidth,
348+ )
349+ end
350+ # add reference only once
351+ label = " Reference"
352+ if _missing_label (ax, label) && haskey (energyhistory, Symbol (" ref" ))
353+ _plot_histogram (
354+ ax,
355+ energyhistory. ref[data_index],
356+ label,
357+ PLOT_STYLES[:reference ]. color,
358+ PLOT_STYLES[:reference ]. linestyle,
359+ PLOT_STYLES[:reference ]. linewidth,
360+ )
361+ end
362+ end
363+
364+ if closure_name == " cnn_1"
365+ label = " No closure (projected dyn)"
366+ if _missing_label (ax, label) && haskey (energyhistory, Symbol (" nomodel" ))
367+ _plot_histogram (
368+ ax,
369+ energyhistory. nomodel[data_index],
370+ label,
371+ PLOT_STYLES[:no_closure_proj ]. color,
372+ PLOT_STYLES[:no_closure_proj ]. linestyle,
373+ PLOT_STYLES[:no_closure_proj ]. linewidth,
374+ )
375+ end
376+ label = " Reference (projected dyn)"
377+ if _missing_label (ax, label) && haskey (energyhistory, Symbol (" ref" ))
378+ _plot_histogram (
379+ ax,
380+ energyhistory. ref[data_index],
381+ label,
382+ PLOT_STYLES[:reference_proj ]. color,
383+ PLOT_STYLES[:reference_proj ]. linestyle,
384+ PLOT_STYLES[:reference_proj ]. linewidth,
385+ )
386+ end
387+ end
388+
389+ if haskey (energyhistory, Symbol (" smag" ))
390+ _plot_histogram (
391+ ax,
392+ energyhistory. smag[data_index],
393+ " $closure_name (smag) (n = $nles )" ,
394+ PLOT_STYLES[:smag ]. color,
395+ PLOT_STYLES[:smag ]. linestyle,
396+ PLOT_STYLES[:smag ]. linewidth,
397+ )
398+ end
399+
400+ label = Φ isa FaceAverage ? " FA" : " VA"
401+ # prior
402+ _plot_histogram (
403+ ax,
404+ energyhistory. model_prior[data_index],
405+ " $closure_name (prior) (n = $nles , $label )" ,
406+ color,
407+ PLOT_STYLES[:prior ]. linestyle,
408+ PLOT_STYLES[:prior ]. linewidth,
409+ )
410+
411+ # post
412+ _plot_histogram (
413+ ax,
414+ energyhistory. model_post[data_index],
415+ " $closure_name (post) (n = $nles , $label )" ,
416+ color,
417+ PLOT_STYLES[:post ]. linestyle,
418+ PLOT_STYLES[:post ]. linewidth,
419+ )
420+
297421end
298422
299423function _get_spectra (setup, u)
0 commit comments