Skip to main content

A simple ray tracing and visualization tool for freespace optics.

Project description

Optable Logo

Optable — Ray tracing on an Optical table

A simple ray tracing and visualization tool for freespace optics.

dedicated to phys students working with freespace optics.

Python Version License GitHub Stars GitHub Forks GitHub Issues GitHub Pull Requests

For documentation see online documentation on Read The Docs.

For examples of use check Examples.

Documentation Status PyPI version

Installation

pip install optical_table

or install from source:

git clone https://github.com/tim4431/optable.git
cd optable
pip install -e .

Example

Gaussian beam tracing

import numpy as np, matplotlib.pyplot as plt
from optable import *

wl = 780e-9
w0 = 10e-6

r0 = [
    Ray([-10, 0, 0], [1, 0, 0], wavelength=wl, w0=w0),
    Ray([-10, 2, 0], [1, 0, 0], wavelength=wl, w0=w0),
    Ray([-10, 4, 0], [1, 0, 0], wavelength=wl, w0=w0),
    Ray([-10, 6, 0], [1, 0, 0], wavelength=wl, w0=w0),
    Ray([-10, 9, 0], [1, 0, 0], wavelength=wl, w0=w0),
    Ray([-10, 21, 0], [1, 0, 0], wavelength=wl, w0=w0).RotZ(-np.pi / 4),
]

m0 = Mirror([0, 0, 0]).RotZ(np.pi / 6)
l0 = Lens([0, 2, 0], radius=0.8, focal_length=5)
l1 = Lens([0, 4, 0], radius=0.8, focal_length=10)
l2 = Lens([0, 6.5, 0], radius=0.8, focal_length=10)
slab0 = GlassSlab([0, 9, 0], n1=1, n2=2, thickness=5)
m1 = Mirror([0, 11, 0]).RotZ(-np.pi / 2)

rays = r0
components = [m0, l0, l1, l2, slab0, m1]

table = OpticalTable()
table.add_components(components)
table.ray_tracing(rays)

fig, ax0 = plt.subplots(1, 1, figsize=(12, 6))
table.render(
    ax0,
    type="Z",
    gaussian_beam=True,
    spot_size_scale=1,
    roi=[-15, 30, -10, 20],
)
plt.show()

Result gaussian_beam

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

optical_table-1.0.1.tar.gz (44.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

optical_table-1.0.1-py3-none-any.whl (47.0 kB view details)

Uploaded Python 3

File details

Details for the file optical_table-1.0.1.tar.gz.

File metadata

  • Download URL: optical_table-1.0.1.tar.gz
  • Upload date:
  • Size: 44.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for optical_table-1.0.1.tar.gz
Algorithm Hash digest
SHA256 0bca99ebf03505c686324a9bdadd6eae7c4c03fc90eef7580207dcd7ef1f4740
MD5 1ef66dc0e9c9c1f7ebac37eb32a2bafa
BLAKE2b-256 e789b42a2d955e189320e377bbcb5aa85d816112f5751add784be29e41261820

See more details on using hashes here.

Provenance

The following attestation bundles were made for optical_table-1.0.1.tar.gz:

Publisher: python-publish.yml on tim4431/optable

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file optical_table-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: optical_table-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 47.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for optical_table-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 182a065ca54307f78eb2334980455818302b312574fd660be81cdfea14395f9c
MD5 a41e8ad602ce4238c4d3206929647439
BLAKE2b-256 856c8781a08430c3922f2b27589deaeaf15066d7a7fbe8d71c0c8d7ac7f68ddf

See more details on using hashes here.

Provenance

The following attestation bundles were made for optical_table-1.0.1-py3-none-any.whl:

Publisher: python-publish.yml on tim4431/optable

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page