Skip to content

Commit 324303d

Browse files
committed
Add LandSimVis to src
1 parent a366651 commit 324303d

File tree

10 files changed

+71
-68
lines changed

10 files changed

+71
-68
lines changed

experiments/integrated/fluxnet/ozark_pft.jl

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ using DelimitedFiles
2828
FluxnetSimulationsExt =
2929
Base.get_extension(ClimaLand, :FluxnetSimulationsExt).FluxnetSimulationsExt;
3030
using CairoMakie, ClimaAnalysis, GeoMakie, Poppler_jll, Printf, StatsBase
31-
LandSimulationVisualizationExt =
32-
Base.get_extension(
33-
ClimaLand,
34-
:LandSimulationVisualizationExt,
35-
).LandSimulationVisualizationExt;
31+
import ClimaLand.LandSimVis as LandSimVis
3632
const FT = Float64
3733
earth_param_set = LP.LandParameters(FT)
3834
climaland_dir = pkgdir(ClimaLand)
@@ -346,7 +342,7 @@ comparison_data =
346342
savedir =
347343
joinpath(pkgdir(ClimaLand), "experiments/integrated/fluxnet/US-MOz/pft/out")
348344
mkpath(savedir)
349-
LandSimulationVisualizationExt.make_diurnal_timeseries(
345+
LandSimVis.make_diurnal_timeseries(
350346
land_domain,
351347
diags,
352348
start_date;
@@ -355,7 +351,7 @@ LandSimulationVisualizationExt.make_diurnal_timeseries(
355351
spinup_date = start_date + Day(N_spinup_days),
356352
comparison_data,
357353
)
358-
LandSimulationVisualizationExt.make_timeseries(
354+
LandSimVis.make_timeseries(
359355
land_domain,
360356
diags,
361357
start_date;

experiments/integrated/fluxnet/run_fluxnet.jl

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@ using DelimitedFiles
2323
FluxnetSimulationsExt =
2424
Base.get_extension(ClimaLand, :FluxnetSimulationsExt).FluxnetSimulationsExt;
2525
using CairoMakie, ClimaAnalysis, GeoMakie, Poppler_jll, Printf, StatsBase
26-
LandSimulationVisualizationExt =
27-
Base.get_extension(
28-
ClimaLand,
29-
:LandSimulationVisualizationExt,
30-
).LandSimulationVisualizationExt;
26+
import ClimaLand.LandSimVis as LandSimVis
3127

3228
const FT = Float64
3329
earth_param_set = LP.LandParameters(FT)
@@ -313,7 +309,7 @@ comparison_data =
313309
savedir =
314310
joinpath(pkgdir(ClimaLand), "experiments/integrated/fluxnet/$(site_ID)/out")
315311
mkpath(savedir)
316-
LandSimulationVisualizationExt.make_diurnal_timeseries(
312+
LandSimVis.make_diurnal_timeseries(
317313
land_domain,
318314
diags,
319315
start_date;
@@ -322,7 +318,7 @@ LandSimulationVisualizationExt.make_diurnal_timeseries(
322318
spinup_date = start_date + Day(N_spinup_days),
323319
comparison_data,
324320
)
325-
LandSimulationVisualizationExt.make_timeseries(
321+
LandSimVis.make_timeseries(
326322
land_domain,
327323
diags,
328324
start_date;

experiments/long_runs/bucket.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,7 @@ using Dates
3434
import NCDatasets
3535

3636
using CairoMakie, GeoMakie, Poppler_jll, ClimaAnalysis
37-
LandSimVis =
38-
Base.get_extension(
39-
ClimaLand,
40-
:LandSimulationVisualizationExt,
41-
).LandSimulationVisualizationExt;
37+
import ClimaLand.LandSimVis as LandSimVis
4238

4339
const FT = Float64;
4440
time_interpolation_method = LinearInterpolation(PeriodicCalendar())

experiments/long_runs/land_region.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,7 @@ import ClimaLand.Simulations: LandSimulation, solve!
3838
using Dates
3939

4040
using CairoMakie, GeoMakie, Poppler_jll, ClimaAnalysis
41-
LandSimVis =
42-
Base.get_extension(
43-
ClimaLand,
44-
:LandSimulationVisualizationExt,
45-
).LandSimulationVisualizationExt;
41+
import ClimaLand.LandSimVis as LandSimVis
4642

4743
const FT = Float64;
4844
context = ClimaComms.context()

experiments/long_runs/snowy_land.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,7 @@ import ClimaLand.Simulations: LandSimulation, solve!
4040
using Dates
4141

4242
using CairoMakie, GeoMakie, Poppler_jll, ClimaAnalysis
43-
LandSimVis =
44-
Base.get_extension(
45-
ClimaLand,
46-
:LandSimulationVisualizationExt,
47-
).LandSimulationVisualizationExt;
43+
import ClimaLand.LandSimVis as LandSimVis
4844

4945
const FT = Float64;
5046
# If you want to do a very long run locally, you can enter `export

experiments/long_runs/soil.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,7 @@ import ClimaLand.Simulations: LandSimulation, solve!
3535
using Dates
3636

3737
using CairoMakie, GeoMakie, Poppler_jll, ClimaAnalysis
38-
LandSimVis =
39-
Base.get_extension(
40-
ClimaLand,
41-
:LandSimulationVisualizationExt,
42-
).LandSimulationVisualizationExt;
38+
import ClimaLand.LandSimVis as LandSimVis
4339

4440
const FT = Float64;
4541
# If you want to do a very long run locally, you can enter `export

ext/LandSimulationVisualizationExt.jl

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
module LandSimulationVisualizationExt
2+
3+
import ClimaLand.LandSimVis as LandSimVis
24
import ClimaDiagnostics
35
import ClimaAnalysis
46
import ClimaAnalysis.Visualize as viz
@@ -22,13 +24,13 @@ include("land_sim_vis/leaderboard/leaderboard.jl")
2224
Uses the diagnostic output of the `sim` to create leaderboard plots, comparing the output of the simulation to the ``observations"
2325
from ERA5 or ILAMB.
2426
"""
25-
function make_leaderboard_plots(
27+
function LandSimVis.make_leaderboard_plots(
2628
sim::ClimaLand.Simulations.LandSimulation;
2729
savedir = ".",
2830
leaderboard_data_sources = ["ERA5", "ILAMB"],
2931
)
3032
model = sim.model
31-
make_leaderboard_plots(
33+
LandSimVis.make_leaderboard_plots(
3234
model,
3335
ClimaLand.get_domain(model),
3436
sim.diagnostics;
@@ -42,7 +44,7 @@ end
4244
4345
A default method for `make_leaderboard_plots` notifying the user that these plots have not been enable for their domain/model combination.
4446
"""
45-
function make_leaderboard_plots(m, d, diag)
47+
function LandSimVis.make_leaderboard_plots(m, d, diag)
4648
@info "Leaderboard plots not configured for your model type and/or your model domain. Model type must be LandModel, and the domain must be global."
4749
end
4850

@@ -61,7 +63,7 @@ saves the output to files in `savedir`.
6163
6264
The first two arguments are used for dispatch only.
6365
"""
64-
function make_leaderboard_plots(
66+
function LandSimVis.make_leaderboard_plots(
6567
model::ClimaLand.LandModel,
6668
domain::ClimaLand.Domains.SphericalShell,
6769
diagnostics;
@@ -113,7 +115,7 @@ be plotted at each level specified. Note that level = 1 corresponds to the top l
113115
and that the function will error if you provide a level not included in the output.
114116
Passing levels = nothing defaults to plotting surface values of 3D fields.
115117
"""
116-
function make_heatmaps(
118+
function LandSimVis.make_heatmaps(
117119
sim::ClimaLand.Simulations.LandSimulation;
118120
savedir = ".",
119121
short_names = nothing,
@@ -122,7 +124,7 @@ function make_heatmaps(
122124
plot_name = "figures.pdf",
123125
)
124126
model = sim.model
125-
make_heatmaps(
127+
LandSimVis.make_heatmaps(
126128
model,
127129
ClimaLand.get_domain(model),
128130
sim.diagnostics;
@@ -134,7 +136,7 @@ function make_heatmaps(
134136
)
135137
end
136138

137-
function make_heatmaps(
139+
function LandSimVis.make_heatmaps(
138140
model::ClimaLand.AbstractModel,
139141
domain::Union{
140142
ClimaLand.Domains.SphericalShell,
@@ -155,10 +157,17 @@ function make_heatmaps(
155157
elseif short_names isa Nothing
156158
short_names = avail_short_names
157159
end
158-
make_heatmaps(savedir, diagdir, short_names, date; plot_name, levels)
160+
LandSimVis.make_heatmaps(
161+
savedir,
162+
diagdir,
163+
short_names,
164+
date;
165+
plot_name,
166+
levels,
167+
)
159168
end
160169

161-
function make_heatmaps(
170+
function LandSimVis.make_heatmaps(
162171
model::ClimaLand.AbstractModel,
163172
domain::Union{ClimaLand.Domains.HybridBox, ClimaLand.Domains.Plane},
164173
diagnostics;
@@ -176,7 +185,7 @@ function make_heatmaps(
176185
elseif short_names isa Nothing
177186
short_names = avail_short_names
178187
end
179-
make_heatmaps(
188+
LandSimVis.make_heatmaps(
180189
savedir,
181190
diagdir,
182191
short_names,
@@ -192,7 +201,7 @@ function make_heatmaps(
192201
end
193202

194203

195-
function make_heatmaps(
204+
function LandSimVis.make_heatmaps(
196205
model::ClimaLand.AbstractModel,
197206
domain::Union{ClimaLand.Domains.Point, ClimaLand.Domains.Column},
198207
diagnostics;
@@ -223,14 +232,14 @@ Please note that
223232
case all possible variables will be plotted
224233
- The top layer of 3D variables is used for plotting.
225234
"""
226-
function make_annual_timeseries(
235+
function LandSimVis.make_annual_timeseries(
227236
sim::ClimaLand.Simulations.LandSimulation;
228237
savedir = ".",
229238
short_names = nothing,
230239
plot_name = "annual_timeseries.pdf",
231240
)
232241
model = sim.model
233-
make_annual_timeseries(
242+
LandSimVis.make_annual_timeseries(
234243
ClimaLand.get_domain(model),
235244
sim.diagnostics;
236245
plot_name,
@@ -239,7 +248,7 @@ function make_annual_timeseries(
239248
)
240249
end
241250

242-
function make_annual_timeseries(
251+
function LandSimVis.make_annual_timeseries(
243252
domain::ClimaLand.Domains.AbstractDomain,
244253
diagnostics;
245254
plot_name = "annual_timeseries.pdf",
@@ -249,7 +258,7 @@ function make_annual_timeseries(
249258
@info "No method matching make_annual_timeseries for $domain."
250259
end
251260

252-
function make_annual_timeseries(
261+
function LandSimVis.make_annual_timeseries(
253262
domain::Union{
254263
ClimaLand.Domains.SphericalShell,
255264
ClimaLand.Domains.SphericalSurface,
@@ -302,7 +311,7 @@ Please note that
302311
case all possible variables will be plotted
303312
- The top layer of 3D variables is used for plotting.
304313
"""
305-
function make_diurnal_timeseries(
314+
function LandSimVis.make_diurnal_timeseries(
306315
sim::ClimaLand.Simulations.LandSimulation;
307316
savedir = ".",
308317
short_names = nothing,
@@ -311,7 +320,7 @@ function make_diurnal_timeseries(
311320
spinup_date = sim.start_date,
312321
)
313322
model = sim.model
314-
make_diurnal_timeseries(
323+
LandSimVis.make_diurnal_timeseries(
315324
ClimaLand.get_domain(model),
316325
sim.diagnostics,
317326
sim.start_date;
@@ -323,7 +332,7 @@ function make_diurnal_timeseries(
323332
)
324333
end
325334

326-
function make_diurnal_timeseries(
335+
function LandSimVis.make_diurnal_timeseries(
327336
domain::ClimaLand.Domains.AbstractDomain,
328337
diagnostics,
329338
start_date;
@@ -336,7 +345,7 @@ function make_diurnal_timeseries(
336345
@info "No method matching make_diurnal_timeseries for $domain."
337346
end
338347

339-
function make_diurnal_timeseries(
348+
function LandSimVis.make_diurnal_timeseries(
340349
domain::Union{ClimaLand.Domains.Column, ClimaLand.Domains.Point},
341350
diagnostics,
342351
start_date;
@@ -354,7 +363,7 @@ function make_diurnal_timeseries(
354363
short_names = avail_short_names
355364
end
356365
diag_ids = [findfirst(sn .== avail_short_names) for sn in short_names]
357-
make_diurnal_timeseries(
366+
LandSimVis.make_diurnal_timeseries(
358367
savedir,
359368
diagnostics[diag_ids], # To be consistent with global/regional runs, this should be a directory with the saved diagnostics.
360369
start_date;
@@ -391,7 +400,7 @@ Please note that
391400
case all possible variables will be plotted
392401
- The top layer of 3D variables is used for plotting.
393402
"""
394-
function make_timeseries(
403+
function LandSimVis.make_timeseries(
395404
sim::ClimaLand.Simulations.LandSimulation;
396405
savedir = ".",
397406
short_names = nothing,
@@ -400,7 +409,7 @@ function make_timeseries(
400409
spinup_date = sim.start_date,
401410
)
402411
model = sim.model
403-
make_timeseries(
412+
LandSimVis.make_timeseries(
404413
ClimaLand.get_domain(model),
405414
sim.diagnostics,
406415
sim.start_date;
@@ -412,7 +421,7 @@ function make_timeseries(
412421
)
413422
end
414423

415-
function make_timeseries(
424+
function LandSimVis.make_timeseries(
416425
domain::ClimaLand.Domains.AbstractDomain,
417426
diagnostics,
418427
start_date;
@@ -425,7 +434,7 @@ function make_timeseries(
425434
@info "No method matching make_timeseries for $domain."
426435
end
427436

428-
function make_timeseries(
437+
function LandSimVis.make_timeseries(
429438
domain::Union{ClimaLand.Domains.Column, ClimaLand.Domains.Point},
430439
diagnostics,
431440
start_date;
@@ -443,7 +452,7 @@ function make_timeseries(
443452
short_names = avail_short_names
444453
end
445454
diag_ids = [findfirst(sn .== avail_short_names) for sn in short_names]
446-
make_timeseries(
455+
LandSimVis.make_timeseries(
447456
savedir,
448457
diagnostics[diag_ids],# To be consistent with global/regional runs, this should be a directory with the saved diagnostics.
449458
start_date;
@@ -459,13 +468,13 @@ end
459468
Creates a plot which assess conservation of energy and water by the simulation;
460469
the outut is saved in `savedir`.
461470
"""
462-
function check_conservation(
471+
function LandSimVis.check_conservation(
463472
sim::ClimaLand.Simulations.LandSimulation;
464473
savedir = ".",
465474
plot_name = "conservation_figures.pdf",
466475
)
467476
model = sim.model
468-
check_conservation(
477+
LandSimVis.check_conservation(
469478
model,
470479
ClimaLand.get_domain(model),
471480
sim.diagnostics,
@@ -474,19 +483,19 @@ function check_conservation(
474483
)
475484
end
476485

477-
function check_conservation(m, d, diags, o, pn)
486+
function LandSimVis.check_conservation(m, d, diags, o, pn)
478487
@info "Conservation checks not configured for your model type and/or your model domain yet. Model type must be EnergyHydrology, and the domain must be global."
479488
end
480489

481-
function check_conservation(
490+
function LandSimVis.check_conservation(
482491
model::ClimaLand.Soil.EnergyHydrology,
483492
domain::ClimaLand.Domains.SphericalShell,
484493
diagnostics,
485494
savedir,
486495
plot_name,
487496
)
488497
diagdir = first(diagnostics).output_writer.output_dir
489-
check_conservation(savedir, diagdir; plot_name)
498+
LandSimVis.check_conservation(savedir, diagdir; plot_name)
490499

491500
end
492501

0 commit comments

Comments
 (0)