Leaf Optics, Surfaces & Coupled BSDF

Leaf-level elastic radiative transfer in CanopyOptics separates tabulated spectral optical constants from leaf structural/biochemical traits, dielectric surface boundaries, and directional BSDF assembly:

  1. Optical tables (LeafOpticalProperties, MultiPigmentOpticalProperties, load_wax_refractive_index) resample refractive indices and specific absorption spectra onto a caller-chosen wavelength grid.
  2. Hemispherical mesophyll & dorsiventral budgets (prospect_budget, leaf_sip_budget, dorsiventral_budget, single_slab_dorsiventral_budget) compute directional-hemispherical or bi-hemispherical reflectance $R$, transmittance $T$, and directly integrated nonnegative material absorptance $A$ ($R + T + A = 1$).
  3. Dielectric boundary models (ConeSurface, RoughDielectricSurface) evaluate smooth Stern–Allen cone transmittance or Beckmann microfacet reflection/transmission with energy-conserving multiple-scattering compensation.
  4. Coupled $4\times 4$ polarized leaf BSDF (CoupledLeafBSDF, prepare_leaf_bsdf, leaf_bsdf_spectrum) couples specular surface reflection ($4\times 4$ Fresnel Mueller matrix) with interface-transmitted diffuse interior transport while preserving Helmholtz reciprocity and directional energy conservation $R_{\mathrm{dir}}(\mu_{\mathrm{in}}) + T_{\mathrm{dir}}(\mu_{\mathrm{in}}) + A_{\mathrm{dir}}(\mu_{\mathrm{in}}) = 1$.

Spectral Optical Tables & Wax Dispersion

CanopyOptics.LeafOpticalProperties — Type
LeafOpticalProperties(λ_bnds = (399.5:2500.5)u"nm"; FT = ...)
LeafOpticalProperties{FT}(λ_bnds = (399.5:2500.5)u"nm")
LeafOpticalProperties{FT,FT2}(λ, nᵣ, Kcab, Kcar, Kant, Kb, Kw, Km, Kp, Kcbc)

Store spectral grid λ, aqueous mesophyll refractive index nᵣ, and PROSPECT-PRO specific absorption coefficient vectors (Féret et al., 2021).

Calling LeafOpticalProperties(λ_bnds) (or LeafOpticalProperties() for the native 1 nm grid on 400–2500 nm) bin-averages the bundled PROSPECT-PRO optical database over bin edges λ_bnds, accepting any Unitful spectral unit (u"nm", u"μm", u"cm^-1") or unitless values in nm.

Fields

  • λ::FT2: spectral bin centers (with or without Unitful units).
  • nᵣ::Vector{FT}: refractive index of aqueous leaf mesophyll.
  • Kcab::Vector{FT}: pooled chlorophyll a+b specific absorption (cm² µg⁻¹).
  • Kcar::Vector{FT}: carotenoid specific absorption (cm² µg⁻¹).
  • Kant::Vector{FT}: anthocyanin specific absorption (cm² µg⁻¹).
  • Kb::Vector{FT}: senescent brown pigment specific absorption (arbitrary units).
  • Kw::Vector{FT}: liquid water specific absorption (cm⁻¹).
  • Km::Vector{FT}: bulk dry matter specific absorption (cm² g⁻¹).
  • Kp::Vector{FT}: protein specific absorption (cm² g⁻¹).
  • Kcbc::Vector{FT}: carbon-based constituent specific absorption (cm² g⁻¹).

Examples

julia> using Unitful

julia> opti = LeafOpticalProperties((400.0:100.0:2400.0)u"nm");

julia> length(opti.nᵣ)
20
source
CanopyOptics.MultiPigmentOpticalProperties — Type
MultiPigmentOpticalProperties(λ_bnds = (399.5:2500.5)u"nm"; basis = :calibrated_in_vivo, FT = ...)
MultiPigmentOpticalProperties{FT}(λ_bnds = (399.5:2500.5)u"nm"; basis = :calibrated_in_vivo)
MultiPigmentOpticalProperties(base::LeafOpticalProperties; Kchla = ..., Kchlb = ..., ...)
MultiPigmentOpticalProperties{FT<:Real, FT2} <: AbstractProspectProperties

Specific absorption cross-section spectra and refractive index nᵣ for leaf models that resolve chlorophyll a (Kchla) and chlorophyll b (Kchlb) separately ([cm² µg⁻¹]) across spectral bin edges λ_bnds or a custom grid λ.

Supported basis options when loading from bundled data:

  • :calibrated_in_vivo (default): empirical in-vivo Kchla, Kchlb calibrated on ANGERS (400–800 nm, data/multi_pigment_chlab_in_vivo.csv), spliced to OPTI_2021 for λ > 800 nm.
  • :prospect_mp_2017: Zhang et al. (2017, Sci. Rep. 7:6429) pseudo-Voigt Kchla, Kchlb, Kcar on 400–800 nm, spliced to OPTI_2021 for λ > 800 nm.
  • :prospect_mp_plus_2022: Zhang et al. (2022, Sensors 22:3025) pseudo-Voigt Kchla, Kchlb, Kcar, Kant on 400–800 nm, spliced to OPTI_2021 for λ > 800 nm.
  • :prospect_pro_pooled: baseline control with Kchla == Kchlb == Kcab from OPTI_2021.
