Skip to content

Commit 732bc23

Browse files
committed
Repair NTuple construction
1 parent af998e8 commit 732bc23

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

src/standalone/Vegetation/canopy_parameterizations.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,7 @@ function canopy_sw_rt_two_stream(
400400

401401
# Convert fractional absorption into absorption and return
402402
# Ensure floating point precision is correct (it may be different for PAR)
403-
F_trans = NTuple{length(α_soil), FT}(undef)
404-
@. F_trans = FT((1 - F_abs - F_refl) / (1 - α_soil))
403+
F_trans = FT.((1 .- F_abs .- F_refl) ./ (1 .- α_soil))
405404
return ntuple(
406405
i -> (;
407406
abs = FT(F_abs[i]),

test/standalone/Vegetation/hyperspectral_radiation.jl

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ for FT in (Float32, Float64)
1717
# Set up radiative transfer using 16 band discretization
1818
spectral_discretization = HyperspectralDiscretization{FT}()
1919
ρ_leaf = FT.(ntuple(_ -> 0.0, 16))
20-
RTparams = BeerLambertParameters(FT;
21-
spectral_discretization,
22-
ρ_leaf,
23-
)
20+
RTparams = BeerLambertParameters(FT; spectral_discretization, ρ_leaf)
2421

2522
# Drivers
2623
θs = FT.(Array(0:0.1:/ 2)))
@@ -29,19 +26,27 @@ for FT in (Float32, Float64)
2926
α_soil = FT.(ntuple(_ -> 0.0, 16))
3027

3128
# Test that radiative transfer works
32-
output = canopy_sw_rt_beer_lambert.(
33-
RTparams.Ω,
34-
(RTparams.ρ_leaf,),
35-
LAI,
36-
K_c,
37-
(α_soil,),
38-
)
29+
output =
30+
canopy_sw_rt_beer_lambert.(
31+
RTparams.Ω,
32+
(RTparams.ρ_leaf,),
33+
LAI,
34+
K_c,
35+
(α_soil,),
36+
)
3937

4038
@test length(output) == length(θs)
4139
@test length(output[1]) == 16
4240
get_PAR_sum =
43-
(rt, sym, PAR_coeff) -> sum(map(x -> getproperty(x, sym), rt) .* PAR_coeff)
44-
@test all(get_PAR_sum.(output, :refl, RTparams.spectral_discretization.PAR_proportions) .< 1e-6)
41+
(rt, sym, PAR_coeff) ->
42+
sum(map(x -> getproperty(x, sym), rt) .* PAR_coeff)
43+
@test all(
44+
get_PAR_sum.(
45+
output,
46+
:refl,
47+
RTparams.spectral_discretization.PAR_proportions,
48+
) .< 1e-6,
49+
)
4550

4651
end
4752
end

0 commit comments

Comments
 (0)