Skip to content

Commit a064652

Browse files
authored
Default global plots using simulation struct (#1199)
1 parent 63bc023 commit a064652

File tree

16 files changed

+783
-456
lines changed

16 files changed

+783
-456
lines changed

.buildkite/Manifest-v1.11.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
julia_version = "1.11.6"
44
manifest_format = "2.0"
5-
project_hash = "acaaffaaac229b13d375a67bbaf146c0a0ce520e"
5+
project_hash = "55c55a1c8b475869d4bb069be5aa7bbf8ba540bb"
66

77
[[deps.ADTypes]]
88
git-tree-sha1 = "be7ae030256b8ef14a441726c4c37766b90b93a3"
@@ -481,10 +481,11 @@ deps = ["ClimaComms", "ClimaCore", "ClimaDiagnostics", "ClimaTimeSteppers", "Cli
481481
path = ".."
482482
uuid = "08f4d4ce-cf43-44bb-ad95-9d2d5f413532"
483483
version = "0.17.1"
484-
weakdeps = ["BSON", "CSV", "ClimaParams", "DataFrames", "Flux", "HTTP", "StatsBase"]
484+
weakdeps = ["BSON", "CSV", "CairoMakie", "ClimaAnalysis", "ClimaParams", "DataFrames", "Flux", "GeoMakie", "HTTP", "Poppler_jll", "Printf", "StatsBase"]
485485

486486
[deps.ClimaLand.extensions]
487487
CreateParametersExt = "ClimaParams"
488+
LandSimulationVisualization = ["CairoMakie", "ClimaAnalysis", "GeoMakie", "Poppler_jll", "Printf", "StatsBase"]
488489
NeuralSnowExt = ["CSV", "DataFrames", "HTTP", "Flux", "StatsBase", "BSON"]
489490

490491
[[deps.ClimaParams]]

.buildkite/Manifest.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# This file is machine-generated - editing it directly is not advised
22

3-
julia_version = "1.10.9"
3+
julia_version = "1.10.10"
44
manifest_format = "2.0"
5-
project_hash = "44a3a750b9b826bdab27f20cf41681e6b0e9e450"
5+
project_hash = "3f0124403c94b3ee688b94982d79b9dea53973ab"
66

77
[[deps.ADTypes]]
88
git-tree-sha1 = "be7ae030256b8ef14a441726c4c37766b90b93a3"
@@ -478,10 +478,11 @@ deps = ["ClimaComms", "ClimaCore", "ClimaDiagnostics", "ClimaTimeSteppers", "Cli
478478
path = ".."
479479
uuid = "08f4d4ce-cf43-44bb-ad95-9d2d5f413532"
480480
version = "0.17.1"
481-
weakdeps = ["BSON", "CSV", "ClimaParams", "DataFrames", "Flux", "HTTP", "StatsBase"]
481+
weakdeps = ["BSON", "CSV", "CairoMakie", "ClimaAnalysis", "ClimaParams", "DataFrames", "Flux", "GeoMakie", "HTTP", "Poppler_jll", "Printf", "StatsBase"]
482482

483483
[deps.ClimaLand.extensions]
484484
CreateParametersExt = "ClimaParams"
485+
LandSimulationVisualization = ["CairoMakie", "ClimaAnalysis", "GeoMakie", "Poppler_jll", "Printf", "StatsBase"]
485486
NeuralSnowExt = ["CSV", "DataFrames", "HTTP", "Flux", "StatsBase", "BSON"]
486487

487488
[[deps.ClimaParams]]
@@ -2246,7 +2247,7 @@ version = "2.5.4+0"
22462247
[[deps.OpenLibm_jll]]
22472248
deps = ["Artifacts", "Libdl"]
22482249
uuid = "05823500-19ac-5b8b-9628-191a04bc5112"
2249-
version = "0.8.1+4"
2250+
version = "0.8.5+0"
22502251

22512252
[[deps.OpenMPI_jll]]
22522253
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Hwloc_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "MPIPreferences", "TOML", "Zlib_jll"]

.buildkite/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
3232
NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab"
3333
NLsolve = "2774e3e8-f4cf-5e23-947b-6d7e65073b56"
3434
Poppler_jll = "9c32591e-4766-534b-9725-b71a8799265b"
35+
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
3536
ProfileCanvas = "efd6af41-a80b-495e-886c-e51b0c7d77a3"
3637
RootSolvers = "7181ea78-2dcb-4de3-ab41-2b8ab5a31e74"
3738
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"

.github/workflows/downgrade.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ jobs:
2929
- uses: julia-actions/cache@v2
3030
- uses: julia-actions/julia-downgrade-compat@v1
3131
with:
32-
skip: Dates, LazyArtifacts, LinearAlgebra, Test, Statistics
32+
skip: Dates, LazyArtifacts, LinearAlgebra, Test, Statistics, Printf
3333
- uses: julia-actions/julia-buildpkg@latest
3434
- uses: julia-actions/julia-runtest@latest

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ ClimaLand.jl Release Notes
33

44
main
55
-------
6+
- Create the extension LandSimulationsVisualization PR[#1199](https://github.com/CliMA/ClimaLand.jl/pull/1199)
67

78
v0.17.1
89
-------

Project.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,27 @@ Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c"
2525
[weakdeps]
2626
BSON = "fbb218c0-5317-5bc6-957e-2ee96dd4b1f0"
2727
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
28+
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
29+
ClimaAnalysis = "29b5916a-a76c-4e73-9657-3c8fd22e65e6"
2830
ClimaParams = "5c42b081-d73a-476f-9059-fd94b934656c"
2931
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
3032
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
33+
GeoMakie = "db073c08-6b98-4ee5-b6a4-5efafb3259c6"
3134
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
35+
Poppler_jll = "9c32591e-4766-534b-9725-b71a8799265b"
36+
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
3237
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
3338

3439
[extensions]
3540
CreateParametersExt = "ClimaParams"
41+
LandSimulationVisualization = ["CairoMakie", "ClimaAnalysis", "GeoMakie", "Poppler_jll", "Printf", "StatsBase"]
3642
NeuralSnowExt = ["CSV", "DataFrames", "HTTP", "Flux", "StatsBase", "BSON"]
3743

3844
[compat]
3945
BSON = "0.3.9"
46+
CairoMakie = "0.12"
4047
CSV = "0.10.14"
48+
ClimaAnalysis = "0.5.17"
4149
ClimaComms = "0.6.2"
4250
ClimaCore = "0.14.23"
4351
ClimaDiagnostics = "0.2.10"
@@ -48,13 +56,16 @@ DataFrames = "1.4"
4856
Dates = "1"
4957
DocStringExtensions = "0.9"
5058
Flux = "0.15, 0.16"
59+
GeoMakie = "< 0.7.13"
5160
HTTP = "1.10"
5261
Insolation = "0.9.2"
5362
Interpolations = "0.15.1, 0.16"
5463
LazyArtifacts = "1"
5564
LazyBroadcast = "1.0.0"
5665
LinearAlgebra = "1"
5766
NCDatasets = "0.14"
67+
Poppler_jll = "24"
68+
Printf = "1"
5869
SciMLBase = "2.53"
5970
StaticArrays = "1.6"
6071
StatsBase = "0.34"

docs/Manifest-v1.11.toml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file is machine-generated - editing it directly is not advised
22

3-
julia_version = "1.11.5"
3+
julia_version = "1.11.6"
44
manifest_format = "2.0"
55
project_hash = "53eaaa3557cec5df76ee8d7b9a7b00e0b499fc9f"
66

@@ -404,12 +404,26 @@ deps = ["ClimaComms", "ClimaCore", "ClimaDiagnostics", "ClimaTimeSteppers", "Cli
404404
path = ".."
405405
uuid = "08f4d4ce-cf43-44bb-ad95-9d2d5f413532"
406406
version = "0.17.1"
407-
weakdeps = ["BSON", "CSV", "ClimaParams", "DataFrames", "Flux", "HTTP", "StatsBase"]
408407

409408
[deps.ClimaLand.extensions]
410409
CreateParametersExt = "ClimaParams"
410+
LandSimulationVisualization = ["CairoMakie", "ClimaAnalysis", "GeoMakie", "Poppler_jll", "Printf", "StatsBase"]
411411
NeuralSnowExt = ["CSV", "DataFrames", "HTTP", "Flux", "StatsBase", "BSON"]
412412

413+
[deps.ClimaLand.weakdeps]
414+
BSON = "fbb218c0-5317-5bc6-957e-2ee96dd4b1f0"
415+
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
416+
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
417+
ClimaAnalysis = "29b5916a-a76c-4e73-9657-3c8fd22e65e6"
418+
ClimaParams = "5c42b081-d73a-476f-9059-fd94b934656c"
419+
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
420+
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
421+
GeoMakie = "db073c08-6b98-4ee5-b6a4-5efafb3259c6"
422+
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
423+
Poppler_jll = "9c32591e-4766-534b-9725-b71a8799265b"
424+
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
425+
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
426+
413427
[[deps.ClimaLandSimulations]]
414428
deps = ["Bonito", "CairoMakie", "ClimaComms", "ClimaCore", "ClimaDiagnostics", "ClimaLand", "ClimaParams", "ClimaTimeSteppers", "ClimaUtilities", "DataFrames", "Dates", "DelimitedFiles", "Format", "HTTP", "Insolation", "Interpolations", "InverseFunctions", "JSON", "LaTeXStrings", "MutableArithmetics", "NLsolve", "PlotUtils", "RootSolvers", "SciMLBase", "StaticArrays", "Statistics", "StatsBase", "SurfaceFluxes", "Thermodynamics", "Unitful", "UnitfulMoles", "WGLMakie"]
415429
path = "../lib/ClimaLandSimulations"

docs/Manifest.toml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file is machine-generated - editing it directly is not advised
22

3-
julia_version = "1.10.9"
3+
julia_version = "1.10.10"
44
manifest_format = "2.0"
55
project_hash = "0e313427333375504d76ddc31cd582bee13918ac"
66

@@ -407,12 +407,26 @@ deps = ["ClimaComms", "ClimaCore", "ClimaDiagnostics", "ClimaTimeSteppers", "Cli
407407
path = ".."
408408
uuid = "08f4d4ce-cf43-44bb-ad95-9d2d5f413532"
409409
version = "0.17.1"
410-
weakdeps = ["BSON", "CSV", "ClimaParams", "DataFrames", "Flux", "HTTP", "StatsBase"]
411410

412411
[deps.ClimaLand.extensions]
413412
CreateParametersExt = "ClimaParams"
413+
LandSimulationVisualization = ["CairoMakie", "ClimaAnalysis", "GeoMakie", "Poppler_jll", "Printf", "StatsBase"]
414414
NeuralSnowExt = ["CSV", "DataFrames", "HTTP", "Flux", "StatsBase", "BSON"]
415415

416+
[deps.ClimaLand.weakdeps]
417+
BSON = "fbb218c0-5317-5bc6-957e-2ee96dd4b1f0"
418+
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
419+
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
420+
ClimaAnalysis = "29b5916a-a76c-4e73-9657-3c8fd22e65e6"
421+
ClimaParams = "5c42b081-d73a-476f-9059-fd94b934656c"
422+
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
423+
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
424+
GeoMakie = "db073c08-6b98-4ee5-b6a4-5efafb3259c6"
425+
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
426+
Poppler_jll = "9c32591e-4766-534b-9725-b71a8799265b"
427+
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
428+
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
429+
416430
[[deps.ClimaLandSimulations]]
417431
deps = ["Bonito", "CairoMakie", "ClimaComms", "ClimaCore", "ClimaDiagnostics", "ClimaLand", "ClimaParams", "ClimaTimeSteppers", "ClimaUtilities", "DataFrames", "Dates", "DelimitedFiles", "Format", "HTTP", "Insolation", "Interpolations", "InverseFunctions", "JSON", "LaTeXStrings", "MutableArithmetics", "NLsolve", "PlotUtils", "RootSolvers", "SciMLBase", "StaticArrays", "Statistics", "StatsBase", "SurfaceFluxes", "Thermodynamics", "Unitful", "UnitfulMoles", "WGLMakie"]
418432
path = "../lib/ClimaLandSimulations"
@@ -2172,7 +2186,7 @@ version = "3.2.4+0"
21722186
[[deps.OpenLibm_jll]]
21732187
deps = ["Artifacts", "Libdl"]
21742188
uuid = "05823500-19ac-5b8b-9628-191a04bc5112"
2175-
version = "0.8.1+4"
2189+
version = "0.8.5+0"
21762190

21772191
[[deps.OpenMPI_jll]]
21782192
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Hwloc_jll", "JLLWrappers", "LazyArtifacts", "Libdl", "MPIPreferences", "TOML", "Zlib_jll"]

experiments/long_runs/bucket.jl

Lines changed: 73 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ import Interpolations
1919
import ClimaUtilities.TimeVaryingInputs:
2020
TimeVaryingInput, LinearInterpolation, PeriodicCalendar
2121
import ClimaUtilities.TimeManager: ITime
22-
using ClimaAnalysis
23-
import ClimaAnalysis.Visualize as viz
2422
using ClimaUtilities
2523
import ClimaUtilities.ClimaArtifacts: @clima_artifact
2624
import ClimaParams as CP
@@ -32,12 +30,15 @@ import ClimaLand.Parameters as LP
3230

3331
import ClimaLand.Simulations: LandSimulation, solve!
3432
using Statistics
35-
import GeoMakie
36-
using CairoMakie
3733
using Dates
3834
import NCDatasets
3935

40-
using Poppler_jll: pdfunite
36+
using CairoMakie, GeoMakie, Poppler_jll, ClimaAnalysis
37+
LandSimVis =
38+
Base.get_extension(
39+
ClimaLand,
40+
:LandSimulationVisualization,
41+
).LandSimulationVisualization;
4142

4243
const FT = Float64;
4344
time_interpolation_method = LinearInterpolation(PeriodicCalendar())
@@ -92,85 +93,76 @@ function setup_model(FT, start_date, domain, earth_param_set, bucket_params)
9293
return bucket
9394
end
9495

95-
function setup_simulation(; greet = false)
96-
Δt = 900.0
97-
start_date = DateTime(2008)
98-
stop_date = DateTime(2010)
99-
nelements = (101, 7)
100-
if greet
101-
@info "Run: Global Bucket Model"
102-
@info "Resolution: $nelements"
103-
@info "Timestep: $Δt s"
104-
@info "Start Date: $start_date"
105-
@info "Stop Date: $stop_date"
106-
end
107-
# Domain
108-
depth = FT(3.5)
109-
dz_tuple = FT.((1.0, 0.05))
110-
domain =
111-
ClimaLand.Domains.global_domain(FT; context, nelements, depth, dz_tuple)
112-
113-
# Parameters
114-
params = LP.LandParameters(FT)
115-
σS_c = FT(0.2)
116-
W_f = FT(0.2)
117-
z_0m = FT(1e-3)
118-
z_0b = FT(1e-3)
119-
κ_soil = FT(1.5)
120-
ρc_soil = FT(2e6)
121-
τc = FT(float(Δt))
122-
α_snow = FT(0.8)
123-
depth = FT(3.5)
124-
bucket_params = (; σS_c, W_f, z_0m, z_0b, κ_soil, ρc_soil, τc, α_snow)
125-
126-
# Model
127-
model = setup_model(FT, start_date, domain, params, bucket_params)
128-
129-
# IC function
130-
function set_ic!(Y, p, t, bucket)
131-
temp_anomaly_amip(coord) = 40 * cosd(coord.lat)^4
132-
# Set temperature IC including anomaly, based on atmospheric setup
133-
T_sfc_0 = 271.0
134-
cds = ClimaCore.Fields.coordinate_field(Y.bucket.T)
135-
@. Y.bucket.T = T_sfc_0 + temp_anomaly_amip(cds)
136-
Y.bucket.W .= 0.15
137-
Y.bucket.Ws .= 0.0
138-
Y.bucket.σS .= 0.0
139-
end
140-
141-
# Define timestepper and ODE algorithm
142-
timestepper = CTS.RK4()
143-
timestepper = CTS.ExplicitAlgorithm(timestepper)
144-
145-
# Create the simulation
146-
simulation = LandSimulation(
147-
FT,
148-
start_date,
149-
stop_date,
150-
Δt,
151-
model;
152-
set_ic!,
153-
timestepper,
154-
outdir,
155-
)
156-
return simulation
96+
Δt = 900.0
97+
start_date = DateTime(2008)
98+
stop_date = DateTime(2010)
99+
nelements = (101, 7)
100+
@info "Run: Global Bucket Model"
101+
@info "Resolution: $nelements"
102+
@info "Timestep: $Δt s"
103+
@info "Start Date: $start_date"
104+
@info "Stop Date: $stop_date"
105+
# Domain
106+
depth = FT(3.5)
107+
dz_tuple = FT.((1.0, 0.05))
108+
domain =
109+
ClimaLand.Domains.global_domain(FT; context, nelements, depth, dz_tuple)
110+
111+
# Parameters
112+
params = LP.LandParameters(FT)
113+
σS_c = FT(0.2)
114+
W_f = FT(0.2)
115+
z_0m = FT(1e-3)
116+
z_0b = FT(1e-3)
117+
κ_soil = FT(1.5)
118+
ρc_soil = FT(2e6)
119+
τc = FT(float(Δt))
120+
α_snow = FT(0.8)
121+
depth = FT(3.5)
122+
bucket_params = (; σS_c, W_f, z_0m, z_0b, κ_soil, ρc_soil, τc, α_snow)
123+
124+
# Model
125+
model = setup_model(FT, start_date, domain, params, bucket_params)
126+
127+
# IC function
128+
function set_ic!(Y, p, t, bucket)
129+
temp_anomaly_amip(coord) = 40 * cosd(coord.lat)^4
130+
# Set temperature IC including anomaly, based on atmospheric setup
131+
T_sfc_0 = 271.0
132+
cds = ClimaCore.Fields.coordinate_field(Y.bucket.T)
133+
@. Y.bucket.T = T_sfc_0 + temp_anomaly_amip(cds)
134+
Y.bucket.W .= 0.15
135+
Y.bucket.Ws .= 0.0
136+
Y.bucket.σS .= 0.0
157137
end
158138

159-
simulation = setup_simulation(; greet = true);
139+
# Define timestepper and ODE algorithm
140+
timestepper = CTS.RK4()
141+
timestepper = CTS.ExplicitAlgorithm(timestepper)
142+
143+
# Create the simulation
144+
simulation = LandSimulation(
145+
FT,
146+
start_date,
147+
stop_date,
148+
Δt,
149+
model;
150+
set_ic!,
151+
timestepper,
152+
outdir,
153+
)
154+
@info "Run: Global Bucket Model"
155+
@info "Resolution: $nelements"
156+
@info "Timestep: $Δt s"
157+
@info "Start Date: $start_date"
158+
@info "Stop Date: $stop_date"
160159
solve!(simulation);
161160

162-
# Eventually replace the below with:
163-
#ClimaLand.Simulations.plot!(simulation, simulation.model, simulation.domain)
164-
165-
# read in diagnostics and make some plots!
166-
#### ClimaAnalysis ####
167161
short_names = ["tsfc", "lhf", "shf", "wsoil"]
168-
include(
169-
joinpath(
170-
pkgdir(ClimaLand),
171-
"experiments",
172-
"long_runs",
173-
"figures_function.jl",
174-
),
162+
LandSimVis.make_annual_timeseries(simulation; savedir = root_path, short_names)
163+
LandSimVis.make_heatmaps(
164+
simulation;
165+
savedir = root_path,
166+
short_names,
167+
date = stop_date,
175168
)
176-
make_figures(root_path, outdir, short_names)

0 commit comments

Comments
 (0)