Note

This page was generated from docs/notebooks/observer/fast_camera_reflection.ipynb.

Ray-traced images#

Here, I simulated the fast-visible camera equiped with PHiX using raysect, and considered the reflected light effect by comparing a non-reflected image with normal one.

[1]:
from pathlib import Path

import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.axes_grid1 import ImageGrid

plt.rcParams["figure.dpi"] = 150
plt.rcParams["font.size"] = 13

Set file paths and show the information about ray-tracing conditions.

[2]:
# path to folder storing ray-traced data
DATA_SYNTHETIC_DIR = Path().cwd().parent / "data" / "synthetic_data"
W_REFLECTION = DATA_SYNTHETIC_DIR / "2020_07_25_01_51_55"
WO_REFLECTION = DATA_SYNTHETIC_DIR / "2020_07_24_20_39_22_wo_ref"

# header information
print("With the effect of reflected light:")
print((W_REFLECTION / "result.txt").read_text())

print("Without the effect of reflected light:")
print((WO_REFLECTION / "result.txt").read_text())
With the effect of reflected light:
--------------------------------------------------------------------------------
camera name              : PHiX fast-visible camera
camera pixels            : (256, 512)
camera per pixel samples : 5
camera lens samples      : 10
camera pixel samples     : 50
camera spectral bins     : 50
camera wavelength range  : 655.6, 656.8
primitives material      : <class 'cherab.phix.machine.material.roughmetal.RoughSUS316L'>
--------------------------------------------------------------------------------

Without the effect of reflected light:
--------------------------------------------------------------------------------
camera name              : PHiX fast-visible camera
camera pixels            : (256, 512)
camera per pixel samples : 5
camera lens samples      : 10
camera pixel samples     : 50
camera spectral bins     : 50
camera wavelength range  : 655.6, 656.8
primitives material      : <class 'raysect.optical.material.absorber.AbsorbingSurface'>
--------------------------------------------------------------------------------

show the typcal ray-traced image with reflection.

[3]:
# Load ray-traced images
power_wo = np.load(WO_REFLECTION / "Power.npy")
power_total = np.load(W_REFLECTION / "Power.npy")
power_ref = power_total - power_wo
A_1px = (20e-6) ** 2  # Area of 1 pixel
[4]:
fig = plt.figure()
vmax = power_total.max() / A_1px
vmin = 0.0
grid = ImageGrid(
    fig, 111, nrows_ncols=(1, 1), axes_pad=0.02, label_mode="L", cbar_mode="single", cbar_pad=0
)
im1 = grid[0].imshow(np.transpose(power_total) / A_1px, cmap="jet", vmax=vmax, vmin=vmin)
grid[0].set_xlabel("x [px]")
grid[0].set_ylabel("y [px]")
grid[0].set_title("total")
cbar1 = plt.colorbar(im1, grid.cbar_axes[0])
cbar1.set_label("Irradiance [W/m$^2$]")
../../_images/notebooks_observer_fast_camera_reflection_7_0.png

Compare with w/o reflection light by subtracting without reflection irradiance from total Irradiance.#

[5]:
fig = plt.figure(figsize=(7, 100))
vmax = power_total.max() / A_1px
vmin = 0.0
grid = ImageGrid(
    fig, 111, nrows_ncols=(1, 3), axes_pad=0.02, label_mode="L", cbar_mode="single", cbar_pad=0
)
im1 = grid[0].imshow(np.transpose(power_total) / A_1px, cmap="jet", vmax=vmax, vmin=vmin)
im2 = grid[1].imshow(np.transpose(power_wo) / A_1px, cmap="jet", vmax=vmax, vmin=vmin)
im3 = grid[2].imshow(np.transpose(power_ref) / A_1px, cmap="jet", vmax=vmax, vmin=vmin)
grid[0].set_xlabel("x [px]")
grid[0].set_ylabel("y [px]")
grid[0].set_title("total")
grid[1].set_title("w/o Reflection")
grid[2].set_title("Reflection only")
cbar1 = plt.colorbar(im1, grid.cbar_axes[0])
cbar1.set_label("Irradiance [W/m$^2$]")
../../_images/notebooks_observer_fast_camera_reflection_9_0.png

Let’s compare values which is retrieved by slicing the above images either at cetain x or y line. The slicing points is corresponding to the pixel having the maximum value.

[6]:
max_point = np.unravel_index(np.argmax(power_total), power_total.shape)
[7]:
fig, ax = plt.subplots()
ypx = max_point[1] + 1
# ypx = 256
ax.plot(power_total[:, ypx - 1] / A_1px, label="total")
ax.plot(power_wo[:, ypx - 1] / A_1px, label="w/o reflection")
ax.plot(power_ref[:, ypx - 1] / A_1px, label="Reflection only")
ax.legend()
ax.set_ylabel("Irradiance [W/m$^2$]")
ax.set_xlabel("x [px]")
ax.set_title(f"y = {ypx} px")
# ax.set_ylim(0, 40)
ax.set_xlim(0, power_total.shape[0] - 1)
ax.set_ylim(0, 90);
# fig.set_size_inches(6,5)
../../_images/notebooks_observer_fast_camera_reflection_12_0.png
[8]:
fig, ax = plt.subplots()
xpx = max_point[0] + 1
ax.plot(power_total[xpx - 1, :] / A_1px, label="total")
ax.plot(power_wo[xpx - 1, :] / A_1px, label="w/o reflection")
ax.plot(power_ref[xpx - 1, :] / A_1px, label="Reflection only")
ax.legend()
ax.set_ylabel("Irradiance [W/m$^2$]")
ax.set_xlabel("y [px]")
ax.set_title(f"x = {xpx} px")
# ax.set_ylim(0, 40)
ax.set_xlim(0, power_total.shape[1] - 1)
ax.set_ylim(0, 90);
# fig.set_size_inches(6,5)
../../_images/notebooks_observer_fast_camera_reflection_13_0.png