| Badge | Status |
|---|---|
| Python versions | |
| Documentation | |
| Continuous integration | |
| Test coverage | |
| PyPI package | |
| PyPI downloads | |
| Anaconda package | |
| Anaconda downloads |
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.
- 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.
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.
Install from PyPI or Anaconda:
python -m pip install PyOptik
# Or: conda install -c martinpdes pyoptikVerify 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.
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.
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.
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.
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.
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/htmlSee CONTRIBUTING.md for contribution guidance. PyOptik is distributed under the MIT license.