source
CanopyOptics.load_wax_refractive_index — Function
load_wax_refractive_index(λ_bnds = (399.5:2500.5)u"nm"; FT = ...)

Load the Stuckens et al. (2009, Remote Sens. Environ. 113(12), 2560–2573; DOI 10.1016/j.rse.2009.07.014) epicuticular leaf wax refractive-index dispersion spectrum $n_{\mathrm{wax}}(\lambda)$ (data/epicuticular_wax_stuckens2009.csv) averaged onto λ_bnds.

Unlike aqueous internal leaf refractive index $n_r(\lambda)$ (which drops from $\sim 1.42$ in the VNIR to $\sim 1.27$ near $2450\;\mathrm{nm}$ due to liquid-water dispersion), epicuticular wax exhibits weak hydrocarbon dispersion ($n_{\mathrm{wax}} \approx 1.48$ at $400\;\mathrm{nm}$ to $1.40$ at $2500\;\mathrm{nm}$), sustaining cuticular surface specular reflectance in the SWIR when passed via n_surface to prospect_budget, dorsiventral_budget, or prepare_leaf_bsdf.

source

Mesophyll Plate & Leaf-SIP Budgets

CanopyOptics.LeafProspectProProperties — Type
LeafProspectProProperties{FT}(; N=1.4, Ccab=40.0, Ccar=10.0, Canth=0.5,
                              Cbrown=0.0, Cw=0.012, Cm=..., Cprot=..., Ccbc=...)

Store leaf biochemical and structural state for PROSPECT-D (bulk dry matter Cm mode) and PROSPECT-PRO (Cprot + Ccbc dry-matter partition mode).

When constructed with keywords:

  • Omitting Cm selects PROSPECT-PRO mode (Cm = 0, defaulting Cprot = 0.001 and Ccbc = 0.009).
  • Supplying Cm explicitly (including Cm = 0 or a ForwardDiff.Dual) selects PROSPECT-D mode (Cprot = 0, Ccbc = 0) so dry matter is not double-counted.
  • Setting both Cm > 0 and Cprot > 0 (or Ccbc > 0) throws an ArgumentError.

Fields

  • N::FT: leaf mesophyll structure parameter (N >= 1).
  • Ccab::FT: chlorophyll a+b content in µg cm⁻².
  • Ccar::FT: carotenoid content in µg cm⁻².
  • Canth::FT: anthocyanin content in µg cm⁻² (Féret et al., 2017/2021).
  • Cbrown::FT: senescent brown pigment content (arbitrary units).
  • Cw::FT: equivalent water thickness in cm.
  • Cm::FT: bulk dry matter content (LMA) in g cm⁻² (0 in Cprot + Ccbc mode).
  • Cprot::FT: protein content in g cm⁻².
  • Ccbc::FT: carbon-based constituents content in g cm⁻².

Examples

julia> leaf = LeafProspectProProperties(N = 1.6, Ccab = 45.0, Cm = 0.008);

julia> (leaf.Cm, leaf.Cprot, leaf.Ccbc)
(0.008, 0.0, 0.0)
source
CanopyOptics.prospect — Function
prospect(leaf, optics[, surface]; n_surface = nothing, μ_in = 1) -> (T, R)

Compute leaf spectral transmittance T and reflectance R from a LeafProspectProProperties or LeafMultiPigmentProperties state and an AbstractProspectProperties optical database.

Optionally supply an AbstractLeafSurface (ConeSurface or RoughDielectricSurface) and cuticular refractive-index vector n_surface. See prospect_budget for the full conserved (; transmission, reflectance, absorptance) budget.

Examples

julia> using Unitful

julia> opti = LeafOpticalProperties((400.0:500.0:2400.0)u"nm");

julia> leaf = LeafProspectProProperties(Ccab = 30.0);

julia> T, R = prospect(leaf, opti);

julia> length(T) == length(R) == 4 && all(0 .< T .+ R .<= 1)
true
source
CanopyOptics.prospect_budget — Function
prospect_budget(leaf, optis)

Compute PROSPECT-PRO transmission, reflection, and directly integrated material absorption, returning (; transmission, reflectance, absorptance). Unlike $1 - R - T$, the local absorptance remains accurate in the nonabsorbing and weak-absorption limits without clipping or rescaling. prospect retains its (T, R) return interface. Absorptance is the monochromatic fraction of incident energy (equivalently photon count) absorbed by all material, not chlorophyll-only absorption or energy retained after fluorescence emission.

