Canopy Structure & Scattering

Canopy radiative-transfer geometry in CanopyOptics combines continuous leaf-angle distributions (AbstractLeafDistribution), clumping and hotspot gap corrections, multi-component leaf/wood mixtures (MixedCanopy), and cosine Fourier scattering matrices $Z[i_{\mathrm{out}}, j_{\mathrm{in}}]$ across bi-Lambertian, dorsiventral, specular, and coupled $4\times 4$ leaf-BSDF scattering laws.

Z-Matrix Single-Scattering Albedo Conventions

  • Symmetric bi-Lambertian (BiLambertianCanopyScattering, LambertianWoodCanopyScattering): Scalar single-scattering albedo $\varpi = R + T$ is divided out of Z so downstream layer solvers multiply by $\varpi$ separately; every non-black ($R + T > 0$) leaf satisfies

    \[\frac{1}{2} \sum_i w_i \bigl(Z^{++}_{ij,0} + Z^{-+}_{ij,0}\bigr) \simeq 1\]

    (identically $= 1$ under DiscreteAngularNormalization).
  • Dorsiventral & coupled BSDF (compute_Z_matrices_directional, compute_Z_matrices_coupled_bsdf): By default (normalize_by_ω = false), Z is normalized by $G(\mu_{\mathrm{in}})$ only and retains directional albedo inside Z,

    \[\frac{1}{2} \sum_i w_i \bigl(Z^{++}_{ij,0} + Z^{-+}_{ij,0}\bigr) \simeq \omega_{\mathrm{down},j},\]

    composing directly without $\varpi$-mixing ambiguities.
  • Pure surface specular (SpecularCanopyScattering): Retains Fresnel/microfacet reflectance strength directly inside Z in the right-handed $(\mathbf{e}_s, \mathbf{e}_p, \mathbf{k})$ meridian Stokes basis.

Directions & Angular Quadrature

CanopyOptics.DirectionCosine — Type
DirectionCosine{FT}(μ, ϕ)
DirectionCosine(; μ = nothing, θ = nothing, ϕ = 0)

Represent a unit spherical direction by polar cosine $\mu = \cos\theta \in [-1, 1]$ and azimuth angle ϕ in radians.

Passing keyword θ instead of μ computes μ = cos(θ) (see also direction_from_angles).

Fields

  • μ::FT: polar cosine $\cos\theta$ in $[-1, 1]$.
  • ϕ::FT: azimuth angle in radians.

Examples

julia> DirectionCosine(0.8, 0.0)
DirectionCosine{Float64}(0.8, 0.0)
source
CanopyOptics.direction_from_angles — Function
direction_from_angles(θ, ϕ)

Construct a DirectionCosine from polar/zenith angle θ and azimuth angle ϕ (both in radians), setting μ = cos(θ).

Examples

julia> direction_from_angles(0.0, 1.2)
DirectionCosine{Float64}(1.0, 1.2)
source
CanopyOptics.dot_product — Function
dot_product(μ₁, μ₂, dϕ)

Compute the Cartesian inner product $\mu_1 \mu_2 + \sqrt{1 - \mu_1^2}\sqrt{1 - \mu_2^2}\cos(\Delta\phi)$ between two unit directions parameterized by polar cosines $\mu_1, \mu_2 \in [-1, 1]$ and relative azimuth dϕ in radians.

source
CanopyOptics.CanopyQuadrature — Type
CanopyQuadrature(n_leaf, n_azimuth = 48)
CanopyQuadrature(; n_leaf = 64, n_azimuth = 48, nQuad = nothing)

Quadrature node counts used when projecting canopy scattering models onto Fourier Z matrices.

n_leaf sets Gauss–Legendre nodes over leaf inclination [0, π/2], and n_azimuth sets outgoing-azimuth quadrature nodes for specular, coupled-BSDF, and reference azimuth integrations.

Examples

julia> q = CanopyQuadrature(n_leaf = 32, n_azimuth = 24)
CanopyQuadrature(32, 24)
source
CanopyOptics.gauleg — Function
gauleg(n, xmin, xmax; norm = false)

Compute n-point Gauss–Legendre quadrature nodes and weights mapped onto [xmin, xmax]. When norm = true, weights are normalized to sum to 1.

Examples

julia> x, w = CanopyOptics.gauleg(4, 0.0, 1.0);

julia> isapprox(sum(w), 1.0; atol = 1e-15)
true
source

Leaf Angle Distributions & Projection (G) Functions

CanopyOptics.LeafDistribution — Type
LeafDistribution{FT<:Real,D<:UnivariateDistribution}(LD, scaling)
LeafDistribution(LD, scaling)

Represent a leaf inclination angle distribution $g_L(\theta_L)$ on $\theta_L \in [0, \pi/2]$ via a Distributions.UnivariateDistribution LD on $u = 2\theta_L / \pi \in [0, 1]$ and Jacobian normalization factor scaling (typically $2/\pi$).

Fields

  • LD::D: univariate probability distribution on $[0, 1]$.
  • scaling::FT: density normalization factor mapping $[0, 1]$ to $[0, \pi/2]$.
source
CanopyOptics.planophile_leaves — Function
planophile_leaves(FT = Float64)

Construct a planophile (predominantly horizontal) LeafDistribution from a Beta distribution with mean inclination 26.76° and standard deviation 18.51° (Bonan, 2019, Table 2.1).

Examples

julia> planophile_leaves(Float64) isa LeafDistribution{Float64}
true
source
CanopyOptics.spherical_leaves — Function
spherical_leaves(FT = Float64)

Construct a spherical LeafDistribution (G(μ) ≈ 0.5) from a Beta distribution with mean inclination 57.3° and standard deviation 21.55° (Bonan, 2019, Table 2.1).

Examples

julia> isapprox(only(G([0.5], spherical_leaves())), 0.5; atol = 2e-2)
true
source
CanopyOptics.beta_leaves — Function
beta_leaves(α, β)

Construct a LeafDistribution over [0, π/2] from arbitrary Beta(α, β) shape parameters (corresponding to (ν, μ) in the RAMI benchmark convention).

