Badge |
Status |
|---|---|
Python versions |
|
Documentation |
|
Continuous integration |
|
Test coverage |
|
PyPI package |
|
PyPI downloads |
|
Anaconda package |
|
Anaconda downloads |
PyOptik
Optical materials and thin films, from data to calculation. PyOptik is an open-source Python package for wavelength-dependent optical constants, dispersion, Fresnel interfaces, and coherent thin-film stacks. It brings the RefractiveIndex.INFO database into unit-aware Python workflows while preserving the source of each dataset.
Features
Find materials by name or select a specific catalog source.
Evaluate dispersion formulas and tabulated complex refractive indices.
Calculate group index, group delay, and group-delay dispersion.
Model Fresnel interfaces and coherent, isotropic multilayer films.
Import, validate, and export custom material data.
Work with scalar or NumPy array wavelengths and physical units.
See PyOptik in action
Design an antireflection coating
Compare the reflectance of bare glass with an ideal quarter-wave coating. The example uses lossless, constant refractive indices at normal incidence; the coating minimizes reflection at its 550 nm design wavelength. Explore the coating tutorial.
Explore dispersion in fused silica
Compare phase and group index and calculate group-delay dispersion through 1 mm of glass using the Malitson model. See the silica dispersion tutorial.
Inspect measured optical constants
Plot the refractive index and extinction coefficient of gold from the Johnson and Christy dataset. See the gold optical constants tutorial.
Installation
Install from PyPI or Anaconda:
python -m pip install PyOptik
# Or: conda install -c martinpdes pyoptik
Verify the installation with python -c "import PyOptik; print(PyOptik.__version__)". Material data is downloaded on first lookup and cached locally. To initialize the complete snapshot in advance, run pyoptik setup.
First calculation
Load a material by name and evaluate its refractive index at a wavelength with units:
from PyOptik import material
from TypedUnit import ureg
bk7 = material("N-BK7")
print(bk7.n(532 * ureg.nanometer))
print(bk7.catalog_id) # specs/SCHOTT-optical/N-BK7
bk7.plot()
The first lookup needs an internet connection. The catalog preserves source identity: use material("main/Au/Johnson") to select a specific dataset, or find_materials("gold") to explore candidates. See the materials guide for defaults, source selection, and provenance.
Interfaces and thin films
An ideal coating can also be calculated without downloading material data:
import numpy as np
from PyOptik import ThinFilmLayer, thin_film_stack
from TypedUnit import ureg
wavelengths = np.linspace(350, 900, 600) * ureg.nanometer
coating_index = np.sqrt(1.52)
coating = ThinFilmLayer(coating_index, 550 * ureg.nanometer / (4 * coating_index))
result = thin_film_stack(wavelengths, [coating], substrate_index=1.52)
print(result.reflectance)
The stack model assumes coherent, isotropic layers; it does not model surface roughness, anisotropy, or incoherent thick substrates. See the interfaces and thin films guide.
Documentation
Wavelengths should carry units; bare numeric wavelengths are interpreted as metres for backward compatibility. Material data has a source-specific validity range; use out_of_range="raise" when extrapolation is unsuitable. See the physical conventions for the complex-index and dispersion conventions.
Citing PyOptik
If you use PyOptik in research, please cite the software using the metadata in CITATION.cff. Also cite the RefractiveIndex.INFO database and the original sources for the material datasets used in your work; source details are available through catalog_id and provenance.
Development and contributions
git clone https://github.com/MartinPdeS/PyOptik.git
cd PyOptik
python -m pip install -e ".[testing,documentation,dev]"
MPLBACKEND=Agg pytest -m "not network"
MPLBACKEND=Agg sphinx-build -b html -W docs/source docs/build/html
See CONTRIBUTING.md for contribution guidance. PyOptik is distributed under the MIT license.
Metadata
Release files for PyOptik 3.5.17
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyoptik-3.5.17.tar.gz | 53.1 kB | Without provenance | Details for pyoptik-3.5.17.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyoptik-3.5.17-py3-none-any.whl | Python 3 | none | any | Details for pyoptik-3.5.17-py3-none-any.whl |
Total release size: 97.9 kB
Release files / pyoptik-3.5.17.tar.gz
| Download URL | pyoptik-3.5.17.tar.gz |
|---|---|
| Size | 53.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1e8370485074f046bd224fa58a084bcc48b456c504e97fb7015688dfe5eac2d8
|
|
BLAKE2b-256 checksum How to use checksums |
e03dcc4009ecc9c089e39ddc258b70712ddaf1c49d09497611b5d75c7deab05d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.18
|
Release files / pyoptik-3.5.17-py3-none-any.whl
| Download URL | pyoptik-3.5.17-py3-none-any.whl |
|---|---|
| Size | 44.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
53da69748f9b1a28dc763a70f0a6472c974aa1a6235e840f4d988716dee2e001
|
|
BLAKE2b-256 checksum How to use checksums |
311b6bd4d0967551c5fa11f9a3c618707ab64ac2ad48a51582444690fb392efc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.18
|
Security for PyOptik 3.5.17
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.