Requires finite $N \ge 1$, finite nonnegative constituent contents and absorption coefficients, and refractive indices $n_r > 1$. Uses the PROSPECT first-surface $40^\circ$ and internal diffuse $90^\circ$ Stern–Allen Fresnel conventions; the nearly index-matched limit ($n_r \to 1^+$) is rejected if computed surface transmissions leave $(0, 1]$. Supports CPU scalars/arrays and first-order ForwardDiff.Dual inputs (the absorption Hessian is singular at zero optical depth).

source
prospect_budget(leaf, optics, surface::AbstractLeafSurface;
                μ_in = one(FT), n_surface = nothing)

Compute a generalized PROSPECT plate budget accepting any AbstractLeafSurface (ConeSurface or RoughDielectricSurface), optional directional incidence cosine $\mu_{\mathrm{in}} \in (0, 1]$, and optional outer cuticular refractive-index spectrum n_surface (e.g., load_wax_refractive_index), for either LeafProspectProProperties or LeafMultiPigmentProperties.

First-surface entry uses surface_interface_optics(surface, μ_in, nr; n_surface) and symmetric diffuse plate interfaces use $t_{\mathrm{int,diffuse}} = t_{\mathrm{hem,ext}} / n_r^2$ across all $N \ge 1$ plates (smoothly supporting $1 \le N < 2$), reducing identically to prospect_budget(leaf, optics) when surface == ConeSurface(40, 1) and n_surface === nothing. For distinct outer-epidermis vs internal aqueous cell-wall interfaces, see DorsiventralLeafProperties. Returns (; transmission, reflectance, absorptance, reflectance_volume).

source
CanopyOptics.prospect_constituent_coefficients — Function
prospect_constituent_coefficients(leaf, optics)

Host-side PROSPECT-PRO composition products for each spectral bin, named by physical constituent. These are the exact concentration × specific-absorption products used by prospect_budget, before dividing their sum by the common plate count N. That common scale cancels in homogeneous constituent attribution.

No spectrum, plant profile or units are selected here. Contents and coefficients must use the matching units documented by LeafProspectProProperties and LeafOpticalProperties. Bulk dry matter overlaps protein/carbon constituents; set Cm=0 when those PRO constituents already describe the same mass. Validation occurs in prospect_budget and the scalar partition_absorption kernel. This array assembly is separate from the CPU/GPU scalar partition/selection rules.

source
CanopyOptics.constituent_optical_depths — Function
constituent_optical_depths(leaf, optics, idx::Integer)

Scalar concentration × specific-absorption optical depths at wavelength index idx, sharing a common FT for allocation-free use with partition_absorption(HomogeneousAbsorption(), absorbed[idx], coeffs).

source
CanopyOptics.LeafMultiPigmentProperties — Type
LeafMultiPigmentProperties{FT<:Real} <: AbstractLeafProperties

Leaf biochemical and structural state with separate chlorophyll a (Cchla) and chlorophyll b (Cchlb) pools alongside carotenoids (Ccar), anthocyanins (Canth), brown pigments (Cbrown), water (Cw), bulk dry matter (Cm), protein (Cprot), and carbon-based constituents (Ccbc).

When constructed with keywords:

  • Omitting Cm selects PROSPECT-PRO dry-matter mode (Cm = 0, defaulting Cprot = 0.001, Ccbc = 0.009).
  • Supplying Cm explicitly (including Cm = 0 or ForwardDiff.Dual) selects bulk Cm mode, defaulting Cprot = 0, Ccbc = 0 without double-counting dry mass.
  • Setting both Cm > 0 and Cprot > 0 (or Ccbc > 0) throws an ArgumentError.
source
CanopyOptics.LeafSIPProperties — Type
LeafSIPProperties{FT<:Real} <: AbstractLeafProperties

Spectral-invariants leaf model state following Wu et al. (2020, Remote Sens. Environ. 250, 112131, SIP_Model.m), with explicit empirical structural slopes (alpha_lma, f_lma_slope, g_lma_slope) so callers can supply TOML-configured or calibrated invariant parameters without hardcoded magic numbers.

When constructed with keywords, supplying Cprot or Ccbc without Cm defaults Cm = 0, and supplying Cchla or Cchlb without Ccab defaults Ccab = 0, avoiding double-counting dry mass or chlorophyll.

source
CanopyOptics.leaf_sip_budget — Function
leaf_sip_budget(leaf::LeafSIPProperties, optics; surface = nothing, μ_in = 1, n_surface = nothing)

Evaluate the Wu et al. (2020) Leaf-SIP spectral-invariants leaf optical budget (surface = nothing, matching published SIP_Model.m which omits cuticular Fresnel reflection) or a surface-coupled Leaf-SIP+Fresnel budget when an AbstractLeafSurface is supplied (surface = ConeSurface(...) or RoughDielectricSurface(...), with optional n_surface wax dispersion).

Wu et al. (2020)'s default slopes (alpha_lma = 600, f_lma_slope = 2765, g_lma_slope = 102.8) were empirically calibrated for bare surface = nothing; adding an external surface restores physical blue/red cuticular reflectance floors, and alpha_lma, f_lma_slope, and g_lma_slope can be recalibrated when fitting NIR/SWIR plateaus jointly with surface coupling.

