Skip to content

Commit 75991d8

Browse files
authored
remove CairoMakie, alter US-MOz params, allocation removal (#957)
1 parent 2e1c1af commit 75991d8

File tree

13 files changed

+356
-556
lines changed

13 files changed

+356
-556
lines changed

.buildkite/Manifest-v1.11.toml

Lines changed: 2 additions & 299 deletions
Large diffs are not rendered by default.

.buildkite/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
2929
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
3030
NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab"
3131
NLsolve = "2774e3e8-f4cf-5e23-947b-6d7e65073b56"
32-
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
3332
Poppler_jll = "9c32591e-4766-534b-9725-b71a8799265b"
3433
ProfileCanvas = "efd6af41-a80b-495e-886c-e51b0c7d77a3"
3534
RootSolvers = "7181ea78-2dcb-4de3-ab41-2b8ab5a31e74"
@@ -47,3 +46,4 @@ cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd"
4746
ClimaAnalysis = "0.5.12"
4847
ClimaTimeSteppers = "0.7"
4948
Statistics = "1"
49+
Flux = "0.15"

experiments/integrated/fluxnet/US-MOz/US-MOz_parameters.jl

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ lat = FT(38.7441) # degree
1515
long = FT(-92.2000) # degree
1616

1717
# Soil parameters
18-
soil_ν = FT(0.5) # m3/m3
19-
soil_K_sat = FT(4e-7) # m/s, matches Natan
20-
soil_S_s = FT(1e-3) # 1/m, guess
21-
soil_vg_n = FT(2.05) # unitless
22-
soil_vg_α = FT(0.04) # inverse meters
23-
θ_r = FT(0.067) # m3/m3, from Wang et al. 2021 https://doi.org/10.5194/gmd-14-6741-2021
18+
soil_ν = FT(0.55) # m3/m3
19+
soil_K_sat = FT(4e-7) # m/s
20+
soil_S_s = FT(1e-2) # 1/m, guess
21+
soil_vg_n = FT(2.0) # unitless
22+
soil_vg_α = FT(0.05) # inverse meters
23+
θ_r = FT(0.04) # m3/m3,
2424

2525
# Soil makeup
2626
ν_ss_quartz = FT(0.1)
@@ -44,23 +44,25 @@ G_Function = CLMGFunction(χl)
4444
ϵ_canopy = FT(0.97)
4545

4646
# Energy Balance model
47-
ac_canopy = FT(7.5e3)
47+
ac_canopy = FT(5e2)
4848

4949
# Conductance Model
5050
g1 = FT(141) # Wang et al: 141 sqrt(Pa) for Medlyn model; Natan used 300.
5151
Drel = FT(1.6)
5252
g0 = FT(1e-4)
5353

5454
#Photosynthesis model
55-
Vcmax25 = FT(9e-5) # from Yujie's paper 4.5e-5 , Natan used 9e-5
55+
Vcmax25 = FT(4.5e-5) # from Yujie's paper 4.5e-5
5656

5757
# Plant Hydraulics and general plant parameters
58+
pc = FT(-2.5e6)
59+
sc = FT(5e-6)
5860
SAI = FT(1.0) # m2/m2 or: estimated from Wang et al, FT(0.00242) ?
5961
f_root_to_shoot = FT(3.5)
60-
K_sat_plant = 5e-9 # m/s # seems much too small?
62+
K_sat_plant = 3e-9 # m/s
6163
ψ63 = FT(-4 / 0.0098) # / MPa to m, Holtzman's original parameter value is -4 MPa
6264
Weibull_param = FT(4) # unitless, Holtzman's original c param value
63-
a = FT(0.05 * 0.0098) # Holtzman's original parameter for the bulk modulus of elasticity
65+
a = FT(0.1 * 0.0098) # Holtzman's original parameter for the bulk modulus of elasticity
6466
conductivity_model =
6567
PlantHydraulics.Weibull{FT}(K_sat_plant, ψ63, Weibull_param)
6668
retention_model = PlantHydraulics.LinearRetentionCurve{FT}(a)

experiments/integrated/fluxnet/US-MOz/US-MOz_simulation.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ variables for running the simulation."""
66

77
# Column dimensions - separation of layers at the top and bottom of the column:
88
dz_bottom = FT(1.5)
9-
dz_top = FT(0.025)
9+
dz_top = FT(0.1)
1010

1111
# Stem and leaf compartments and their heights:
1212
n_stem = Int64(1)
@@ -20,4 +20,4 @@ h_leaf = FT(9.5) # m
2020
t0 = Float64(0)
2121

2222
# Time step size:
23-
dt = Float64(450)
23+
dt = Float64(1800)

experiments/integrated/fluxnet/data_tools.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ function filter_column(driver_data::Matrix, column_name::String, units::String)
109109
# Check that the data exists and read it in if so
110110
col_dat, status = column_status(driver_data, column_name)
111111
# Set missing data threshold above which column is treated as absent
112-
missing_threshold = 0.5
112+
missing_threshold = 10.0
113113
# Set poor quality threshold above which the column undergoes no replacement using the quality flag
114-
quality_threshold = 0.5
114+
quality_threshold = 10.0
115115
# if it does not exist, exit
116116
if status == absent
117117
@info "Warning: Data for $column_name is absent"

experiments/integrated/fluxnet/ozark_pft.jl

Lines changed: 58 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import SciMLBase
99
import ClimaTimeSteppers as CTS
1010
using ClimaCore
1111
import ClimaParams as CP
12-
using Plots
12+
using CairoMakie
1313
using Statistics
1414
using Dates
1515
using Insolation
@@ -299,7 +299,7 @@ output_dir = ClimaUtilities.OutputPathGenerator.generate_output_path(outdir)
299299

300300
d_writer = ClimaDiagnostics.Writers.DictWriter()
301301

302-
ref_time = DateTime(2005) # random. not sure what it should be
302+
ref_time = DateTime(2010)
303303

304304
diags = ClimaLand.default_diagnostics(
305305
land,
@@ -353,7 +353,6 @@ short_names_1D = [
353353
"ghf", # G
354354
"rn", # Rn
355355
]
356-
357356
short_names_2D = [
358357
"swc", # swc_sfc or swc_5 or swc_10
359358
"tsoil", # soil_T_sfc or soil_T_5 or soil_T_10
@@ -557,78 +556,88 @@ end
557556
# Water content in soil and snow
558557
# Soil water content
559558
# Current resolution has the first layer at 0.1 cm, the second at 5cm.
560-
plt1 = Plots.plot(size = (1500, 800))
561-
Plots.plot!(
562-
plt1,
563-
model_times ./ 3600 ./ 24,
564-
swc,
565-
label = "1.25cm",
566-
xlim = [
567-
minimum(model_times ./ 3600 ./ 24),
568-
maximum(model_times ./ 3600 ./ 24),
569-
],
570-
ylim = [0.05, 0.55],
571-
xlabel = "Days",
572-
ylabel = "SWC [m/m]",
573-
color = "blue",
574-
margin = 10Plots.mm,
559+
fig = Figure(size = (1500, 800), fontsize = 20)
560+
ax1 = Axis(fig[2, 1], xlabel = "Days", ylabel = "SWC [m/m]")
561+
limits!(
562+
ax1,
563+
minimum(model_times ./ 3600 ./ 24),
564+
maximum(model_times ./ 3600 ./ 24),
565+
0.05,
566+
0.6,
575567
)
576-
577-
plot!(
578-
plt1,
568+
lines!(ax1, model_times ./ 3600 ./ 24, swc, label = "1.25cm", color = "blue")
569+
lines!(
570+
ax1,
579571
model_times ./ 3600 ./ 24,
580572
si,
581573
color = "cyan",
582574
label = "Ice, 1.25cm",
583575
)
584576

585577
if drivers.SWC.status != absent
586-
Plots.plot!(
587-
plt1,
578+
lines!(
579+
ax1,
588580
data_times ./ 3600 ./ 24,
589581
drivers.SWC.values[data_id_post_spinup],
590582
label = "Data",
591583
)
592584
end
593-
plt2 = Plots.plot(
594-
data_times ./ 3600 ./ 24,
595-
(drivers.P.values .* (-1e3 * 24 * 3600))[data_id_post_spinup],
596-
label = "",
585+
586+
ax2 = Axis(
587+
fig[1, 1],
588+
xlabel = "",
597589
ylabel = "Precipitation [mm/day]",
598-
xlim = [
599-
minimum(model_times ./ 3600 ./ 24),
600-
maximum(model_times ./ 3600 ./ 24),
601-
],
602-
margin = 10Plots.mm,
603-
ylim = [-200, 0],
604-
size = (1500, 400),
590+
xticklabelsvisible = false,
591+
)
592+
limits!(
593+
ax2,
594+
minimum(model_times ./ 3600 ./ 24),
595+
maximum(model_times ./ 3600 ./ 24),
596+
-500,
597+
0.0,
605598
)
606599

607-
Plots.plot(plt2, plt1, layout = grid(2, 1, heights = [0.3, 0.7]))
608-
Plots.savefig(joinpath(savedir, "ground_water_content.png"))
600+
lines!(
601+
ax2,
602+
data_times ./ 3600 ./ 24,
603+
(drivers.P.values .* (-1e3 * 24 * 3600) .* (1 .- snow_frac))[data_id_post_spinup],
604+
label = "Rain (data)",
605+
)
606+
lines!(
607+
ax2,
608+
data_times ./ 3600 ./ 24,
609+
(drivers.P.values .* (-1e3 * 24 * 3600) .* snow_frac)[data_id_post_spinup],
610+
label = "Snow (data)",
611+
)
612+
CairoMakie.save(joinpath(savedir, "ground_water_content.png"), fig)
613+
609614

610-
plt1 = Plots.plot(size = (1500, 800))
611-
Plots.plot!(
612-
plt1,
615+
616+
fig2 = Figure(size = (1500, 800))
617+
ax12 = Axis(fig2[1, 1], xlabel = "Days", ylabel = "Temperature (K)")
618+
limits!(
619+
ax12,
620+
minimum(model_times ./ 3600 ./ 24),
621+
maximum(model_times ./ 3600 ./ 24),
622+
265,
623+
315,
624+
)
625+
626+
lines!(
627+
ax12,
613628
model_times ./ 3600 ./ 24,
614629
soil_T,
615630
label = "1.25cm",
616-
xlim = [
617-
minimum(model_times ./ 3600 ./ 24),
618-
maximum(model_times ./ 3600 ./ 24),
619-
],
620-
xlabel = "Days",
621-
ylabel = "Temperature (K)",
622631
color = "blue",
623-
margin = 10Plots.mm,
624632
)
633+
625634
if drivers.TS.status != absent
626-
Plots.plot!(
627-
plt1,
635+
lines!(
636+
ax12,
628637
data_times ./ 3600 ./ 24,
629638
drivers.TS.values[data_id_post_spinup],
630639
label = "Data",
631640
)
632641
end
633642

634-
Plots.savefig(joinpath(savedir, "soil_temperature.png"))
643+
CairoMakie.save(joinpath(savedir, "soil_temperature.png"), fig2)

experiments/integrated/fluxnet/plot_utils.jl

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Plotting utilities for the integrated fluxnet site experiments"""
22

33
using Interpolations
4-
using Plots
4+
using CairoMakie
55
using StatsBase
66

77
S_PER_DAY = 86400 # Number of seconds in a day
@@ -61,17 +61,16 @@ function plot_daily_avg(
6161
compute_diurnal_avg(data, [0:data_dt:(num_days * S_PER_DAY);], num_days)
6262

6363
# Plot the data diurnal cycle
64-
plt = Plots.plot(size = (800, 400))
65-
Plots.plot!(
66-
plt,
67-
0.5:0.5:24,
68-
data_hh_avg,
69-
label = label,
64+
fig = CairoMakie.Figure(size = (800, 400))
65+
ax = CairoMakie.Axis(
66+
fig[1, 1],
7067
xlabel = "Hour of day",
7168
ylabel = "$var_name $(unit)",
7269
title = "$var_name",
7370
)
74-
Plots.savefig(joinpath(savedir, "$(var_name)_avg.png"))
71+
CairoMakie.lines!(ax, Array(0.5:0.5:24), data_hh_avg[:], label = label)
72+
axislegend(ax, position = :lt)
73+
CairoMakie.save(joinpath(savedir, "$(var_name)_avg.png"), fig)
7574
end
7675

7776
"""This function will be used to plot the comparison of the diurnal average of a
@@ -101,17 +100,17 @@ function plot_avg_comp(
101100
= StatsBase.cor(model_hh_avg, data_hh_avg)^2
102101

103102
# Plot the model and data diurnal cycles
104-
plt = Plots.plot(size = (800, 400))
105-
Plots.plot!(
106-
plt,
107-
0.5:0.5:24,
108-
model_hh_avg,
109-
label = "Model",
103+
fig = CairoMakie.Figure(size = (800, 400))
104+
ax = CairoMakie.Axis(
105+
fig[1, 1],
110106
xlabel = "Hour of day",
111107
ylabel = "$var_name $(units)",
112108
title = "$var_name: RMSD = $(round(RMSD, digits = 2)), R² = $(round(R²[1][1], digits = 2))",
113-
legend = :topleft,
114109
)
115-
Plots.plot!(plt, 0.5:0.5:24, data_hh_avg, label = "Data")
116-
Plots.savefig(joinpath(savedir, "$(var_name)_avg.png"))
110+
CairoMakie.lines!(ax, Array(0.5:0.5:24), model_hh_avg[:], label = "Model")
111+
112+
CairoMakie.lines!(ax, Array(0.5:0.5:24), data_hh_avg[:], label = "Data")
113+
axislegend(ax, position = :lt)
114+
115+
CairoMakie.save(joinpath(savedir, "$(var_name)_avg.png"), fig)
117116
end

0 commit comments

Comments
 (0)