Linear combinations of distribution functions
About this example
This example shows how to create linear combinations of surface and volume scattering distribution functions.
Show code cell source
%matplotlib widget
from rt1_model import volume, surface
import matplotlib.pyplot as plt
Volume scattering distributions
To create a linear-combination for volume-scattering distribution functions, simply provide a list of
weights and distributions to the volume.LinComb class.
V_1 = volume.Isotropic()
V_2 = volume.HenyeyGreenstein(t=0.4, ncoefs=10)
V = volume.LinComb([(0.5, V_1), (0.5, V_2)])
V.polarplot()
Parametric linear combinations
It is also possible to use symbolic weights to obtain parametric linear-combinations!
V_1 = volume.Rayleigh()
V_2 = volume.HenyeyGreenstein(t="t", ncoefs=12)
V = volume.LinComb([("w", V_1), ("1-w", V_2)])
f = plt.figure(figsize=(10, 4))
f.canvas.header_visible = False
ax1, ax2, ax3 = f.add_subplot(131, projection="polar"), f.add_subplot(132, projection="polar"), f.add_subplot(133, projection="polar")
V.polarplot(ax=ax1, param_dict=dict(w=0., t=0.6), legend=False)
V.polarplot(ax=ax2, param_dict=dict(w=0.5, t=0.6), legend=False)
V.polarplot(ax=ax3, param_dict=dict(w=0.8, t=0.6), legend=False)
f.tight_layout()
Surface scattering distributions
Linear combinations of surface scattering distribution functions work completely similar!
SRF_1 = surface.Isotropic()
SRF_2 = surface.HenyeyGreenstein(t=0.4, ncoefs=10)
SRF = surface.LinComb([(0.5, SRF_1), (0.5, SRF_2)])
SRF.polarplot()
Parametric linear combinations
Parametric combinations for surface scattering functions also work in the exact same way!
SRF_1 = surface.HenyeyGreenstein(t="-t", a=[-1, 1, 1], ncoefs=12)
SRF_2 = surface.HenyeyGreenstein(t="t", ncoefs=12)
SRF = surface.LinComb([("w", SRF_1), ("1-w", SRF_2)])
f = plt.figure(figsize=(10, 4))
f.canvas.header_visible = False
axes = (f.add_subplot(131, projection="polar"),
f.add_subplot(132, projection="polar"),
f.add_subplot(133, projection="polar"))
for ax, (w, t) in zip(axes, ((0.2, 0.4), (0.4, 0.6), (0.8, 0.6))):
SRF.polarplot(ax=ax, param_dict=dict(w=w, t=t), legend=False, label=f"BRDF with w={w} and t={t}")
f.tight_layout()