Skip to content

Commit

Permalink
One .pdf instead of 36 .png long_runs artifacts
Browse files Browse the repository at this point in the history
Long runs where producing 36 artifacts (.png files), this commit
tidy this up by gathering them into one .pdf instead.
  • Loading branch information
AlexisRenchon committed Oct 22, 2024
1 parent e205018 commit 08f4d78
Show file tree
Hide file tree
Showing 8 changed files with 168 additions and 51 deletions.
171 changes: 127 additions & 44 deletions .buildkite/Manifest-v1.11.toml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .buildkite/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab"
NLsolve = "2774e3e8-f4cf-5e23-947b-6d7e65073b56"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Poppler_jll = "9c32591e-4766-534b-9725-b71a8799265b"
ProfileCanvas = "efd6af41-a80b-495e-886c-e51b0c7d77a3"
RootSolvers = "7181ea78-2dcb-4de3-ab41-2b8ab5a31e74"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
Expand Down
11 changes: 9 additions & 2 deletions experiments/long_runs/bucket.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# # Global bucket run

# The code sets up and runs the bucket model on a spherical domain,
# using ERA5 data.
# using ERA5 data.

# Simulation Setup
# Number of spatial elements: 101 in horizontal, 5 in vertical
Expand Down Expand Up @@ -38,6 +38,8 @@ using CairoMakie
using Dates
import NCDatasets

using Poppler_jll: pdfunite

const FT = Float64;
time_interpolation_method = LinearInterpolation(PeriodicCalendar())
regridder_type = :InterpolationsRegridder
Expand Down Expand Up @@ -167,6 +169,7 @@ setup_and_solve_problem(; greet = true);
simdir = ClimaAnalysis.SimDir(outdir)
short_names =
["swa", "rn", "tsfc", "qsfc", "lhf", "shf", "wsoil", "wsfc", "ssfc"]
tmpdir = mktempdir(root_path)
for short_name in short_names
var = get(simdir; short_name)
times = ClimaAnalysis.times(var)
Expand All @@ -182,6 +185,10 @@ for short_name in short_names
:mask => ClimaAnalysis.Utils.kwargs(color = :white),
),
)
CairoMakie.save(joinpath(root_path, "$(short_name)_$t.png"), fig)
CairoMakie.save(joinpath(tmpdir, "$(short_name)_$t.pdf"), fig)
end
end
figures = readdir(tmpdir)
pdfunite() do unite
run(Cmd([unite, figures..., "figures.pdf"]))
end
9 changes: 8 additions & 1 deletion experiments/long_runs/land.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ import GeoMakie
using Dates
import NCDatasets

using Poppler_jll: pdfunite

const FT = Float64;
time_interpolation_method = LinearInterpolation(PeriodicCalendar())
regridder_type = :InterpolationsRegridder
Expand Down Expand Up @@ -593,6 +595,7 @@ setup_and_solve_problem(; greet = true);
#### ClimaAnalysis ####
simdir = ClimaAnalysis.SimDir(outdir)
short_names = ["gpp", "ct", "lai", "swc", "si", "swa", "lwu", "et", "er", "sr"]
tmpdir = mktempdir(root_path)
for short_name in short_names
var = get(simdir; short_name)
times = ClimaAnalysis.times(var)
Expand All @@ -607,6 +610,10 @@ for short_name in short_names
:mask => ClimaAnalysis.Utils.kwargs(color = :white),
),
)
CairoMakie.save(joinpath(root_path, "$(short_name)_$t.png"), fig)
CairoMakie.save(joinpath(tmpdir, "$(short_name)_$t.pdf"), fig)
end
end
figures = readdir(tmpdir)
pdfunite() do unite
run(Cmd([unite, figures..., "figures.pdf"]))
end
9 changes: 8 additions & 1 deletion experiments/long_runs/land_region.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ using CairoMakie
using Dates
import NCDatasets

using Poppler_jll: pdfunite

const FT = Float64;
time_interpolation_method = LinearInterpolation(PeriodicCalendar())
regridder_type = :InterpolationsRegridder
Expand Down Expand Up @@ -597,6 +599,7 @@ setup_and_solve_problem(; greet = true);
#### ClimaAnalysis ####
simdir = ClimaAnalysis.SimDir(outdir)
short_names = ["gpp", "ct", "swc", "si"]
tmpdir = mktempdir(root_path)
for short_name in short_names
var = get(simdir; short_name)
times = ClimaAnalysis.times(var)
Expand All @@ -606,7 +609,11 @@ for short_name in short_names
tmp = ClimaAnalysis.slice(var, time = t; kwargs...)
if !all(isnan.(tmp.data))
viz.heatmap2D!(fig, tmp)
CairoMakie.save(joinpath(root_path, "$(short_name)_$t.png"), fig)
CairoMakie.save(joinpath(tmpdir, "$(short_name)_$t.pdf"), fig)
end
end
end
figures = readdir(tmpdir)
pdfunite() do unite
run(Cmd([unite, figures..., "figures.pdf"]))
end
9 changes: 8 additions & 1 deletion experiments/long_runs/soil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ using CairoMakie
using Dates
import NCDatasets

using Poppler_jll: pdfunite

const FT = Float64;
time_interpolation_method = LinearInterpolation(PeriodicCalendar())
regridder_type = :InterpolationsRegridder
Expand Down Expand Up @@ -365,6 +367,7 @@ setup_and_solve_problem(; greet = true);
#### ClimaAnalysis ####
simdir = ClimaAnalysis.SimDir(outdir)
short_names = ["swc", "si", "sie"]
tmpdir = mktempdir(root_path)
for short_name in short_names
var = get(simdir; short_name)
times = ClimaAnalysis.times(var)
Expand All @@ -380,6 +383,10 @@ for short_name in short_names
:mask => ClimaAnalysis.Utils.kwargs(color = :white),
),
)
CairoMakie.save(joinpath(root_path, "$(short_name)_$t.png"), fig)
CairoMakie.save(joinpath(tmpdir, "$(short_name)_$t.pdf"), fig)
end
end
figures = readdir(tmpdir)
pdfunite() do unite
run(Cmd([unite, figures..., "figures.pdf"]))
end
4 changes: 2 additions & 2 deletions test/diagnostics/diagnostics_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using ClimaLand.Diagnostics: @with_error

@test isdefined(ClimaLand.Diagnostics, :compute_sw_albedo!)

@test !hasmethod(
@test hasmethod(
ClimaLand.Diagnostics.compute_sw_albedo!,
(Any, Any, Any, Any, Any),
)
Expand Down Expand Up @@ -35,7 +35,7 @@ ClimaLand.Diagnostics.define_diagnostics!(DummyModel())
# Just to trigger the error
out = Y = p = t = land_model = nothing

@test_throws ErrorException("Cannot compute albedo with model = Nothing") ClimaLand.Diagnostics.compute_albedo!(
@test_throws ErrorException("Cannot compute sw_albedo with model = Nothing") ClimaLand.Diagnostics.compute_sw_albedo!(
out,
Y,
p,
Expand Down
5 changes: 5 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,8 @@ end
@safetestset "Integrated soil and snow" begin
include("integrated/soil_snow.jl")
end

# Diagnostics
@safetestset "Diagnostics" begin
include("diagnostics/diagnostics_tests.jl")
end

0 comments on commit 08f4d78

Please sign in to comment.