Skip to content

Commit ef3d4c1

Browse files
committed
Repair a ton of issues
1 parent 705045a commit ef3d4c1

File tree

11 files changed

+180
-139
lines changed

11 files changed

+180
-139
lines changed

docs/tutorials/standalone/Canopy/canopy_tutorial.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ soil_driver = PrescribedGroundConditions(
146146
root_depths = SVector{10, FT}(-(10:-1:1.0) ./ 10.0 * 2.0 .+ 0.2 / 2.0),
147147
ψ = t -> ψ_soil0,
148148
spectral_discretization = TwoBandSpectralDiscretization{FT}(),
149-
α_ground = FT.(0.2, 0.4),
149+
α_ground = FT.((0.2, 0.4)),
150150
T = t -> 298.0,
151151
ϵ = FT(0.99),
152152
);

experiments/standalone/Vegetation/no_vegetation.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ soil_driver = PrescribedGroundConditions(
6262
root_depths = SVector{10, FT}(-(10:-1:1.0) ./ 10.0 * 2.0 .+ 0.2 / 2.0),
6363
ψ = t -> ψ_soil0,
6464
spectral_discretization = spectral_discretization,
65-
α_ground = FT.(0.2, 0.4),
65+
α_ground = FT.((0.2, 0.4)),
6666
T = t -> 298.0,
6767
ϵ = FT(0.99),
6868
);

experiments/standalone/Vegetation/timestep_test.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ soil_driver = PrescribedGroundConditions(
101101
root_depths = SVector{10, FT}(-(10:-1:1.0) ./ 10.0 * 2.0 .+ 0.2 / 2.0),
102102
ψ = t -> ψ_soil0,
103103
spectral_discretization = spectral_discretization,
104-
α_ground = FT.(0.2, 0.4),
104+
α_ground = FT.((0.2, 0.4)),
105105
T = t -> 298.0,
106106
ϵ = FT(0.99),
107107
);

experiments/standalone/Vegetation/varying_lai.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ soil_driver = PrescribedGroundConditions(
6060
root_depths = SVector{10, FT}(-(10:-1:1.0) ./ 10.0 * 2.0 .+ 0.2 / 2.0),
6161
ψ = t -> ψ_soil0,
6262
spectral_discretization = TwoBandSpectralDiscretization{FT}(),
63-
α_ground = FT.(0.2, 0.4),
63+
α_ground = FT.((0.2, 0.4)),
6464
T = t -> 298.0,
6565
ϵ = FT(0.99),
6666
);

experiments/standalone/Vegetation/varying_lai_with_stem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ soil_driver = PrescribedGroundConditions(
6262
root_depths = SVector{10, FT}(-(10:-1:1.0) ./ 10.0 * 2.0 .+ 0.2 / 2.0),
6363
ψ = t -> ψ_soil0,
6464
spectral_discretization = spectral_discretization,
65-
α_ground = FT.(0.2, 0.4),
65+
α_ground = FT.((0.2, 0.4)),
6666
T = t -> 298.0,
6767
ϵ = FT(0.99),
6868
);