Computes absorptance directly via $-\operatorname{expm1}(-k_{\mathrm{elem}})$ without $1 - R - T$ subtraction, preserving $R + T + A = 1$ into the nonabsorbing limit.

source
CanopyOptics.prospect_primal — Function
prospect_primal(x)

Extract the primal scalar value of x, stripping nested ForwardDiff.Dual wrappers while returning non-dual numbers unchanged.

Examples

julia> CanopyOptics.prospect_primal(1.42)
1.42
source

Dorsiventral & Asymmetric-Surface Leaf Stacks

CanopyOptics.DorsiventralLeafProperties — Type
DorsiventralLeafProperties{LP<:AbstractLeafProperties, LS<:AbstractLeafProperties, SAd<:AbstractLeafSurface, SAb<:AbstractLeafSurface} <: AbstractLeafProperties

Two-zone dorsiventral leaf representation separating palisade (adaxial) and spongy (abaxial) mesophyll layers (palisade, spongy, each a LeafProspectProProperties or LeafMultiPigmentProperties) bounded by distinct adaxial (surface_adaxial) and abaxial (surface_abaxial) dielectric surfaces.

Supported structural domains ($N_{\mathrm{tot}} = N_{\mathrm{pal}} + N_{\mathrm{spo}}$):

  • $N_{\mathrm{pal}} \ge 1$ and $N_{\mathrm{spo}} \ge 1$ ($N_{\mathrm{tot}} \ge 2$): exact two-zone Redheffer plate stack.
  • $0 < N_{\mathrm{pal}} \le 1$, $0 < N_{\mathrm{spo}} \le 1$, and $1 \le N_{\mathrm{tot}} < 2$: continuous convex bridge

    \[\mathcal{B}(N_{\mathrm{tot}}) = (2 - N_{\mathrm{tot}})\,\mathcal{B}_{\mathrm{slab}} + (N_{\mathrm{tot}} - 1)\,\mathcal{B}_{1,1}\]

    between the unbroken $N_{\mathrm{tot}} = 1$ two-sublayer slab and the $N_{\mathrm{pal}} = N_{\mathrm{spo}} = 1$ ($N_{\mathrm{tot}} = 2$) stack, preserving strict energy conservation, nonnegative zone absorptances, and bi-hemispherical reciprocity $T_{\mathrm{ad}} = T_{\mathrm{ab}}$ across thin/compact leaves ($C^0$ continuous at $N_{\mathrm{tot}} = 2$).
  • When single_slab == true, evaluates the unbroken $N = 1$ two-sublayer operator single_slab_dorsiventral_budget directly for any positive $(N_{\mathrm{pal}}, N_{\mathrm{spo}})$.

See dorsiventral_from_traits to construct a dorsiventral leaf smoothly from whole-leaf traits across all $N_{\mathrm{tot}} \ge 1$.

source
CanopyOptics.dorsiventral_from_traits — Function
dorsiventral_from_traits(whole_leaf; N_tot = whole_leaf.N,
                         mesophyll_fraction_palisade = 0.45,
                         pigment_fraction_palisade = 0.75,
                         surface_adaxial = ConeSurface(40),
                         surface_abaxial = ConeSurface(40),
                         single_slab = false)

Partition a whole-leaf LeafProspectProProperties or LeafMultiPigmentProperties into a DorsiventralLeafProperties over all continuous total plate counts $N_{\mathrm{tot}} \ge 1$:

  • Photosynthetic and accessory pigments (Ccab or Cchla, Cchlb, Ccar, Canth, Cbrown) are allocated by $f_c \in [0, 1]$ (pigment_fraction_palisade): $C_{\mathrm{pal}} = f_c C$ and $C_{\mathrm{spo}} = (1 - f_c) C$.
  • Water and dry matter (Cw, Cm, Cprot, Ccbc) are allocated by $f_m \in (0, 1)$ (mesophyll_fraction_palisade).
  • Zone plate counts $(N_{\mathrm{pal}}, N_{\mathrm{spo}})$ satisfy $N_{\mathrm{pal}} + N_{\mathrm{spo}} = N_{\mathrm{tot}}$ and meet continuously at $(1, 1)$ across $N_{\mathrm{tot}} = 2$ ($C^0$ continuous at $N_{\mathrm{tot}} = 2$, $C^\infty$ on $(1, 2)$ and $(2, \infty)$):

    \[(N_{\mathrm{pal}},\, N_{\mathrm{spo}}) = \begin{cases} \bigl(f_m + (N_{\mathrm{tot}} - 1)(1 - f_m),\; (1 - f_m) + (N_{\mathrm{tot}} - 1) f_m\bigr), & 1 \le N_{\mathrm{tot}} < 2, \\[4pt] \bigl(1 + (N_{\mathrm{tot}} - 2) f_m,\; 1 + (N_{\mathrm{tot}} - 2)(1 - f_m)\bigr), & N_{\mathrm{tot}} \ge 2. \end{cases}\]