Examples

julia> beta_leaves(2.0, 2.0) isa LeafDistribution{Float64}
true
source
CanopyOptics.βparameters — Function
βparameters(θₗ, s)

Compute Beta(α, β) shape parameters (α, β) on [0, 1] from mean leaf inclination angle θₗ and standard deviation s (both in radians), following Bonan (2019, Table 2.1, Eqs. 2.9–2.10):

\[\alpha = \frac{1 - (s^2 + \theta_l^2)/(\theta_l \pi / 2)}{(s^2 + \theta_l^2)/\theta_l^2 - 1}, \qquad \beta = \left(\frac{\pi / 2}{\theta_l} - 1\right) \alpha .\]

Examples

julia> α, β = βparameters(deg2rad(45.0), deg2rad(16.27));

julia> round.((α, β); digits = 3)
(3.325, 3.325)
source
CanopyOptics.G — Function
G(μ, LD; quadrature = CanopyQuadrature(), nLeg = nothing)

Compute the Ross projected leaf area factor in directions μ for an azimuthally uniform leaf inclination distribution LD, preserving the container shape and axes of μ.

Uses quadrature.n_leaf (or nLeg when explicitly passed) and the normalized leaf-area measure shared with the canopy scattering kernels.

Examples

julia> isapprox(G([0.5, 1.0], spherical_leaves()), [0.5, 0.5]; atol = 1e-3)
true
source
CanopyOptics.G2 — Function
G2(μ::AbstractArray, LD::AbstractLeafDistribution; nLeg = 40)

Compute the Ross projection factor G(μ) by integrating in leaf-normal cosine μ_L instead of leaf inclination angle θ_L (retained for cross-checking G).

source
CanopyOptics.bfG — Function
bfG(μ::AbstractArray, LD::AbstractLeafDistribution; nLeg = 20)

Compute the Ross projection factor G(μ) by direct 2D quadrature of |Ω ⋅ Ω_L| over leaf inclination and azimuth (reference implementation for G).

source
CanopyOptics.H — Function
H(μ, μₗ)

Evaluate the one-sided azimuthally averaged leaf projection factor $H(\mu, \mu_L)$ for stream polar cosine $\mu = \cos\theta \in [-1, 1]$ and leaf-normal cosine $\mu_L = \cos\theta_L \in [-1, 1]$ (Shultis & Myneni, 1988, Eqs. 46–47):

\[H(\mu, \mu_L) = \frac{1}{2\pi} \int_0^{2\pi} \max\!\big(0,\; \mu\mu_L + \sqrt{1-\mu^2}\sqrt{1-\mu_L^2}\cos\phi\big)\,d\phi .\]

Evaluated algebraically without $\cot(\arccos(\cdot))$ singularities so boundary inputs ($|\mu| = 1$ or $\mu_L = 0$) remain finite and ForwardDiff-compatible. Assembles the azimuthally averaged $\Psi$ kernels in CanopyOptics.compute_Ψ.

Examples

julia> CanopyOptics.H(1.0, 0.0)
0.0
source
CanopyOptics.compute_Ψ — Function
compute_Ψ(μ::AbstractVector, μₗ::Real)
compute_Ψ(μ::AbstractVector, μꜛ::AbstractVector, μₗ::Real)

Compute the azimuthally averaged (Ψ⁺, Ψ⁻) coupling matrices at leaf-normal cosine μₗ following Shultis & Myneni (1988, Eq. 45):

