{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Fast Camera's lins of sight\n", "===" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Show all of lines of sight of camera in 3-D space with PHiX CAD model" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from pathlib import Path\n", "\n", "import calcam\n", "import numpy as np\n", "import plotly.graph_objects as go\n", "\n", "from cherab.phix import __path__\n", "from cherab.phix.machine import show_PFCs_3D\n", "\n", "CALIB_PATH = (\n", " Path(__path__[0]) / \"observer\" / \"fast_camera\" / \"calibration_data\" / \"shot_17393_ideal.ccc\"\n", ")\n", "CAD_PATH = Path(__path__[0]) / \"machine\" / \"geometry\" / \"data\" / \"PHiX_calcam_CAD.ccm\"" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Load calcam data and ray cast" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Load the calibration\n", "cam_calib = calcam.Calibration(CALIB_PATH)\n", "\n", "# Load the CAD model\n", "phix_cad = calcam.CADModel(CAD_PATH)\n", "\n", "# Do the ray cast to find the sight-line / CAD model intersection coordinates\n", "raydata = calcam.raycast_sightlines(cam_calib, phix_cad)" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Visualize lines of sight with PHiX CAD" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# PHiX PFCs\n", "fig = show_PFCs_3D(fig_size=(700, 500))\n", "\n", "\n", "# Plot lines of sight\n", "for row in range(0, raydata.ray_start_coords.shape[0], 16):\n", " for column in range(0, raydata.ray_start_coords.shape[1], 16):\n", " start = raydata.ray_start_coords[row, column, :]\n", " end = raydata.ray_end_coords[row, column, :]\n", " ray = np.vstack((start, end))\n", " line = go.Scatter3d(\n", " x=ray[:, 0],\n", " y=ray[:, 1],\n", " z=ray[:, 2],\n", " mode=\"lines\",\n", " hovertemplate=f\"LoS at ({row}, {column}) pixel\",\n", " showlegend=False,\n", " line=dict(color=\"#1f77b4\", width=1),\n", " )\n", " fig.add_trace(line)\n", "\n", "fig.show()" ] } ], "metadata": { "kernelspec": { "display_name": "cherab-phix-dev", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.15 | packaged by conda-forge | (main, Nov 22 2022, 15:55:03) \n[GCC 10.4.0]" }, "orig_nbformat": 4, "vscode": { "interpreter": { "hash": "2725905a4c02db19e04df9b8fdbbe5ec65a73ea52bebaf9474aa1cc98819834c" } } }, "nbformat": 4, "nbformat_minor": 2 }