Skip to content

Commit 705045a

Browse files
committed
Resolve type issues for radiation parameters structs
1 parent 72f2ec1 commit 705045a

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

docs/tutorials/integrated/soil_canopy_tutorial.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ radiative_transfer_args = (;
225225
G_Function = ConstantGFunction(FT(0.5)),
226226
ρ_leaf = FT.((0.1, 0.45)),
227227
τ_leaf = FT.((0.05, 0.25)),
228-
Ω = 0.69,
228+
Ω = FT(0.69),
229229
)
230230
)
231231

ext/CreateParametersExt.jl

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -582,20 +582,18 @@ end
582582
"""
583583
function TwoStreamParameters(FT::AbstractFloat;
584584
ld = (_) -> 0.5,
585-
ρ_PAR_leaf = 0.3,
586-
τ_PAR_leaf = 0.2,
587-
ρ_NIR_leaf = 0.4,
588-
τ_NIR_leaf = 0.25,
585+
spectral_discretization = TwoBandSpectralDiscretization{FT}(),
586+
ρ_leaf = (0.3, 0.4),
587+
τ_leaf = (0.2, 0.25),
589588
Ω = 1,
590589
n_layers = UInt64(20),
591590
kwargs...
592591
)
593592
function TwoStreamParameters(toml_dict;
594593
ld = (_) -> 0.5,
595-
ρ_PAR_leaf = 0.3,
596-
τ_PAR_leaf = 0.2,
597-
ρ_NIR_leaf = 0.4,
598-
τ_NIR_leaf = 0.25,
594+
spectral_discretization = TwoBandSpectralDiscretization{FT}(),
595+
ρ_leaf = (0.3, 0.4),
596+
τ_leaf = (0.2, 0.25),
599597
Ω = 1,
600598
n_layers = UInt64(20),
601599
kwargs...
@@ -610,6 +608,7 @@ TwoStreamParameters(::Type{FT}; kwargs...) where {FT <: AbstractFloat} =
610608
function TwoStreamParameters(
611609
toml_dict::CP.AbstractTOMLDict;
612610
G_Function = ConstantGFunction(CP.float_type(toml_dict)(0.5)),
611+
spectral_discretization = nothing,
613612
ρ_leaf::F = (0.3, 0.4),
614613
τ_leaf::F = (0.2, 0.25),
615614
Ω = 1,
@@ -627,8 +626,12 @@ function TwoStreamParameters(
627626
# automatic conversion not possible to Union types
628627
ρ_leaf = FT.(ρ_leaf)
629628
τ_leaf = FT.(τ_leaf)
630-
return TwoStreamParameters{FT, typeof(G_Function), typeof(ρ_PAR_leaf)}(;
629+
if (isnothing(spectral_discretization))
630+
spectral_discretization = TwoBandSpectralDiscretization{FT}()
631+
end
632+
return TwoStreamParameters{FT, typeof(spectral_discretization), typeof(G_Function), typeof(Ω), typeof(ρ_leaf)}(;
631633
G_Function,
634+
spectral_discretization,
632635
ρ_leaf,
633636
τ_leaf,
634637
Ω,
@@ -661,6 +664,7 @@ BeerLambertParameters(::Type{FT}; kwargs...) where {FT <: AbstractFloat} =
661664
function BeerLambertParameters(
662665
toml_dict::CP.AbstractTOMLDict;
663666
G_Function = ConstantGFunction(CP.float_type(toml_dict)(0.5)),
667+
spectral_discretization = nothing,
664668
ρ_leaf::F = (0.1, 0.4),
665669
Ω = 1,
666670
kwargs...,
@@ -675,7 +679,10 @@ function BeerLambertParameters(
675679
# default value for keyword args must be converted manually
676680
# automatic conversion not possible to Union types
677681
ρ_leaf = FT.(ρ_leaf)
678-
return BeerLambertParameters{FT, typeof(G_Function), typeof(ρ_leaf)}(;
682+
if (isnothing(spectral_discretization))
683+
spectral_discretization = TwoBandSpectralDiscretization{FT}()
684+
end
685+
return BeerLambertParameters{FT, typeof(spectral_discretization), typeof(G_Function), typeof(ρ_leaf)}(;
679686
G_Function,
680687
ρ_leaf,
681688
Ω,

0 commit comments

Comments
 (0)