source
CanopyOptics.dorsiventral_budget — Function
dorsiventral_budget(leaf::DorsiventralLeafProperties, optics;
                    μ_ad = 1, μ_ab = 1, hemispherical = false,
                    n_surface = nothing,
                    n_surface_adaxial = n_surface,
                    n_surface_abaxial = n_surface)

Compute paired adaxial-illuminated and abaxial-illuminated leaf optical budgets (; adaxial, abaxial), where each face budget is a NamedTuple containing (; transmission, reflectance, absorptance, absorptance_palisade, absorptance_spongy, reflectance_volume).

Guarantees:

  1. Exact passive conservation $R + T + A_{\mathrm{pal}} + A_{\mathrm{spo}} = 1$ to floating-point roundoff without clipping or rescaling.
  2. Exact reduction to prospect_budget when palisade and spongy zones have equal per-plate optical depth and ConeSurface(40, 1) on both faces.
  3. Exact bi-hemispherical (hemispherical = true) Helmholtz reciprocity $T_{\mathrm{ad}} = T_{\mathrm{ab}}$ under arbitrary pigment, structural ($N_{\mathrm{pal}} \neq N_{\mathrm{spo}}$), cuticular (surf_ad != surf_ab), and wax (n_surface_adaxial != n_surface_abaxial) asymmetry across all $N_{\mathrm{tot}} \ge 1$.
source
CanopyOptics.single_slab_dorsiventral_budget — Function
single_slab_dorsiventral_budget(k_pal, k_spo, nr, surf_ad, surf_ab;
                                μ_ad = 1, μ_ab = 1, hemispherical = false,
                                n_surface_adaxial = nr, n_surface_abaxial = nr)

Evaluate the exact $N = 1$ unbroken two-sublayer dorsiventral slab operator $I_{\mathrm{ad}} \star S_2(k_{\mathrm{pal}}, k_{\mathrm{spo}}) \star I_{\mathrm{ab}}$ without an artificial internal air gap or $(2 E_3(k/2))^2$ chord-splitting error.

source

Dielectric Surface Interfaces & Microfacet Optics

CanopyOptics.ConeSurface — Type
ConeSurface(α_deg = 40, n_scale = 1)

Isotropic incidence-cone dielectric boundary generalizing PROSPECT's Stern–Allen surface (α_deg = 40 reproduces legacy PROSPECT; α_deg = 0 models collimated nadir integrating-sphere illumination; α_deg = 8 models $8^\circ$-port integrating spheres). n_scale scales the outer cuticular refractive index ($n_{\mathrm{eff}} = n_{\mathrm{scale}} \, n_{\mathrm{surface}}$), while internal diffuse exit into the aqueous mesophyll of index $n_r$ obeys exact $1 / n_r^2$ étendue invariance.

source
CanopyOptics.RoughDielectricSurface — Type
RoughDielectricSurface(σ = 0.15, n_scale = 1)

Rough Beckmann microfacet dielectric leaf surface with RMS facet slope $\sigma \in [0.02, 1]$ and effective epicuticular refractive-index factor n_scale ($n_{\mathrm{eff}} = n_{\mathrm{scale}} \, n_{\mathrm{surface}}$). Uses exact erfcx-based Smith separable masking–shadowing ($0 \le R_{\mathrm{surf}} < 1$ strictly) and thermodynamic $1 / n_r^2$ étendue scaling into the aqueous mesophyll of refractive index $n_r$.

source
CanopyOptics.surface_interface_optics — Function
surface_interface_optics(surface::AbstractLeafSurface, μ_in, nr;
                         hemispherical = false, n_surface = nr)

Evaluate external entry and internal diffuse exit probabilities across a leaf's external dielectric boundary:

  • r_ext, t_ext ($= 1 - r_{\mathrm{ext}}$): external reflectance and entry transmittance (directional at $\mu_{\mathrm{in}}$ when hemispherical == false, or bi-hemispherical $2\pi \to 2\pi$ when hemispherical == true), evaluated at outer cuticular refractive index $n_{\mathrm{eff}} = n_{\mathrm{scale}} \, n_{\mathrm{surface}}$.
  • t_hem_ext: bi-hemispherical ($2\pi \to 2\pi$) external transmittance across surface.
  • t_int_diffuse, r_int_diffuse: diffuse internal-to-air exit transmittance $t_{\mathrm{int,diffuse}} = t_{\mathrm{hem,ext}} / n_r^2$ and internal reflectance $1 - t_{\mathrm{int,diffuse}}$ from the aqueous mesophyll ($n_r > 1$) into air ($n = 1$).