\[\Psi^+(\mu, \mu') = H(\mu, \mu_L) H(\mu', \mu_L) + H(-\mu, \mu_L) H(-\mu', \mu_L),\]

\[\Psi^-(\mu, \mu') = H(\mu, \mu_L) H(-\mu', \mu_L) + H(-\mu, \mu_L) H(\mu', \mu_L).\]

Returns (Ψ⁺, Ψ⁻) of size (length(μ), length(μ')), preserving the index axes of μ and μꜛ. The two-argument method sets μꜛ = μ.

source

Clumping & Hotspot Gap Geometry

CanopyOptics.AbstractClumping — Type
AbstractClumping{FT}

Angular clumping model for canopy interception.

Clumping modifies the effective projected area used in gap probability and extinction calculations:

\[G_{eff}(μ) = Ω(μ) G(μ).\]

It does not change the leaf or wood scattering matrix Z; it changes how often canopy elements are encountered along a path.

source
CanopyOptics.ConstantClumping — Type
ConstantClumping(; Ω = 1)
ConstantClumping(; Ω₀ = 1)

Direction-independent clumping index.

Values Ω < 1 reduce effective extinction relative to a random leaf distribution. Ω = 1 preserves the unclumped Beer-Lambert limit. Values above one represent more regular spacing and are allowed for completeness.

source
CanopyOptics.EmpiricalDirectionalClumping — Type
EmpiricalDirectionalClumping(; Ω₀ = 0.7, c = 2, e = 2)

Simple empirical angular clumping model:

\[Ω(θ) = \frac{Ω_0}{Ω_0 + (1 - Ω_0)\exp(-c θ^e)}, \qquad θ = \arccos μ.\]

The default shape gives Ω(0) = Ω₀ at nadir and approaches one toward the horizon, where clumping is visually less apparent along the slant path.

This is a compact directional parameterization rather than the full Chen-Leblanc row/crown gap-size model. ChenLeblancClumping is provided as a compatibility alias.

source
CanopyOptics.effective_G — Function
effective_G(clumping, G_value, μ)

Apply clumping to a Ross projection factor: G_eff = Ω(μ) G.

This helper is intended for propagation/extinction code. Z-matrix construction should generally keep using the unclumped leaf-angle G normalization.

source
CanopyOptics.AbstractHotSpot — Type
AbstractHotSpot{FT}

Model for bidirectional hotspot corrections to canopy gap probability.

Hotspot terms are propagation corrections, not leaf scattering matrices: they modify the joint probability that the solar and viewing paths see the same canopy gaps. They should therefore be applied where direct-beam source terms are assembled, not inside compute_Z_matrices.

source
CanopyOptics.NoHotSpot — Type
NoHotSpot()
NoHotSpot{FT}()

Default model with independent sun and view gaps. The joint gap probability is $\exp[-(k_s + k_o)L]$.

source
CanopyOptics.KuuskHotSpot — Type
KuuskHotSpot(; h = 0.1)
KuuskHotSpot{FT}(; h = FT(0.1))

Kuusk-style hotspot correction with dimensionless size parameter h, roughly leaf size divided by canopy height. Larger h broadens the hotspot; $h \le 0$ disables the correction and returns the independent-gap probability.

source
CanopyOptics.canopy_extinction — Function
canopy_extinction(G_value, μ)

Convert projected area G_value ($G(\mu)$) into the directional extinction coefficient $k = G(\mu) / \mu$ used by Beer–Lambert canopy gap probabilities.

source
CanopyOptics.hotspot_separation — Function
hotspot_separation(μ_s, μ_o, dϕ, h)

Angular separation parameter used by the Kuusk hotspot correction:

\[α = \frac{1}{h}\sqrt{\tan^2 θ_s + \tan^2 θ_o - 2\tan θ_s\tan θ_o\cos Δϕ}.\]

source
CanopyOptics.hotspot_correction — Function
hotspot_correction(model, k_s, k_o, μ_s, μ_o, dϕ, L)

Return the multiplicative correction C_hs applied to the independent joint gap probability. k_s and k_o are directional extinction coefficients, μ_s and μ_o are positive cosines for sun and view paths, dϕ is relative azimuth in radians, and L is cumulative LAI or area index.

source
CanopyOptics.joint_gap_probability — Function
joint_gap_probability(model, k_s, k_o, μ_s, μ_o, dϕ, L)

Return the full correlated bidirectional gap probability

\[P_{so}(L) = \exp[-(k_s + k_o)L] C_{hs}(L).\]

Use NoHotSpot for the independent-path Beer-Lambert result.

Hotspot corrections belong in the direct-beam source assembly of the canopy RT consumer, not in compute_Z_matrices. A typical per-layer skeleton is:

G_s = G([μ_s], LAD)[1]
G_o = G([μ_o], LAD)[1]
k_s = canopy_extinction(G_s, μ_s)
k_o = canopy_extinction(G_o, μ_o)

P_so = joint_gap_probability(hotspot, k_s, k_o, μ_s, μ_o, dϕ, L_cumulative)
P_o  = exp(-k_o * L_cumulative)
direct_source_scale = P_so / P_o

The consumer then applies direct_source_scale to the direct solar source term before multiplying by the canopy scattering kernel.

source

Multi-Component Canopies & Wood Reflectance

CanopyOptics.CanopyComponent — Type
CanopyComponent(scatterer, LAD, area_index; clumping = nothing)
CanopyComponent(; scatterer, LAD, area_index, clumping = nothing)

One canopy scattering population.

scatterer is a canopy scattering model such as BiLambertianCanopyScattering or LambertianWoodCanopyScattering, LAD is that population's element angle distribution, and area_index is its one-sided area index: LAI for leaves, WAI/BAI for woody material. Optional per-component clumping is used by bulk_G, but mixed Z-matrix normalization keeps using the unclumped Ross G convention.

source
CanopyOptics.MixedCanopy — Type
MixedCanopy(components...)
MixedCanopy((components...,))

Area-weighted canopy made from multiple scattering populations.

Each component may have its own scatterer, angle distribution, area index, and clumping model. Z matrices are mixed column-by-column using the incoming-stream projected area weights

\[w_c(μ_j) = \frac{AI_c G_c(μ_j)} {\sum_d AI_d G_d(μ_j)}.\]

The optional component clumping models are intentionally not included in this Z normalization; use bulk_G with clumped = true for propagation.

source
CanopyOptics.LeafComponent — Function
LeafComponent(; LAI, scatterer = nothing, LAD = nothing,
              clumping = nothing) -> CanopyComponent

Convenience constructor for the leaf scattering population of a tree canopy. Defaults to a BiLambertianCanopyScattering (reflection

  • transmission, the canonical leaf scatterer) and spherical_leaves

(Bonan/Norman default — projection function G(μ) ≈ 0.5). Override either via kwarg: e.g. scatterer = some_prospect_driven_scatterer or LAD = planophile_leaves(FT).

When scatterer and LAD are left at their defaults, they are constructed in the float type of LAI — so LeafComponent(LAI = 3.5f0) returns a CanopyComponent{Float32, ...} end-to-end, with no silent Float64 promotion.

LAI is the one-sided leaf area index [m² leaf / m² ground]. Must be non-negative (throws DomainError otherwise).

The resulting CanopyComponent plugs directly into MixedCanopy and the existing compute_Z_matrices, bulk_G, effective_G paths — no other call sites change.

source
CanopyOptics.StemComponent — Function
StemComponent(; SAI, R = 0.25, scatterer = nothing, LAD = nothing,
              clumping = nothing) -> CanopyComponent

Convenience constructor for the stem scattering population.

Stems are modeled as opaque Lambertian (reflection only, no transmission — the "no T, just R" point) with a default erectophile (mostly vertical) angle distribution. This captures the fact that trunks intercept little overhead sun (small G at high μ) but a lot of low-angle sun (large G at small μ).

R may be a scalar (broadband bark albedo) or any AbstractWoodReflectance (e.g. LUTWoodReflectance for band-resolved bark spectra). The default R = 0.25 is a broadband typical mature-bark value (Bonan 2019, Climate Change and Terrestrial Ecosystem Modeling, Table 14.1). Pass scatterer = ... to override the entire scattering model (rarely needed).

When scatterer and LAD are left at their defaults, they are constructed in the float type of SAI — so StemComponent(SAI = 0.9f0) returns a CanopyComponent{Float32, ...} end-to-end.

SAI is the one-sided stem area index [m² stem / m² ground]. Must be non-negative (throws DomainError otherwise).

source
CanopyOptics.BranchComponent — Function
BranchComponent(; BAI, R = 0.30, scatterer = nothing, LAD = nothing,
                clumping = nothing) -> CanopyComponent

Convenience constructor for the branch scattering population.

Similar to StemComponent but with a default plagiophile (oblique, on-average ~45°-tilted) angle distribution that represents branches hanging off the main stem at intermediate inclinations. The default R = 0.30 is a broadband typical younger-bark value, slightly higher than the mature-stem default to reflect smoother branch bark; override with any AbstractWoodReflectance for band-resolved spectra.

When scatterer and LAD are left at their defaults, they are constructed in the float type of BAI — so BranchComponent(BAI = 0.1f0) returns a CanopyComponent{Float32, ...} end-to-end.

BAI is the one-sided branch area index [m² branch / m² ground]. Must be non-negative (throws DomainError otherwise).

source
CanopyOptics.TreeCanopy — Function
TreeCanopy(; LAI, SAI = 0, BAI = 0,
           leaf_kwargs = (;), stem_kwargs = (;), branch_kwargs = (;))
    -> MixedCanopy

One-line constructor for "leaves + stems + branches" tree canopies. Returns a MixedCanopy with up to three CanopyComponents.

A SAI or BAI of zero omits the corresponding component entirely — MixedCanopy doesn't carry spurious zero-area populations in its projected-area weighting. When SAI = BAI = 0 the result is a single-component MixedCanopy whose bulk_G matches the leaf-only G(μ, ::LeafDistribution) exactly.

Each population's defaults can be overridden via the *_kwargs NamedTuples, which are spliced into the corresponding LeafComponent / StemComponent / BranchComponent call. For example, to use band-resolved bark reflectance:

using CanopyOptics
canopy = TreeCanopy(;
    LAI = 4.0,
    SAI = 0.9,
    BAI = 0.1,
    stem_kwargs = (; R = LUTWoodReflectance(
        grid = [400, 800, 2500], R = [0.10, 0.20, 0.45], grid_unit = :nm)),
)

The resulting MixedCanopy plugs into all existing paths (bulk_G, compute_Z_matrices, etc.) and is the recommended way to construct tree canopies in upstream consumers (RRTMGP, ClimaLand multi-layer canopies, CanopyColumn).

source
CanopyOptics.bulk_G — Function
bulk_G(canopy, μ; clumped = true, quadrature = CanopyQuadrature())

Compute the area-index-weighted canopy projected area:

\[G_{bulk}(μ) = \sum_c AI_c G_c(μ),\]

or $\sum_c AI_c Ω_c(μ)G_c(μ)$ when clumped = true.

source
CanopyOptics.AbstractWoodReflectance — Type
AbstractWoodReflectance{FT}

Spectral reflectance model for bark or woody canopy elements.

Wood reflectance is kept separate from angular scattering. A reflectance model answers "what is the bark albedo at this wavelength or wavenumber?", while a canopy scattering model answers "how does that woody surface redirect light?".

source
CanopyOptics.LUTWoodReflectance — Type
LUTWoodReflectance(grid, R; grid_unit = :nm, extrapolation = :clamp)

Piecewise-linear bark/wood reflectance lookup table.

grid and R must have the same length, with at least two points. The constructor sorts the table by spectral coordinate. grid_unit is :nm for wavelength in nanometers or :cm_inv for wavenumber. extrapolation = :clamp uses the nearest endpoint outside the tabulated range; :error throws.

source
CanopyOptics.PolynomialWoodReflectance — Type
PolynomialWoodReflectance(coeffs; grid_unit = :nm, x_offset = 0, x_scale = 1)

Polynomial bark/wood reflectance model.

Coefficients use ascending order:

\[R(x) = c_0 + c_1 \hat{x} + c_2 \hat{x}^2 + \cdots, \qquad \hat{x} = (x - x_{offset}) / x_{scale}.\]

Use x_offset and x_scale to fit on a normalized wavelength or wavenumber coordinate instead of raw nanometers.

source
CanopyOptics.wood_reflectance — Function
wood_reflectance(model, x; grid_unit = :nm)
wood_reflectance(model, grid; grid_unit = :nm)

Evaluate a wood reflectance model at one spectral coordinate or a vector of coordinates. grid_unit describes the input coordinate unit.

source

Canopy Scattering Models & Fourier Z-Matrices

CanopyOptics.AbstractCanopyScatteringType — Type
AbstractCanopyScatteringType{FT<:Real}

Supertype for leaf, wood, composite, and multi-component canopy angular scattering models projected onto discrete-ordinate Fourier Z matrices.

source
CanopyOptics.BiLambertianCanopyScattering — Type
BiLambertianCanopyScattering{FT<:Real}(R, T)
BiLambertianCanopyScattering(; R = 0.3, T = 0.1)

Face-symmetric diffuse bi-Lambertian canopy leaf scattering model parameterized by hemispherical reflectance R and transmittance T.

Fields

  • R::FT: leaf hemispherical reflectance.
  • T::FT: leaf hemispherical transmittance.

Examples

julia> BiLambertianCanopyScattering(0.42, 0.38)
BiLambertianCanopyScattering{Float64}(0.42, 0.38)
source
CanopyOptics.DorsiventralBiLambertianCanopyScattering — Type
DorsiventralBiLambertianCanopyScattering{FT<:Real} <: AbstractCanopyScatteringType{FT}

Dorsiventral bi-Lambertian canopy leaf scattering model with distinct adaxial (upper, sky-facing: R_ad, T_ad) and abaxial (lower, soil-facing: R_ab, T_ab) hemispherical reflectance and transmittance.

For true elastic leaf radiative transfer (such as dorsiventral_budget with hemispherical = true), bi-hemispherical Helmholtz reciprocity guarantees $T_{\mathrm{ad}} = T_{\mathrm{ab}}$ even when $R_{\mathrm{ad}} \neq R_{\mathrm{ab}}$; unequal $T_{\mathrm{ad}} \neq T_{\mathrm{ab}}$ is permitted here only for effective/upscaled asymmetric canopy elements (such as clumped shoots).

In CanopyOptics's canopy coordinate convention ($+\mu$ downward into the canopy, $-\mu$ upward toward the sky), a leaf with inclination $\theta_L \in [0, \pi/2]$ ($\mu_L = \cos\theta_L \ge 0$) has downward abaxial normal Ω_L = DirectionCosine(+μ_L, ϕ_L) and upward adaxial normal $-\Omega_L$. Because downward and upward streams illuminate opposite faces on average ($Z^{++} \neq Z^{--}$ and $Z^{-+} \neq Z^{+-}$ whenever $R_{\mathrm{ad}} \neq R_{\mathrm{ab}}$ or $T_{\mathrm{ad}} \neq T_{\mathrm{ab}}$), use compute_Z_matrices_directional to assemble all four scattering blocks (; Zpp, Zmp, Zpm, Zmm, ω_down, ω_up).

source
CanopyOptics.SpecularCanopyScattering — Type
SpecularCanopyScattering{FT<:Real}(nᵣ, κ)
SpecularCanopyScattering(; nᵣ = 1.5, κ = 0.5)

Specular leaf-surface canopy scattering model parameterized by cuticular refractive index nᵣ and Nilson–Kuusk roughness attenuation κ.

Fields

  • nᵣ::FT: leaf surface refractive index.
  • κ::FT: surface roughness attenuation parameter (κ >= 0).

Examples

julia> SpecularCanopyScattering(nᵣ = 1.45, κ = 0.2)
SpecularCanopyScattering{Float64}(1.45, 0.2)
source
CanopyOptics.LambertianWoodCanopyScattering — Type
LambertianWoodCanopyScattering(reflectance)
LambertianWoodCanopyScattering(R)
LambertianWoodCanopyScattering(; R = 0.25, reflectance = nothing)

Opaque Lambertian woody element: reflection only, no transmission.

This is the angular-scattering counterpart to AbstractWoodReflectance. For scalar Z-matrix assembly it delegates to BiLambertianCanopyScattering(R, 0), preserving the existing canopy normalization convention.

source
CanopyOptics.compute_Z_matrices — Function
compute_Z_matrices(mod::SpecularCanopyScattering, μ::AbstractVector,
                   LD::AbstractLeafDistribution, m::Integer;
                   quadrature = CanopyQuadrature(), npol = 1) -> (Z⁺⁺, Z⁻⁺)

Compute the Fourier-m component of the single-scattering phase matrices (Z⁺⁺, Z⁻⁺) for a specular leaf surface by integrating compute_reflection (or compute_reflection_mueller when npol > 1) over the azimuthal quadrature grid:

  • Z⁺⁺[i, j]: same-hemisphere scattering ($\mu > 0 \to \mu > 0$, forward scatter).
  • Z⁻⁺[i, j]: opposite-hemisphere scattering ($\mu > 0 \to \mu < 0$, backscatter).

Azimuth integration uses quadrature.n_azimuth Gauss–Legendre points over $[0, 2\pi]$ with $\cos(m\phi)$ weights for scalar $I$ (npol = 1) and the vSmartMOM Stokes cos/sin parity kernel for npol = 3 or 4. Columns are normalized by $G(\mu_{\mathrm{in}})$ while retaining the Fresnel/roughness strength in the returned kernel.

source
compute_Z_matrices(mod::BiLambertianCanopyScattering,
                   μ::AbstractVector, LD::AbstractLeafDistribution,
                   m::Integer; quadrature = CanopyQuadrature(), npol = 1) -> (Z⁺⁺, Z⁻⁺)

Compute one cosine Fourier moment of the bi-Lambertian canopy scattering matrices. Rows are outgoing streams and columns are incoming streams: Z[i_out, j_in].

npol = 1 returns scalar Stokes-I matrices. npol = 3 and npol = 4 expand the scalar diffuse result into vSmartMOM-style Stokes blocks with only I→I populated.

This method uses the closed-form Fourier moments from compute_Z_matrices_aniso_analytic. For all moments in one call, pass a range such as 0:m_max.

The optional angular_normalization keyword selects a ContinuousAngularNormalization (default) or DiscreteAngularNormalization. The latter is supported for the bi-Lambertian single-moment and range APIs; pass the scalar positive-hemisphere cosine weights, including zeros for viewing nodes.

source
compute_Z_matrices(mod::LambertianWoodCanopyScattering,
                   μ, LD, m; spectral_coordinate = nothing, grid_unit = :nm,
                   npol = 1)

Compute one Fourier moment for opaque Lambertian wood.

The wood reflectance is evaluated, then the angular Z construction delegates to BiLambertianCanopyScattering(R, 0). For non-constant wood reflectance models, pass spectral_coordinate in the unit specified by grid_unit.

source
compute_Z_matrices(mod::AbstractCanopyScatteringType,
                   μ, LD, m_range::AbstractUnitRange; quadrature, npol = 1)

Compute a stack of canopy Z matrices for Fourier moments in m_range.

The scalar default returns arrays with shape (length(μ), length(μ), length(m_range)). Passing npol = 3 or 4 returns Stokes-expanded arrays with the first two dimensions multiplied by npol. In both cases the package convention is Z[i_out, j_in, k], where k = m - first(m_range) + 1.

source
compute_Z_matrices(mod::CompositeCanopyScattering, μ, LD, m; quadrature, npol = 1)

Compute one Fourier moment for an additive canopy-scattering model.

Each component is evaluated independently and the resulting (Z⁺⁺, Z⁻⁺) matrices are summed. Diffuse components use the vSmartMOM convention where scalar single-scattering albedo is divided out of Z; specular components carry their Fresnel/roughness strength in their kernel. Consumers that multiply by a separate canopy single-scattering albedo must account for that when using specular components in a full RT layer.

source
compute_Z_matrices(canopy::MixedCanopy, μ, m; quadrature, npol = 1)
compute_Z_matrices(canopy::MixedCanopy, μ, ignored_LD, m; quadrature, npol = 1)

Compute canopy Z matrices for a mixture of components with their own angle distributions and area indices. The ignored_LD compatibility form exists so callers that already carry (scatterer, μ, LAD, m) can pass a MixedCanopy as the scatterer without changing their call shape.

source
CanopyOptics.compute_Z_matrices_aniso_analytic — Function
compute_Z_matrices_aniso_analytic(mod::BiLambertianCanopyScattering,
                                  μ::AbstractVector{FT},
                                  LD::AbstractLeafDistribution,
                                  m_max::Int;
                                  quadrature = CanopyQuadrature(),
                                  npol = 1) -> (Z⁺⁺, Z⁻⁺)

Compute all scalar Fourier moments m = 0:m_max of the bi-Lambertian canopy phase matrices without azimuthal quadrature.

The scalar default returns arrays of shape (length(μ), length(μ), m_max + 1). Passing npol = 3 or npol = 4 expands those scalar moments into Stokes-block matrices of shape (npol * length(μ), npol * length(μ), m_max + 1). Because bi-Lambertian scattering is unpolarized here, only the $I \to I$ entry of each stream block is populated.

All cases use the vSmartMOM convention

\[Z[i_{\mathrm{out}}, j_{\mathrm{in}}, m+1],\]

where $Z^{++}$ is same-sign transmission and $Z^{-+}$ is sign-change reflection. The single-scattering albedo $\varpi = R + T$ is divided out, so for conservative leaves the $m = 0$ column integral of $Z^{++} + Z^{-+}$ equals $\approx 2$ under the same quadrature and $G(\mu)$ convention used by vSmartMOM.

Origin trace

Shultis & Myneni (1988), Eq. 45 writes the azimuthally averaged Lambertian canopy kernels as products of one-direction projected-area functions. For each leaf inclination this implementation generalizes that factorization from $m = 0$ to arbitrary cosine Fourier order using the closed-form moments returned by _one_sided_projection_moments.

For signed incoming/outgoing directions, let $(P_i, N_i)$ and $(P_o, N_o)$ be the positive-face and negative-face projection moments. The circular-convolution theorem gives the per-leaf Fourier coefficients

\[\Psi^+_m = P_{i,m}P_{o,m} + N_{i,m}N_{o,m}, \qquad \Psi^-_m = P_{i,m}N_{o,m} + N_{i,m}P_{o,m}.\]

Multiplying these products by $2$ before applying $f_0 = 2$ and $f_{m>0} = 4$ converts the $1/(2\pi)$ Fourier coefficients above to the half-range cosine moment used by compute_Z_matrices_aniso:

\[\frac{2}{\pi}\int_0^{\pi} \Gamma(\Delta\phi)\cos(m\Delta\phi)\,d\Delta\phi ,\]

matching vSmartMOM's elemental kernels where $\varpi$ is applied outside Z.

angular_normalization = ContinuousAngularNormalization() retains the default continuous angular law. Pass DiscreteAngularNormalization(μ, weights; atol) to normalize each leaf's angular redistribution on that outgoing quadrature before integrating over leaf inclination. This preserves the area kernel's reciprocity and its discrete zeroth-mode column integral without modifying $G$ or leaf albedo. Use the same normalization for emitted leaf-source moments.

source
compute_Z_matrices_aniso_analytic(mod::CompositeCanopyScattering,
                                  μ, LD, m_max; quadrature)

Compute all moments 0:m_max for a composite canopy-scattering model by delegating to the stacked compute_Z_matrices API.

source
CanopyOptics.compute_Z_matrices_directional — Function
compute_Z_matrices_directional(mod::DorsiventralBiLambertianCanopyScattering,
                               μ::AbstractVector, LD::AbstractLeafDistribution,
                               m_max::Int; quadrature = CanopyQuadrature(),
                               npol = 1, normalize_by_ω = false)

Compute analytic closed-form cosine Fourier moments m = 0:m_max for all four directional canopy scattering blocks (; Zpp, Zmp, Zpm, Zmm, ω_down, ω_up) with zero azimuthal quadrature:

  • Zpp: downward to downward ($+\mu_j \to +\mu_i$)
  • Zmp: downward to upward ($+\mu_j \to -\mu_i$, canopy top reflection)
  • Zpm: upward to downward ($-\mu_j \to +\mu_i$, canopy bottom reflection)
  • Zmm: upward to upward ($-\mu_j \to -\mu_i$)
  • ω_down, ω_up: exact stream-dependent single-scattering albedos for $+\mu$ and $-\mu$.

By default (normalize_by_ω = false), columns are normalized by $G(\mu_{\mathrm{in}})$ only so at $m = 0$,

\[\frac{1}{2} \sum_i w_i \bigl(Z^{++}_{ij,0} + Z^{-+}_{ij,0}\bigr) \approx \omega_{\mathrm{down},j},\]

preventing $\varpi$-mixing ambiguities when combined with specular or coupled BSDF kernels. Setting normalize_by_ω = true divides out ω_down[j] and ω_up[j], matching BiLambertianCanopyScattering identically when $R_{\mathrm{ad}} = R_{\mathrm{ab}}$ and $T_{\mathrm{ad}} = T_{\mathrm{ab}}$.

source
CanopyOptics.compute_Z_matrices_coupled_bsdf — Function
compute_Z_matrices_coupled_bsdf(prep::PreparedLeafBSDFSpectrum, idx_λ::Integer,
                                μ::AbstractVector, LD::AbstractLeafDistribution,
                                m_max::Int; quadrature = CanopyQuadrature(n_leaf=16, n_azimuth=24))

Project a coupled directional leaf BSDF (CoupledLeafBSDF, prepared via prepare_leaf_bsdf at wavelength index idx_λ) onto the 4-block canopy Fourier phase matrices (; Zpp, Zmp, Zpm, Zmm, ω_down, ω_up) ($G(\mu_{\mathrm{in}})$-normalized, normalize_by_ω = false).

Uses rotationally invariant 3D inner products for both surface microfacet reflection ($\mathbf{H} = \mathbf{k}_{\mathrm{out}} - \mathbf{k}_{\mathrm{in}}$) and internal volume/forward-lobe scattering, preserving exact leaf-level energy conservation $R(\mu_i) + T(\mu_i) + A(\mu_i) = 1$ inside canopy radiative transfer. For very glossy leaves ($\sigma \lesssim 0.05$, specular lobe width $\sim \sigma$ rad), increase quadrature (e.g. CanopyQuadrature(n_leaf = 32, n_azimuth = 48)) to resolve the narrow specular peak without angular aliasing.

source
CanopyOptics.compute_Γ — Function
compute_Γ(mod::BiLambertianCanopyScattering, Ωⁱⁿ::DirectionCosine, Ωᵒᵘᵗ::DirectionCosine,
          LD::AbstractLeafDistribution; quadrature = CanopyQuadrature())

Compute the azimuthally resolved area scattering transfer function $\Gamma(\Omega^{\mathrm{in}} \to \Omega^{\mathrm{out}})$ for a direction pair by direct double integration over leaf polar and azimuthal angles, following Shultis & Myneni (1988), Eqs. (38)–(39):

\[\Gamma = R\,\Gamma^- + T\,\Gamma^+ ,\]

where $\Gamma^-$ integrates the negative (reflection) part and $\Gamma^+$ the positive (transmission) part of $(\Omega^{\mathrm{in}} \cdot \Omega_L)(\Omega^{\mathrm{out}} \cdot \Omega_L)$ over all leaf orientations.

Retained as a direct-quadrature reference path for validating the analytic Fourier closure; production Z-matrix assembly uses compute_Z_matrices_aniso_analytic. See CanopyOptics.compute_lambertian_Γ for the azimuthally averaged ($m = 0$) equivalent.

source
CanopyOptics.compute_Γ_isotropic — Function
compute_Γ_isotropic(mod::BiLambertianCanopyScattering, Ωⁱⁿ, Ωᵒᵘᵗ)

Compute the analytic area scattering transfer function for a spherical leaf-angle distribution following Shultis & Myneni (1988), Eq. (40):

\[\Gamma_{\mathrm{iso}}(\beta) = \frac{\omega}{3\pi}(\sin\beta - \beta\cos\beta) + \frac{T}{3}\cos\beta ,\]

where $\beta = \arccos(\Omega^{\mathrm{in}} \cdot \Omega^{\mathrm{out}})$ and $\omega = R + T$.

source
CanopyOptics.compute_Γ_directional — Function
compute_Γ_directional(mod::DorsiventralBiLambertianCanopyScattering,
                      Ωⁱⁿ::DirectionCosine, Ωᵒᵘᵗ::DirectionCosine, LD; quadrature)

Evaluate the direct 2D $(\theta_L, \phi_L)$ quadrature reference for the dorsiventral area scattering transfer function $\Gamma(\Omega^{\mathrm{in}} \to \Omega^{\mathrm{out}})$. Reduces identically to CanopyOptics.compute_Γ when $R_{\mathrm{ad}} = R_{\mathrm{ab}}$ and $T_{\mathrm{ad}} = T_{\mathrm{ab}}$.

source
CanopyOptics.compute_lambertian_Γ — Function
compute_lambertian_Γ(μ, μꜛ, r, t, LD::AbstractLeafDistribution; nLeg = 20)

Compute the azimuthally averaged area scattering transfer matrix Γ of size (length(μ), length(μꜛ)) following Shultis & Myneni (1988), Eq. 43:

$Γ(μ_i, μ'_j) = \int_0^{π/2} g_L(θ_L)\,[t\,Ψ^+(μ_i, μ'_j, \cos θ_L) + r\,Ψ^-(μ_i, μ'_j, \cos θ_L)]\,dθ_L$

for leaf reflectance r, leaf transmittance t, and azimuthally uniform leaf angle distribution LD.

Examples

julia> Γ = CanopyOptics.compute_lambertian_Γ([0.4, 0.8], [-0.5], 0.4, 0.1, spherical_leaves());

julia> size(Γ)
(2, 1)
source
CanopyOptics.compute_reflection — Function
compute_reflection(mod::SpecularCanopyScattering, Ωⁱⁿ, Ωᵒᵘᵗ, LD)

Compute the specular bidirectional scattering coefficient for direction pair (Ωⁱⁿ, Ωᵒᵘᵗ), following Knyazikhin & Marshak, Discrete Ordinates Method for Photon Transport in Leaf Canopies, Eq. 2.39:

\[f_s(\Omega' \to \Omega) = \frac{1}{8}\,g_L(\theta^*)\,K(\kappa, \alpha^*)\,F_r(n_r, \alpha^*) ,\]

where $\theta^*$ is the polar angle of the specular leaf normal (from CanopyOptics.getSpecularΩ), $\alpha^* = \arccos(\Omega^{\mathrm{in}} \cdot \Omega^{\mathrm{out}}) / 2$ is the incidence half-angle, $K(\kappa, \alpha^*)$ is the Nilson–Kuusk roughness factor, and $F_r(n_r, \alpha^*)$ is unpolarized Fresnel reflectance. Accepts DirectionCosine directions (construct from (θ, ϕ) via direction_from_angles).

For Stokes-vector propagation, use compute_reflection_mueller. Note that Ωⁱⁿ points toward the illumination source ($-\mathbf{k}_{\mathrm{in}}$) and Ωᵒᵘᵗ points along the reflected ray ($+\mathbf{k}_{\mathrm{out}}$); only reflection is modelled here (for coupled surface, volume, and directional transmission, see CoupledLeafBSDF).

source
CanopyOptics.compute_reflection_mueller — Function
compute_reflection_mueller(mod, Ωin, Ωout, LD, npol=1)

Compute the specular leaf bidirectional scattering Mueller matrix for (Ωin, Ωout), where Ωin points toward the illumination source ($\mathbf{k}_{\mathrm{in}} = -\hat{\boldsymbol{\Omega}}_{\mathrm{in}}$) and Ωout points along the reflected ray ($\mathbf{k}_{\mathrm{out}} = +\hat{\boldsymbol{\Omega}}_{\mathrm{out}}$).

The scalar $I \to I$ element reduces identically to compute_reflection. For npol = 3 or 4, the local Fresnel Mueller matrix ($+Q$ perpendicular to the local reflection plane, $-Q$ parallel) is rotated algebraically from the incoming canopy meridian-plane triad $(\mathbf{e}_{s,\mathrm{in}}, \mathbf{e}_{p,\mathrm{in}}, \mathbf{k}_{\mathrm{in}})$ into the local reflection plane and out to the outgoing canopy meridian-plane triad $(\mathbf{e}_{s,\mathrm{out}}, \mathbf{e}_{p,\mathrm{out}}, \mathbf{k}_{\mathrm{out}})$, matching the vSmartMOM Fourier $\cos(m\Delta\phi)$ / $\sin(m\Delta\phi)$ parity convention and satisfying exact $4\times 4$ Hovenier reciprocity

\[\mathbf{M}(\Omega_2, \Omega_1) = \mathbf{P}\,\mathbf{M}(\Omega_1, \Omega_2)^{\mathsf{T}}\,\mathbf{P}, \qquad \mathbf{P} = \operatorname{diag}(1, 1, -1, 1) .\]

source
CanopyOptics.getSpecularΩ — Function
getSpecularΩ(Ωⁱⁿ::DirectionCosine, Ωᵒᵘᵗ::DirectionCosine) -> (Ωᴸ, α)

Compute the unit specular leaf normal Ωᴸ bisecting incoming source direction Ωⁱⁿ ($-\mathbf{k}_{\mathrm{in}}$) and outgoing ray direction Ωᵒᵘᵗ ($+\mathbf{k}_{\mathrm{out}}$), together with the local incidence half-angle $\alpha = \arccos(\Omega^{\mathrm{in}} \cdot \Omega^{\mathrm{out}}) / 2$ (Knyazikhin & Marshak, 1991, Eq. 18).

At the antipodal forward-grazing limit ($\Omega^{\mathrm{out}} \approx -\Omega^{\mathrm{in}}$, $\alpha = \pi/2$), returns a deterministic unit normal orthogonal to Ωⁱⁿ without coordinate singularity or ForwardDiff.Dual NaN tangents.

source
CanopyOptics.A — Function
A(θ::FT, θₗ::FT) where FT<:Real

Returns the azimuthally-integrated projected leaf area function for beam direction θ and leaf inclination θₗ (both in radians), assuming azimuthal uniformity. Follows Bonan, Modeling Earth's Climate, Eq. 14.24:

``A(θ, θₗ) = \begin{cases} \cos θ\,\cos θₗ & θₗ \le π/2 - θ \ \frac{2}{π}!\left[\sqrt{\sin^2 θₗ - \cos^2 θ} + \cos θ\,\cos θₗ\, \arcsin!\left(\frac{\cos θ\,\cos θₗ}{\sin θ\,\sin θₗ}\right)\right] & \text{otherwise} \end{cases}``

Used by G to compute the Ross G-function. See also Asm for the algebraically equivalent Shultis & Myneni form.

source
CanopyOptics.Asm — Function
Asm(θ::FT, θₗ::FT) where FT<:Real

Algebraically equivalent form of A following Shultis & Myneni (1987) Eqs. 35–36. Used for cross-validation; production code uses A.

source

Discrete Angular Normalization & Leaf Source Moments

CanopyOptics.DiscreteAngularNormalization — Type
DiscreteAngularNormalization(μ, weights; atol)

Normalize each leaf face's angular redistribution against the supplied positive- hemisphere cosine quadrature. Both arrays must share a floating-point type; $0 < \mu \le 1$, nonnegative weights, and $\lvert\sum_i w_i - 1\rvert \le \mathrm{atol}$ are required. Zero-weight viewing/solar nodes are allowed. No weights are rescaled.

The constructor copies the host arrays. Treat the owned arrays as read-only and reconstruct the object when angles or weights change. Scattering calls require the exact same angle values, order and precision. Include the normalization and both angular arrays in any downstream optical-cache identity.

This is an opt-in discretization of a bi-Lambertian angular PDF, not a change to leaf albedo, projected area $G$, absorbed PAR or photon yield. It preserves the scalar area kernel's reciprocity while making its zeroth-mode column integral conservative to rounding accuracy. Finite angular errors and solver depth errors remain. Specular/composite normalization is not provided by this policy.

source
CanopyOptics.leaf_angular_scale — Function
leaf_angular_scale(normalization, μ_leaf)

Compute the host geometry factor for one leaf inclination μ_leaf in $[0, 1]$. The continuous convention returns 1. The discrete convention returns $1 / H$, where

\[H = 2 \sum_i w_i \bigl(P_0(\mu_i, \mu_{\mathrm{leaf}}) + N_0(\mu_i, \mu_{\mathrm{leaf}})\bigr)\]

is the quadrature integral of a single Lambertian leaf face. Multiply each leaf's scattering contribution or source projection by this factor once without altering $G$, leaf area, or physiological yield.

Precompute this host geometry before copying optical/source arrays to a GPU.

source
CanopyOptics.leaf_projection_moments — Function
leaf_projection_moments(μ, μ_leaf, m_max;
                        normalization=ContinuousAngularNormalization())

Return (P, N), the cosine Fourier moments of the positive and negative leaf-face projections for orders 0:m_max. Ray cosine μ is signed; the leaf normal points upward with inclination cosine $\mu_{\mathrm{leaf}} \in [0, 1]$ using the same floating-point precision. The continuous moments evaluate

\[\frac{1}{2\pi} \int_0^{2\pi} \text{projection}(\phi)\cos(m\phi)\,d\phi .\]

For a two-face Lambertian source (front, back), $2 P_m f_{\mathrm{front}} + 2 N_m f_{\mathrm{back}}$ gives the azimuth-integrated source coefficients before leaf-normal azimuth factors. The optional discrete normalization applies leaf_angular_scale once to both arrays, consistently with bi-Lambertian scattering on that measure. The azimuth convention and $\mu$ path factor of a particular radiative-transfer solver belong in its adapter rather than in these moments.

source