Skip to content

Commit

Permalink
Merge pull request #2558 from CliMA/gb/diagnostics
Browse files Browse the repository at this point in the history
Use more ClimaAnalysis in post of precipitation test
  • Loading branch information
Sbozzolo authored Jan 22, 2024
2 parents c792dd3 + 31e3d73 commit 17f7703
Showing 1 changed file with 35 additions and 33 deletions.
68 changes: 35 additions & 33 deletions post_processing/ci_plots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import CairoMakie.Makie
import ClimaAnalysis
import ClimaAnalysis: Visualize as viz
import ClimaAnalysis: SimDir, slice_time, slice
import ClimaAnalysis.Utils: kwargs as ca_kwargs

import ClimaCoreSpectra: power_spectrum_2d

Expand Down Expand Up @@ -50,7 +51,7 @@ function Makie.get_tickvalues(yticks::Int, yscale::typeof(Plvl), ymin, ymax)
end

YLOGSCALE = Dict(
:axis => ClimaAnalysis.Utils.kwargs(
:axis => ca_kwargs(
dim_on_y = true,
yscale = Plvl,
yticks = 7,
Expand Down Expand Up @@ -123,7 +124,7 @@ function make_spectra_generic(
output_path,
vars,
args...;
slicing_kwargs = ClimaAnalysis.Utils.kwargs(),
slicing_kwargs = ca_kwargs(),
output_name = "spectra",
kwargs...,
)
Expand Down Expand Up @@ -216,47 +217,48 @@ end
function make_plots(::Val{:single_column_precipitation_test}, simulation_path)
simdir = SimDir(simulation_path)
short_names = ["hus", "clw", "cli", "husra", "hussn", "ta"]
hus, clw, cli, husra, hussn, ta = [
vars = [
slice(get(simdir; short_name), x = 0.0, y = 0.0) for
short_name in short_names
]

z_units = hus.dim_attributes["z"]["units"]
z = hus.dims["z"]
# We first prepare the axes with all the nice labels with ClimaAnalysis, then we use
# CairoMakie to add the additional lines.
fig = CairoMakie.Figure(resolution = (1200, 600))

hus_units = hus.attributes["units"]
clw_units = clw.attributes["units"]
cli_units = cli.attributes["units"]
husra_units = husra.attributes["units"]
hussn_units = hussn.attributes["units"]
ta_units = ta.attributes["units"]
p_loc = [1, 1]

fig = CairoMakie.Figure(resolution = (1200, 600))
ax1 = CairoMakie.Axis(
fig[1, 1],
ylabel = "z [$z_units]",
xlabel = "hus [$hus_units]",
)
ax4 = CairoMakie.Axis(
fig[2, 1],
ylabel = "z [$z_units]",
xlabel = "ta [$ta_units]",
)
ax2 = CairoMakie.Axis(fig[1, 2], xlabel = "q_liq [$clw_units]")
ax3 = CairoMakie.Axis(fig[1, 3], xlabel = "q_ice [$cli_units]")
ax5 = CairoMakie.Axis(fig[2, 2], xlabel = "q_rai [$husra_units]")
ax6 = CairoMakie.Axis(fig[2, 3], xlabel = "q_sno [$hussn_units]")
axes = map(vars) do var
viz.plot!(
fig,
var;
time = 0.0,
p_loc,
more_kwargs = Dict(
:plot => ca_kwargs(color = :navy),
:axis => ca_kwargs(dim_on_y = true, title = ""),
),
)

# Make a grid of plots
p_loc[2] += 1
p_loc[2] > 3 && (p_loc[1] += 1; p_loc[2] = 1)
return CairoMakie.current_axis()
end

col = Dict(0 => :navy, 500 => :blue2, 1000 => :royalblue, 1500 => :skyblue1)
col = Dict(500 => :blue2, 1000 => :royalblue, 1500 => :skyblue1)

for (time, color) in col
CairoMakie.lines!(ax1, slice(hus; time).data, z, color = color)
CairoMakie.lines!(ax2, slice(clw; time).data, z, color = color)
CairoMakie.lines!(ax3, slice(cli; time).data, z, color = color)
CairoMakie.lines!(ax4, slice(ta; time).data, z, color = color)
CairoMakie.lines!(ax5, slice(husra; time).data, z, color = color)
CairoMakie.lines!(ax6, slice(hussn; time).data, z, color = color)
for (i, var) in enumerate(vars)
CairoMakie.lines!(
axes[i],
slice(var; time).data,
var.dims["z"],
color = color,
)
end
end

file_path = joinpath(simulation_path, "summary.pdf")
CairoMakie.save(file_path, fig)
end
Expand Down

0 comments on commit 17f7703

Please sign in to comment.