Physical thin-cuticle approximation when n_surface != nr (e.g., Stuckens et al. 2009 epicuticular wax $n_{\mathrm{wax}}(\lambda)$ via load_wax_refractive_index): across air ($n = 1$) — lossless thin wax cuticle ($n_{\mathrm{eff}}$) — aqueous mesophyll ($n_r$), smooth internal wax–mesophyll Fresnel reflection is $(n_{\mathrm{eff}} - n_r)^2 / (n_{\mathrm{eff}} + n_r)^2$ ($\approx 0.03$–$0.05\%$ in the VNIR and $\le 0.5\%$ at the $2450\text{ nm}$ SWIR $n_r \approx 1.27$ minimum), with zero wax-to-mesophyll total internal reflection for externally entering rays since $\sin\theta_{\mathrm{wax}} \le 1 / n_{\mathrm{eff}} < n_r / n_{\mathrm{eff}}$ for all $n_r > 1$. Neglecting that $< 0.5\%$ secondary internal bounce, external entry is governed by the air–wax interface ($n_{\mathrm{eff}}$), while diffuse internal exit from the aqueous mesophyll ($n_r$) into air ($n = 1$) obeys exact isothermal detailed-balance étendue invariance $t_{\mathrm{int,diffuse}} = t_{\mathrm{hem,ext}}(n_{\mathrm{eff}}) / n_r^2 \in (0, 1)$.

source
CanopyOptics.calctav_smooth — Function
calctav_smooth(α_deg, nr)

Evaluate cancellation-free Stern (1964) / Allen (1973) cone-averaged dielectric surface transmittance for $\alpha_{\mathrm{deg}} \in [0, 90]$ and $n_r > 1$, supporting Float32, Float64, and ForwardDiff.Dual without precision promotion or $0/0$ singularities at $\alpha_{\mathrm{deg}} = 0^\circ$ or $90^\circ$:

  • For $\sin^2\alpha \le 0.04$ ($\alpha_{\mathrm{deg}} \le 11.54^\circ$, including $0^\circ$ and $8^\circ$), evaluates the strictly positive Fresnel cone integral $\int_0^1 T_F(\xi\sin^2\alpha, n_r)\,\mathrm{d}\xi$ by 5-point Gauss–Legendre quadrature ($< 2\text{ ulp}$ in Float32/Float64, $C^\infty$ at $0^\circ$).
  • Above $0.04$ (including $40^\circ$ and $90^\circ$), evaluates the exact Stern–Allen closed form using $b_1 = \cos\alpha\sqrt{n_r^2 - \sin^2\alpha}$, avoiding $\sqrt{0}$ derivative singularities at $\alpha_{\mathrm{deg}} = 90^\circ$.
source
CanopyOptics.calctav — Function
calctav(α::FT, nr::FT) where {FT<:AbstractFloat}

Computes transmission of isotropic radiation across a dielectric surface (Stern F., 1964; Allen W.A.,Appl. Opt., 3(1):111-113 1973)). From calctav.m in PROSPECT-D

Arguments

  • α angle of incidence [degrees]
  • nr Index of refraction
source
CanopyOptics.Fᵣ — Function
Fᵣ(n, θᵢ)

Compute unpolarized Fresnel power reflectance $(r_s^2 + r_p^2) / 2$ for an air-to-medium interface with real refractive index $n$ at incidence angle θᵢ in radians. See fresnel_components.

Examples

julia> round(CanopyOptics.Fᵣ(1.5, 0.0); digits = 4)
0.04
source
CanopyOptics.fresnel_components — Function
fresnel_components(n, θᵢ)

Compute real-dielectric Fresnel amplitude reflectances (r_s, r_p) for an air-to-medium interface (n_air = 1, medium refractive index n >= 1) at incidence angle θᵢ in radians (Born & Wolf, Principles of Optics, Eqs. 1.5.45–1.5.46):

\[r_s = \frac{\cos\theta_i - n\cos\theta_t}{\cos\theta_i + n\cos\theta_t}, \qquad r_p = \frac{n\cos\theta_i - \cos\theta_t}{n\cos\theta_i + \cos\theta_t},\]

where $\sin\theta_t = \sin\theta_i / n$.

Examples

julia> rs, rp = CanopyOptics.fresnel_components(1.5, 0.0);

julia> (round(rs; digits = 4), round(rp; digits = 4))
(-0.2, 0.2)
source
CanopyOptics.K — Function
K(κ, α)

Compute the Nilson–Kuusk leaf-surface roughness reduction factor:

\[K(\kappa, \alpha) = e^{-\kappa \tan |\alpha|} .\]

  • $\kappa \approx 0.1\text{–}0.3$ controls surface roughness (κ = 0 gives a smooth Fresnel surface).
  • α is the incidence half-angle in radians, with $|\alpha| \le \pi/2$.
  • At grazing incidence ($|\alpha| = \pi/2$), returns 0 for κ > 0 and 1 for κ = 0 without evaluating tan(Float32(π/2)).

Used in compute_reflection to attenuate specular reflectance for rough leaves.

source
CanopyOptics.beckmann_D — Function
beckmann_D(tan2_theta_h, cos2_theta_h, σ)

Evaluate the isotropic Beckmann microfacet normal distribution

\[D(\mathbf{h}) = \frac{\exp(-\tan^2\theta_h / \sigma^2)}{\pi \sigma^2 \cos^4\theta_h}\]

