{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "e355c3b8",
   "metadata": {},
   "source": [
    "# Lens Information\n",
    "\n",
    "`LensInfoViewer` prints a surface-by-surface summary of an optical system.\n",
    "`optic.info()` is the convenience entry point for the same viewer. Unlike an\n",
    "analysis plot, this table describes the lens prescription, not spot quality or\n",
    "image-plane irradiance."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f8e8a5dd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "╒════╤═════════════════╤═══════════╤═══════════╤═════════════╤════════════╤═════════╤═════════════════╕\n",
      "│    │ Type            │ Comment   │    Radius │   Thickness │ Material   │   Conic │   Semi-aperture │\n",
      "╞════╪═════════════════╪═══════════╪═══════════╪═════════════╪════════════╪═════════╪═════════════════╡\n",
      "│  0 │ Planar          │           │  inf      │   inf       │ Air        │       0 │         9.19008 │\n",
      "│  1 │ Standard        │           │   22.0136 │     3.25896 │ SK16       │       0 │         9.19008 │\n",
      "│  2 │ Standard        │           │ -435.76   │     6.00755 │ Air        │       0 │         7.93701 │\n",
      "│  3 │ Standard        │           │  -22.2133 │     0.99997 │ F2         │       0 │         4.12082 │\n",
      "│  4 │ Stop - Standard │           │   20.2919 │     4.75041 │ Air        │       0 │         3.80085 │\n",
      "│  5 │ Standard        │           │   79.6836 │     2.95208 │ SK16       │       0 │         6.43676 │\n",
      "│  6 │ Standard        │           │  -18.3953 │    42.2078  │ Air        │       0 │         7.35478 │\n",
      "│  7 │ Planar          │           │  inf      │   nan       │ Air        │       0 │        18.1455  │\n",
      "╘════╧═════════════════╧═══════════╧═══════════╧═════════════╧════════════╧═════════╧═════════════════╛\n",
      "\n"
     ]
    }
   ],
   "source": [
    "from optiland.samples.objectives import CookeTriplet\n",
    "from optiland.visualization import LensInfoViewer\n",
    "\n",
    "lens = CookeTriplet()\n",
    "lens.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3eed87c2",
   "metadata": {},
   "source": [
    "## Read the surface table\n",
    "\n",
    "The row index is the surface index: 0 is the object surface, 1–6 are the six\n",
    "refracting surfaces of the three lens elements, and 7 is the image surface.\n",
    "\n",
    "| Column | Interpretation |\n",
    "| --- | --- |\n",
    "| Type | Surface geometry; `Stop -` marks the aperture stop (surface 4 here). |\n",
    "| Comment | Optional surface annotation; blank for this sample. |\n",
    "| Radius | Signed radius of curvature in mm; `inf` denotes a plane. |\n",
    "| Thickness | Axial distance in mm from this surface to the next one. |\n",
    "| Material | Medium immediately after the surface, not before it. |\n",
    "| Conic | Dimensionless conic constant; zero for this sample's spherical surfaces. |\n",
    "| Semi-aperture | Surface semi-aperture in mm, not the full diameter. |\n",
    "\n",
    "For example, surface 1 has radius 22.01359 mm and thickness 3.25896 mm;\n",
    "the medium after it is SK16. Surface 3 introduces F2 and surface 5 introduces\n",
    "SK16 again. The object is at infinity, so its thickness is infinite; the image\n",
    "surface has no following surface, so its thickness is `nan`. Displayed numbers\n",
    "are rounded and should be checked against the sample definition for full precision.\n",
    "\n",
    "The viewer updates the paraxial model before printing. Semi-apertures reflect the\n",
    "current model (or an explicit radial aperture when present); they are not a\n",
    "manufacturing specification for mechanical lens diameters. For aspheric systems,\n",
    "the viewer also prints a coefficient table. This Cooke triplet has no aspheric\n",
    "coefficients."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "36b2b3eb",
   "metadata": {},
   "source": [
    "## Use the viewer directly\n",
    "\n",
    "The explicit form below prints the same information. Neither entry point takes\n",
    "display options or returns a DataFrame; use whichever form fits your workflow.\n",
    "For a more extensive optical report, see the separate prescription gallery example."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fcaa952a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "╒════╤═════════════════╤═══════════╤═══════════╤═════════════╤════════════╤═════════╤═════════════════╕\n",
      "│    │ Type            │ Comment   │    Radius │   Thickness │ Material   │   Conic │   Semi-aperture │\n",
      "╞════╪═════════════════╪═══════════╪═══════════╪═════════════╪════════════╪═════════╪═════════════════╡\n",
      "│  0 │ Planar          │           │  inf      │   inf       │ Air        │       0 │         9.19008 │\n",
      "│  1 │ Standard        │           │   22.0136 │     3.25896 │ SK16       │       0 │         9.19008 │\n",
      "│  2 │ Standard        │           │ -435.76   │     6.00755 │ Air        │       0 │         7.93701 │\n",
      "│  3 │ Standard        │           │  -22.2133 │     0.99997 │ F2         │       0 │         4.12082 │\n",
      "│  4 │ Stop - Standard │           │   20.2919 │     4.75041 │ Air        │       0 │         3.80085 │\n",
      "│  5 │ Standard        │           │   79.6836 │     2.95208 │ SK16       │       0 │         6.43676 │\n",
      "│  6 │ Standard        │           │  -18.3953 │    42.2078  │ Air        │       0 │         7.35478 │\n",
      "│  7 │ Planar          │           │  inf      │   nan       │ Air        │       0 │        18.1455  │\n",
      "╘════╧═════════════════╧═══════════╧═══════════╧═════════════╧════════════╧═════════╧═════════════════╛\n",
      "\n"
     ]
    }
   ],
   "source": [
    "viewer = LensInfoViewer(lens)\n",
    "viewer.view()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "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.13.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
