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.2.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.2-py3-none-any.whl (47.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: optical_table-1.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 4a5a7b4bf51a093e53c515226b7e6c4979363958e1e9d0b2bafde6a7fee5d1ce
MD5 b22f3675067af05c7330771b1eba706b
BLAKE2b-256 aa8e83eca70c66a77fdba519c0cab792a13e9e0d808434c394659c56b4a6e56a

See more details on using hashes here.

Provenance

The following attestation bundles were made for optical_table-1.0.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: optical_table-1.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c69aae500551050eb869d0b5fcd5368a08c3aa2ed09b929f67391d0052609cf5
MD5 4ae26eccc379842415e9dd237a80b536
BLAKE2b-256 bec6d14a7f3f59cf7d2547195865857df516eff672cfeb75cfed26cb94a3a05e

See more details on using hashes here.

Provenance

The following attestation bundles were made for optical_table-1.0.2-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