Comparing closure approximations¶

In [1]:
try:
    %matplotlib widget
except (ImportError, RuntimeError):
    %matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D

from fiberoripy.closures import (
    IBOF_closure,
    get_random_tensor_pair,
    hybrid_closure,
    linear_closure,
    quadratic_closure,
)
from fiberoripy.tensorplot import (
    plot_orbit2,
    plot_orbit4,
    plot_projection2,
    plot_projection4,
)
In [2]:
# create a fourth order fiber orientation tensor
a, A = get_random_tensor_pair(seed=1.0 / 3.0 * np.eye(3), N=100)

# compute a couple of closures
A_hybrid = hybrid_closure(a)
A_ibof = IBOF_closure(a)
A_lin = linear_closure(a)
A_quad = quadratic_closure(a)
In [3]:
# Second order tensor plot
fig = plt.figure(figsize=(12, 8))

ax = fig.add_subplot(221, projection=Axes3D.name)
plotargs = {"rstride": 4, "cstride": 4}
plot_orbit2(ax, plotargs, a)

ax = fig.add_subplot(222)
plot_projection2(ax, "xy", a)

ax = fig.add_subplot(223)
plot_projection2(ax, "xz", a)

ax = fig.add_subplot(224)
plot_projection2(ax, "yz", a)

plt.show()
No description has been provided for this image
In [4]:
# Fourth order tensor plot
fig = plt.figure(figsize=(12, 8))

ax = fig.add_subplot(221, projection=Axes3D.name)
plotargs = {"alpha": 0.1, "rstride": 4, "cstride": 4}
plot_orbit4(ax, plotargs, A, A_hybrid, A_lin, A_quad, A_ibof)

ax = fig.add_subplot(222)
plot_projection4(ax, "xy", A, A_hybrid, A_lin, A_quad, A_ibof)

ax = fig.add_subplot(223)
plot_projection4(ax, "xz", A, A_hybrid, A_lin, A_quad, A_ibof)

ax = fig.add_subplot(224)
plot_projection4(ax, "yz", A, A_hybrid, A_lin, A_quad, A_ibof)

plt.legend(["Original", "Hybrid", "Linear", "Quadratic", "IBOF"])

plt.show()
No description has been provided for this image