directly from $\tan^2\theta_h = (H_x^2 + H_y^2) / H_z^2$ and $\cos^2\theta_h = H_z^2 / \|\mathbf{H}\|^2$ without inverse trigonometric functions ($C^\infty$ smooth at $\theta_h = 0$).

source
CanopyOptics.smith_beckmann_G1 — Function
smith_beckmann_G1(μ, σ)

Evaluate the exact Beckmann 1D Smith masking–shadowing factor $G_1(\mu; \sigma) = 1 / \bigl(1 + \Lambda(a)\bigr)$ with $a = \mu / (\sigma\sqrt{1 - \mu^2})$ via SpecialFunctions.erfcx. Guards the flat $C^\infty$ nadir neighborhood $(1 - \mu^2)\sigma^2 \le \mu^2 / a_{\max}^2$ before forming $\sqrt{1 - \mu^2}$, eliminating $0/0$ and $\sqrt{0}$ ForwardDiff.Dual singularities at $\mu = 1$.

source
CanopyOptics.microfacet_directional_reflectance — Function
microfacet_directional_reflectance(μ_in, n_eff, σ)

Compute single-bounce directional-hemispherical reflectance $R_{\mathrm{surf},1}(\mu_{\mathrm{in}}, n_{\mathrm{eff}}, \sigma)$ of a Beckmann–Smith dielectric surface ($0 < R_{\mathrm{surf},1} < 1$ strictly), evaluated via the Beckmann slope-CDF $(u, \phi_h)$ change of variables $D(\mathbf{h})\,\mu_h\,\mathrm{d}\omega_h = \mathrm{d}u\,\mathrm{d}\phi_h / (2\pi)$, which eliminates peak-width aliasing across all $\sigma \ge 0.02$ and preserves exact ForwardDiff tangents at nadir $\mu_{\mathrm{in}} = 1$.

source
CanopyOptics.microfacet_hemispherical_reflectance — Function
microfacet_hemispherical_reflectance(n_eff, σ)

Compute bi-hemispherical single-bounce microfacet reflectance:

\[R_{\mathrm{hem}}(n_{\mathrm{eff}}, \sigma) = 2 \int_0^1 R_{\mathrm{surf},1}(\mu, n_{\mathrm{eff}}, \sigma)\,\mu\,\mathrm{d}\mu = \int_0^1 R_{\mathrm{surf},1}(\sqrt{v}, n_{\mathrm{eff}}, \sigma)\,\mathrm{d}v.\]

source

Coupled 4×4 Polarized Leaf BSDF

CanopyOptics.CoupledLeafBSDF — Type
CoupledLeafBSDF(leaf, surface; η_t = 0, γ_t = 4)
CoupledLeafBSDF(dorsiventral_leaf; η_t = 0, γ_t = 4)
CoupledLeafBSDF(asymmetric_surface_leaf; η_t = 0, γ_t = 4)

Energy-conserving, Helmholtz-reciprocal, Stokes-polarized leaf bidirectional scattering distribution function (BRDF + BTDF + Mueller matrix) coupling rough dielectric microfacet surface optics consistently with internal plate transport:

  1. First-surface reflection ($\mathbf{M}_{r,\mathrm{surf}}$): Beckmann normal distribution ($\tan^2\theta_h = (H_x^2 + H_y^2) / H_z^2$), erfcx-based Smith shadowing–masking $G_2 = G_1(\mu_i)\,G_1(\mu_o)$, trigonometric-free Fresnel amplitudes, and algebraic meridian-plane Stokes rotations (npol in $\{1, 3, 4\}$), obeying exact Hovenier reciprocity $\mathbf{M}(\boldsymbol{\omega}_o \to \boldsymbol{\omega}_i) = \mathbf{P}\,\mathbf{M}(\boldsymbol{\omega}_i \to \boldsymbol{\omega}_o)^\top \mathbf{P}$ with $\mathbf{P} = \operatorname{diag}(1, 1, -1, 1)$.
  2. Internal volume BRDF ($f_{r,\mathrm{vol}}$): Coupled through external entry $T_{\mathrm{ext},s}(\mu_i) = 1 - R_{\mathrm{surf},s}(\mu_i)$ and directional escape $E_s(\mu_o) = T_{\mathrm{ext},s}(\mu_o) / T_{\mathrm{hem,ext},s}$ using the same RoughDielectricSurface (never a mismatched ConeSurface).
  3. Directional transmission ($f_t$): Symmetric Kelemen–Szirmay-Kalos / Kulla–Conty closure combining diffuse escape ($1 - \eta_t$) with a normalized forward lobe ($\eta_t \in [0, 1)$, concentration $\gamma_t \ge 0$), guaranteeing strict nonnegativity, exact hemispherical conservation $R(\mu_i) + T(\mu_i) + A(\mu_i) = 1$, and exact directional Helmholtz reciprocity $f_t(\boldsymbol{\Omega}_{\mathrm{in}} \to \boldsymbol{\Omega}_{\mathrm{out}}) = f_t(-\boldsymbol{\Omega}_{\mathrm{out}} \to -\boldsymbol{\Omega}_{\mathrm{in}})$.
