Skip to main content

otk - optics toolkit

Toolkit for doing optics in Python

Features include

  • 3D engine based on sphere tracing for simple robust implicit surfaces and constructive solid geometry,
  • nonsequential ray tracing engine,
  • programmatic lookup of full RefractiveIndex.INFO database,
  • import of lenses and glass catalogs from Zemax.

Installation

Installation methods include:

  • Clone repository and interact with it using Poetry e.g. poetry run view-zmx <zemax-file> or poetry shell.
  • Install from package repository (e.g. PyPi) with pip: pip install otk.
  • Development mode with [: poetry add <path-to-local-repo>.
  • From package repository (e.g. PyPi) with Poetry: poetry add otk.

Getting started

  1. Check out the scripts in examples.
  2. View one of the lenses in designs with the command line tool view-zmx.

Documentation

(Yep, this is it at the moment.)

Command line tools

view-zmx <zemaxfile> launches a viewer of a Zemax lens.

Packages

  • otk.sdb - Geometry library based on signed distance bounds.
  • otk.rt1 - First attempt at ray tracing package. Superseded by otk.rt2.
  • otk.rt2 - Ray tracing package with flexible geometry based on otk.sdb. See also otk.rt2_scalar_qt.
  • otk.asbp - Angular spectrum beam propagation.
  • otk.abcd - 1D ray transfer matrix ("ABCD matrices") tools.
  • otk.rtm4 - abstractions for 1D ray transfer matrices, building upon otk.abcd.
  • otk.pgb - parabasal Gaussian routines for doing wave optical calculations with ray tracing results. Builds upon otk.rt1.
  • otk.h4t - homogeneous 4x4 transformation matrices.
  • otk.paraxial - basic paraxial optics calculations.
  • otk.math - various optics-specific math functions.
  • otk.pov - tools for generating POV-Ray scenes of optical setups.
  • otk.pov - for calculating properties of prisms.
  • otk.qt - Qt-related utilities
  • otk.ri - refractive index tools.
  • otk.trains - axially symmetric optical systems
  • otk.v3 - operations on homogeneous vectors in 2D
  • otk.v4 - operations on homogeneous vectors in 3D
  • otk.v4b - broadcasting operations on homogeneous vectors in 3D
  • otk.zemax - reading Zemax files

Roadmap

  • Import of wavelengths, field, and stop from Zemax.
  • Variables to allow rapid changes for animation and optimization.
  • Cool demos: rainbow, lighthouse.
  • Improve physical & wave optics.
    • Upgrade parabasal Gaussians to use rt2.
    • Upgrade asbp to use rt2.
    • Demos e.g. spherical aberration acting on Gaussian beam, Arago spot.

Folder contents

  • otk - the Python package itself. Package data includes
    • otk/properties - material properties databases.
    • otk/notes - miscellaneous notes including derivations.
  • examples - example scripts.

Package management

otk uses Poetry for package management. This means that dependencies, version, entry points etc are all defined in pyproject.toml.

Using PyPi test instance

To setup, add test.pypi.org to your Poetry configuration with poetry config repositories.test https://test.pypi.org/legacy/. Note the trailing slash.

To publish (after poetry build), poetry publish -r test.

To test that it installs properly,

  1. create and activate a virtual environment, and
  2. per instructions, pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple otk.

However, I was unable to re-upload the same version (i.e. to correct a mistake) to test.pypi.org (even after logging in to the website and deleting the release).

Testing

Test framework is pytest and tox.

Contributing

Please do.

Metadata

Release files for otk 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for otk 0.1.2
File Size Uploaded
otk-0.1.2.tar.gz 1.5 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for otk 0.1.2
File Interpreter ABI Platform
otk-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 3.7 MB

Release files / otk-0.1.2.tar.gz

Download URL otk-0.1.2.tar.gz
Size 1.5 MB
Tags Source
SHA-256 checksum
How to use checksums
bf5b86301555082e973d1c9223c3e7f26d3d9c49295c3bf829400601481feedb
BLAKE2b-256 checksum
How to use checksums
acacab75ae03afef2222c999a37988d6dca17e6d4e57e099c67a552c5ae54594
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.5 CPython/3.8.0 Darwin/18.7.0

Release files / otk-0.1.2-py3-none-any.whl

Download URL otk-0.1.2-py3-none-any.whl
Size 2.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
179716458ccc1e8a0119c50fb834ff9be50f99bb458026bc4114fa923ac4f3d5
BLAKE2b-256 checksum
How to use checksums
73cdb26c2be5eeb29bad4dc615eaaa8839ee1551ccfe5b602a9d2a21b465fbc7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.5 CPython/3.8.0 Darwin/18.7.0

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page