diff --git a/examples/Project.toml b/examples/Project.toml index 2ea69890f91..1b56812af75 100644 --- a/examples/Project.toml +++ b/examples/Project.toml @@ -67,6 +67,7 @@ YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6" [compat] BlockArrays = "0.16" CairoMakie = "0.10, 0.11" +ClimaAnalysis = "0.3" ClimaCoreMakie = "0.3, 0.4" ClimaCorePlots = "0.2" ClimaCoreSpectra = "0.1" diff --git a/post_processing/ci_plots.jl b/post_processing/ci_plots.jl index 4250d687ddf..808dac61216 100644 --- a/post_processing/ci_plots.jl +++ b/post_processing/ci_plots.jl @@ -607,7 +607,7 @@ EDMFBoxPlots = Union{ } """ - plot_edmf_vert_profile!(fig, p_loc, var_group) + plot_edmf_vert_profile!(grid_loc, var_group) Helper function for `make_plots_generic`. Takes a list of variables and plots them on the same axis. @@ -616,10 +616,10 @@ function plot_edmf_vert_profile!(grid_loc, var_group) z = var_group[1].dims["z"] units = var_group[1].attributes["units"] ax = CairoMakie.Axis( - grid_loc[1,1], + grid_loc[1, 1], ylabel = "z [$(var_group[1].dim_attributes["z"]["units"])]", xlabel = "$(short_name(var_group[1])) [$units]", - title = short_var_info(var_group[1]) + title = var_info(var_group[1]), ) for var in var_group @@ -628,17 +628,28 @@ function plot_edmf_vert_profile!(grid_loc, var_group) length(var_group) > 1 && Makie.axislegend(ax) end + +""" + plot_custom_title!(grid_loc, var) + +Helper function for `make_plots_generic`. Plots a variable with a custom title. +""" +plot_custom_title!(grid_loc, var) = viz.plot!( + grid_loc, + var; + more_kwargs = Dict(:axis => ca_kwargs(title = var_info(var))), +) + """ group_edmf_vars(vars) -Groups pairs of updraft and gridmean EDMF OutputVars into a Dict. -This is fairly brittle - it just checks that the long name starts with "Updraft" -and matches on the rest of the long name. +Groups updraft and gridmean EDMF OutputVars into a Dict. +Groupings are matched via variable short name, location, and time (if applicable). """ function group_edmf_vars(vars) grouped_vars = OrderedDict{String, Vector{ClimaAnalysis.OutputVar}}() - for var in sort(vars, by = short_var_info) - suffix = short_var_info(var) + for var in sort(vars, by = var_info) + suffix = var_info(var) if haskey(grouped_vars, suffix) push!(grouped_vars[suffix], var) else @@ -648,16 +659,21 @@ function group_edmf_vars(vars) return grouped_vars end -function short_var_info(var) +function var_info(var) attr = var.attributes + + name = replace(short_name(var), "up" => "") coords = if haskey(attr, "slice_lat") "lat = $(attr["slice_lat"]), lon = $(attr["slice_lon"])" else "x = $(attr["slice_x"]), y = $(attr["slice_y"])" end - name = replace(short_name(var), "up" => "") - time = "t = " * attr["slice_time"] - return join([name, coords, time], ", ") + var_info = [name, coords] + + time = get(attr, "slice_time", nothing) + isnothing(time) || push!(var_info, "t = $(time)s") + + return join(var_info, ", ") end function make_plots(::EDMFBoxPlots, simulation_path) @@ -707,6 +723,7 @@ function make_plots(::EDMFBoxPlots, simulation_path) make_plots_generic( simulation_path, vars_zt, + plot_fn = plot_custom_title!, summary_files = [tmp_file], MAX_NUM_COLS = 2, MAX_NUM_ROWS = 4, @@ -746,9 +763,9 @@ function make_plots(::EDMFSpherePlots, simulation_path) make_plots_generic( simulation_path, vars_zt, + plot_fn = plot_custom_title!, summary_files = [tmp_file], MAX_NUM_COLS = 2, MAX_NUM_ROWS = 4, - more_kwargs = Dict(:axis => ca_kwargs(title = var -> var.attributes["short_name"])) ) end