Skip to content

Commit 79444b5

Browse files
committed
Repair NTuple construction
1 parent af998e8 commit 79444b5

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

src/standalone/Vegetation/canopy_parameterizations.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +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)
403+
F_trans = ntuple(_ -> FT(0.0), length(α_soil))
404404
@. F_trans = FT((1 - F_abs - F_refl) / (1 - α_soil))
405405
return ntuple(
406406
i -> (;
@@ -428,7 +428,7 @@ Note that cos(θs) is equal to zero when θs = π/2, and this is a coefficient
428428
of k₀, which we divide by in this expression. This can amplify small errors
429429
when θs is near π/2.
430430
431-
This formula is empirical and can yied negative numbers depending on the
431+
This formula is empirical and can yield negative numbers depending on the
432432
input, which, when dividing by something very near zero,
433433
can become large negative numbers.
434434

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)