ext/CreateParametersExt.jl

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -624,12 +624,21 @@ function TwoStreamParameters(
624624
FT = CP.float_type(toml_dict)
625625
# default value for keyword args must be converted manually
626626
# automatic conversion not possible to Union types
627-
ρ_leaf = FT.(ρ_leaf)
628-
τ_leaf = FT.(τ_leaf)
627+
if typeof(ρ_leaf) <: Tuple
628+
ρ_leaf = FT.(ρ_leaf)
629+
τ_leaf = FT.(τ_leaf)
630+
end
631+
629632
if (isnothing(spectral_discretization))
630633
spectral_discretization = TwoBandSpectralDiscretization{FT}()
631634
end
632-
return TwoStreamParameters{FT, typeof(spectral_discretization), typeof(G_Function), typeof(Ω), typeof(ρ_leaf)}(;
635+
return TwoStreamParameters{
636+
FT,
637+
typeof(spectral_discretization),
638+
typeof(G_Function),
639+
typeof(Ω),
640+
typeof(ρ_leaf),
641+
}(;
633642
G_Function,
634643
spectral_discretization,
635644
ρ_leaf,
@@ -678,12 +687,20 @@ function BeerLambertParameters(
678687
FT = CP.float_type(toml_dict)
679688
# default value for keyword args must be converted manually
680689
# automatic conversion not possible to Union types
681-
ρ_leaf = FT.(ρ_leaf)
690+
if typeof(ρ_leaf) <: Tuple
691+
ρ_leaf = FT.(ρ_leaf)
692+
end
682693
if (isnothing(spectral_discretization))
683694
spectral_discretization = TwoBandSpectralDiscretization{FT}()
684695
end
685-
return BeerLambertParameters{FT, typeof(spectral_discretization), typeof(G_Function), typeof(ρ_leaf)}(;
696+
return BeerLambertParameters{
697+
FT,
698+
typeof(spectral_discretization),
699+
typeof(G_Function),
700+
typeof(ρ_leaf),
701+
}(;
686702
G_Function,
703+
spectral_discretization,
687704
ρ_leaf,
688705
Ω,
689706
parameters...,

src/standalone/Vegetation/Canopy.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,6 @@ function ClimaLand.make_update_aux(
442442
thermo_params = earth_param_set.thermo_params
443443
(; spectral_discretization, G_Function, Ω, λ_γ_PAR) =
444444
canopy.radiative_transfer.parameters
445-
nbands = length(spectral_discretization.λ) - 1
446445
energy_per_mole_photon_par = planck_h * c / λ_γ_PAR * N_a
447446
(; g1, g0, Drel) = canopy.conductance.parameters
448447
area_index = p.canopy.hydraulics.area_index
@@ -457,8 +456,8 @@ function ClimaLand.make_update_aux(
457456
(1 - exp(-(LAI + SAI))) #from CLM 5.0, Tech note 4.20
458457
p.canopy.radiative_transfer.G .= compute_G(G_Function, θs)
459458
RT = canopy.radiative_transfer
460-
compute_PAR!(par_d, RT, bc.radiation, p, t)
461-
compute_NIR!(nir_d, RT, bc.radiation, p, t)
459+
banded_sw_d = (sw_d) -> sw_d .* RT.parameters.spectral_discretization.I
460+
@. SW_d.= banded_sw_d(p.drivers.SW_d)
462461
K = p.canopy.radiative_transfer.K
463462
@. K = extinction_coeff(p.canopy.radiative_transfer.G, θs)
464463
DOY =
@@ -490,10 +489,9 @@ function ClimaLand.make_update_aux(
490489
)
491490

492491
# Extract PAR radiation from radiative transfer output
493-
faPAR = sum(
494-
spectral_discretization.PAR_proportions .*
495-
ntuple((i) -> p.canopy.radiative_transfer.rt[i].abs, nbands),
496-
)
492+
get_PAR = (rt) -> sum(map(x -> x.abs, rt) .* spectral_discretization.PAR_proportions)
493+
faPAR = get_PAR.(p.canopy.radiative_transfer.rt)
494+
497495

498496
# update plant hydraulics aux
499497
hydraulics = canopy.hydraulics
@@ -560,6 +558,8 @@ function ClimaLand.make_update_aux(
560558

561559
# Update Rd, An, Vcmax25 (if applicable to model) in place
562560
Vcmax25 = p.canopy.photosynthesis.Vcmax25
561+
get_par_d = (sw_d) -> sum(sw_d .* spectral_discretization.PAR_proportions)
562+
par_d = get_par_d.(SW_d)
563563
update_photosynthesis!(
564564
Rd,
565565
An,

0 commit comments

Comments
 (0)