Note

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

Fast Camera’s lins of sight#

Show all of lines of sight of camera in 3-D space with PHiX CAD model

[1]:
from pathlib import Path

import calcam
import numpy as np
import plotly.graph_objects as go

from cherab.phix import __path__
from cherab.phix.machine import show_PFCs_3D

CALIB_PATH = (
    Path(__path__[0]) / "observer" / "fast_camera" / "calibration_data" / "shot_17393_ideal.ccc"
)
CAD_PATH = Path(__path__[0]) / "machine" / "geometry" / "data" / "PHiX_calcam_CAD.ccm"

Load calcam data and ray cast

[2]:
# Load the calibration
cam_calib = calcam.Calibration(CALIB_PATH)

# Load the CAD model
phix_cad = calcam.CADModel(CAD_PATH)

# Do the ray cast to find the sight-line / CAD model intersection coordinates
raydata = calcam.raycast_sightlines(cam_calib, phix_cad)
Extracting CAD model...
Loading mesh file: FBC_half_down.STL...
Loading mesh file: FBC_half_down2.STL...
Loading mesh file: FBC_half_up.STL...
Loading mesh file: FBC_half_up2.STL...
Loading mesh file: FL_half.STL...
Loading mesh file: FL_half2.STL...
Loading mesh file: limiter_225.STL...
Loading mesh file: limiter_box.STL...
Loading mesh file: MG_port.STL...
Loading mesh file: vaccum_flange.STL...
Loading mesh file: rail_connection_half.STL...
Loading mesh file: rail_connection_half2.STL...
Loading mesh file: rail_half_down.STL...
Loading mesh file: rail_half_down2.STL...
Loading mesh file: rail_half_up.STL...
Loading mesh file: rail_half_up2.STL...
Loading mesh file: vessel_gasket_half.STL...
Loading mesh file: vessel_gasket_half2.STL...
Loading mesh file: vessel_wall_fine.STL...
Loading mesh file: vessel_wall_fine2.STL...
Casting 131.1k rays...

Visualize lines of sight with PHiX CAD

[3]:
# PHiX PFCs
fig = show_PFCs_3D(fig_size=(700, 500))


# Plot lines of sight
for row in range(0, raydata.ray_start_coords.shape[0], 16):
    for column in range(0, raydata.ray_start_coords.shape[1], 16):
        start = raydata.ray_start_coords[row, column, :]
        end = raydata.ray_end_coords[row, column, :]
        ray = np.vstack((start, end))
        line = go.Scatter3d(
            x=ray[:, 0],
            y=ray[:, 1],
            z=ray[:, 2],
            mode="lines",
            hovertemplate=f"LoS at ({row}, {column}) pixel<extra></extra>",
            showlegend=False,
            line=dict(color="#1f77b4", width=1),
        )
        fig.add_trace(line)

fig.show()