source
CanopyOptics.PreparedLeafBSDFSpectrum — Type
PreparedLeafBSDFSpectrum{FT<:Real}

Wavelength-resolved precomputation returned by prepare_leaf_bsdf storing adaxial and abaxial cuticular surface parameters, outer refractive-index spectra (n_surf_ad, n_surf_ab), hemispherical volume/transmission/absorption budgets, 12-node directional escape profiles, and Kelemen–Szirmay-Kalos directional transmission normalization constants. Enables O(1) multi-angle BRDF, BTDF, and Stokes Mueller evaluations via leaf_bsdf_spectrum and leaf_directional_budget.

source
CanopyOptics.prepare_leaf_bsdf — Function
prepare_leaf_bsdf(model::CoupledLeafBSDF, optics::AbstractProspectProperties;
                  n_surface = nothing,
                  n_surface_adaxial = n_surface,
                  n_surface_abaxial = n_surface)

Precompute wavelength-dependent hemispherical internal budgets and symmetric Kelemen–Szirmay-Kalos transmission normalization constants once per leaf state, so subsequent multi-angle BRDF / BTDF / Stokes Mueller evaluations are O(1) per wavelength and direction pair. Pass n_surface = load_wax_refractive_index(λ_bnds) (or face-specific n_surface_adaxial, n_surface_abaxial on dorsiventral / asymmetric-surface leaves) to include epicuticular wax dispersion.

source
CanopyOptics.surface_brdf_mueller — Function
surface_brdf_mueller(μ_i, ϕ_i, μ_o, ϕ_o, n_eff, σ, npol = 1)

Evaluate the single-bounce polarized microfacet BRDF Mueller matrix $\mathbf{M}_{r,\mathrm{surf}}$ (size npol × npol, npol in $\{1, 3, 4\}$) in the leaf local frame ($\hat{\mathbf{z}} = (0, 0, 1)$ outward face normal), where $(\mu_i, \phi_i)$ points toward the illumination source ($\mathbf{k}_{\mathrm{in}} = -\boldsymbol{\omega}_i$) and $(\mu_o, \phi_o)$ points toward the detector ($\mathbf{k}_{\mathrm{out}} = +\boldsymbol{\omega}_o$), with $\mu_i, \mu_o \in (0, 1]$.

In the meridian-plane Stokes convention of CanopyOptics, $+Q$ denotes perpendicular ($s$ / horizontal) linear polarization and $-Q$ denotes parallel ($p$ / in-meridian) linear polarization. All geometry and Stokes rotations are computed algebraically without acos, asin, or atan singularities.

source
CanopyOptics.leaf_directional_budget — Function
leaf_directional_budget(prep::PreparedLeafBSDFSpectrum, μ_i; face = :adaxial)
leaf_directional_budget(model::CoupledLeafBSDF, optics, μ_i;
                        face = :adaxial, n_surface = nothing,
                        n_surface_adaxial = n_surface, n_surface_abaxial = n_surface)

Compute the exact directional-hemispherical budget (; reflectance, reflectance_surface, reflectance_volume, transmission, absorptance) for collimated incidence at cosine $\mu_i \in (0, 1]$ on face (:adaxial or :abaxial). Satisfies $R(\mu_i) + T(\mu_i) + A(\mu_i) = 1$ across all $\mu_i \in (0, 1]$.

source
CanopyOptics.leaf_bsdf_spectrum — Function
leaf_bsdf_spectrum(prep::PreparedLeafBSDFSpectrum, μ_i, ϕ_i, μ_o, ϕ_o;
                   face = :adaxial, npol = 1)
leaf_bsdf_spectrum(model::CoupledLeafBSDF, optics, μ_i, ϕ_i, μ_o, ϕ_o;
                   face = :adaxial, npol = 1)

Evaluate the spectral leaf BSDF at incident source direction $(\mu_i, \phi_i)$ on face (:adaxial or :abaxial), reflected detector direction $(\mu_o, \phi_o)$ ($\mu_o > 0$ on the illuminated face), and transmitted detector direction $(\mu_o, \phi_o)$ ($\mu_o > 0$ measured from the opposite face normal $-\hat{\mathbf{z}}$, so straight-through forward continuation of $(\theta_i, \phi_i = 0)$ is $(\theta_o = \theta_i, \phi_o = \pi)$):

  • brdf: total scalar BRDF $[\mathrm{sr}^{-1}]$ (nλ-vector, equal to $f_{r,\mathrm{surf}} + f_{r,\mathrm{vol}}$).
  • btdf: total scalar BTDF $[\mathrm{sr}^{-1}]$ (nλ-vector).
  • brdf_mueller: (npol, npol, nλ) polarized BRDF Mueller array ($M_{11}$ equals brdf; diffuse internal multiple scattering populates $(1, 1)$ unpolarized).
  • dolp: reflected degree of linear polarization $\sqrt{M_{21}^2 + M_{31}^2} / M_{11}$ when npol >= 3 (for unpolarized incident light), or zeros(FT, nλ) when npol == 1.
source