@@ -4,16 +4,40 @@ include("diagnostics_plots.jl")
44include (" ../leaderboard/leaderboard.jl" )
55
66"""
7- postprocess_sim(::Type{AbstractSlabplanetSimulationMode}, cs, postprocessing_vars)
7+ postprocess_sim(cs, postprocessing_vars)
88
9- Call `common_postprocessing` to perform common postprocessing tasks that are common to all simulation types.
10- Then, if conservation checks exist, perform them.
9+ Perform all postprocessing operations. This includes plotting all available
10+ diagnostics, plotting all model states and coupler fields for debugging,
11+ producing the leaderboard if monthly data is available, performing
12+ conservation checks if enabled, and closing all diagnostics file writers.
1113"""
12- function postprocess_sim (:: Type{<:AbstractSlabplanetSimulationMode} , cs, postprocessing_vars)
13- (; conservation_softfail,) = postprocessing_vars
14+ function postprocess_sim (cs, postprocessing_vars)
15+ (; use_coupler_diagnostics, output_default_diagnostics, t_end, conservation_softfail) = postprocessing_vars
16+ output_dir = cs. dirs. output
17+ artifact_dir = cs. dirs. artifacts
18+ coupler_output_dir = joinpath (output_dir, " coupler" )
19+ atmos_output_dir = joinpath (output_dir, " clima_atmos" )
20+ land_output_dir = joinpath (output_dir, " clima_land" )
21+
22+ # Plot generic diagnostics if requested
23+ if use_coupler_diagnostics && plot_diagnostics
24+ @info " Plotting diagnostics for coupler, atmos, and land"
25+ make_diagnostics_plots (coupler_output_dir, artifact_dir, output_prefix = " coupler_" )
26+ make_diagnostics_plots (atmos_output_dir, artifact_dir, output_prefix = " atmos_" )
27+ make_diagnostics_plots (land_output_dir, artifact_dir, output_prefix = " land_" )
28+ end
29+
30+ # Plot all model states and coupler fields (useful for debugging)
31+ ! CA. is_distributed (cs. comms_ctx) && debug (cs, artifact_dir)
1432
15- common_postprocessing (cs, postprocessing_vars)
33+ # If we have monthly data, plot the leaderboard
34+ if t_end > 84600 * 31 * 3 && output_default_diagnostics
35+ leaderboard_base_path = artifact_dir
36+ compute_leaderboard (leaderboard_base_path, atmos_output_dir)
37+ compute_pfull_leaderboard (leaderboard_base_path, atmos_output_dir)
38+ end
1639
40+ # Perform conservation checks if they exist
1741 if ! isnothing (cs. conservation_checks)
1842 @info " Conservation Check Plots"
1943 plot_global_conservation (
@@ -31,66 +55,7 @@ function postprocess_sim(::Type{<:AbstractSlabplanetSimulationMode}, cs, postpro
3155 figname2 = joinpath (cs. dirs. artifacts, " total_water_log_bucket.png" ),
3256 )
3357 end
34- end
35-
36- """
37- postprocess_sim(::Type{AMIPMode}, cs, postprocessing_vars)
38-
39- Call `common_postprocessing` to perform postprocessing tasks that are common to all simulation
40- types, and then conditionally plot AMIP diagnostics
41- """
42- function postprocess_sim (:: Type{AMIPMode} , cs, postprocessing_vars)
43- (; use_coupler_diagnostics, output_default_diagnostics, t_end) = postprocessing_vars
44-
45- common_postprocessing (cs, postprocessing_vars)
46-
47- if use_coupler_diagnostics
48- # # plot data that correspond to the model's last save_hdf5 call (i.e., last month)
49- @info " AMIP plots"
50- # define variable names and output directories for each diagnostic
51- amip_short_names_atmos = [" ta" , " ua" , " hus" , " clw" , " pr" , " ts" , " toa_fluxes_net" ]
52- amip_short_names_coupler = [" F_turb_energy" ]
53- output_dir_coupler = cs. dirs. output
54-
55- # Check if all output variables are available in the specified directories
56- make_diagnostics_plots (
57- atmos_output_dir,
58- cs. dirs. artifacts,
59- short_names = amip_short_names_atmos,
60- output_prefix = " atmos_" ,
61- )
62- make_diagnostics_plots (
63- output_dir_coupler,
64- cs. dirs. artifacts,
65- short_names = amip_short_names_coupler,
66- output_prefix = " coupler_" ,
67- )
68- end
69-
70- # Check this because we only want monthly data for making plots
71- if t_end > 84600 * 31 * 3 && output_default_diagnostics
72- leaderboard_base_path = cs. dirs. artifacts
73- compute_leaderboard (leaderboard_base_path, atmos_output_dir)
74- compute_pfull_leaderboard (leaderboard_base_path, atmos_output_dir)
75- end
76-
77- # close all AMIP diagnostics file writers
78- ! isnothing (cs. amip_diags_handler) &&
79- map (diag -> close (diag. output_writer), cs. amip_diags_handler. scheduled_diagnostics)
80- end
81-
82- """
83- common_postprocessing(cs, postprocessing_vars)
84-
85- Perform postprocessing common to all simulation types.
86- """
87- function common_postprocessing (cs, postprocessing_vars)
88- (; plot_diagnostics, atmos_output_dir) = postprocessing_vars
89- if plot_diagnostics
90- @info " Plotting diagnostics"
91- make_diagnostics_plots (atmos_output_dir, cs. dirs. artifacts)
92- end
9358
94- # plot all model states and coupler fields (useful for debugging)
95- ! CA . is_distributed (cs. comms_ctx ) && debug (cs , cs. dirs . artifacts )
59+ # Close all diagnostics file writers
60+ ! isnothing (cs. diags_handler ) && map (diag -> close (diag . output_writer) , cs. diags_handler . scheduled_diagnostics )
9661end
0 commit comments