Python interface to refractiveindex.info that ships the database
Project description
indicio
indicio is a python package that provides offline access to the
refractiveindex.info database of optical
constants. Contrary to other similar packages, the full upstream database ships
inside the package, so there is no need to download it separately: just pip install indicio and you are ready to go.
indicio has zero runtime dependency, not even YAML because the database is
stored internally in a custom sqlite format that python can decode natively.
This also reduces the size of the database to ~16MB.
The API returns structured descriptions of dispersion models. It does
not implement formulas to compute n(λ) or k(λ). That job is left to the
consumer, who can pick whatever numerical stack suits the use case (numpy, jax,
torch, etc.).
indicio exists primarily for integration in Torch Lens
Maker, but you are welcome to
use it for anything else!
Installation
pip install indicio
Quickstart
import indicio
SiO2 = indicio.get_material("main", "SiO2", "Malitson")
print(SiO2.n)
>>> Sellmeier(c1=0.0, coefficients=((0.6961662769317627, 0.06840430200099945), (0.40794259309768677, 0.11624140292406082), (0.8974794149398804, 9.896161079406738)), wavelength_range=(0.21, 6.7))
API
indicio.get_material(shelf: str, book: str, page: str) -> MaterialEntry
indicio.has_material(shelf: str, book: str, page: str) -> bool
indicio.shelves() -> tuple[str, ...]
indicio.books(shelf: str) -> tuple[str, ...]
indicio.pages(shelf: str, book: str) -> tuple[str, ...]
indicio.iter_materials() -> Iterator[MaterialEntry]
indicio.search(query: str) -> tuple[tuple[str, str, str], ...]
indicio.__version__ # library version, e.g. "1.0.0"
indicio.__database_version__ # upstream commit hash baked into the data
The data model
@dataclass(frozen=True)
class MaterialEntry:
shelf: str
book: str
page: str
name: str | None
references: str | None
comments: str | None
n: NModel | None # real part — None if upstream has only k
k: KModel | None # imaginary part — None if upstream has only n
-
For the dispersion model n, there are 10 possible cases: 9 closed-form formulas (following the upstream dispersion-formula doc), or tabulated data.
-
For the extinction coefficient k, the data is always tabulated.
For detailed data description of each model see src/indicio/models.py.
Examples
The examples/ directory contains complete evaluation scripts covering every
formula type:
examples/example_evaluation_stdlib.py: uses only the standard library (math,array,bisect).examples/example_evaluation_numpy.py: uses numpy; evaluators are vectorized over a wavelength array.examples/example_plot.py: uses numpy + matplotlib to plot n(λ) and k(λ) over the validity range.
python examples/example_evaluation_stdlib.py main SiO2 Malitson
python examples/example_evaluation_numpy.py main Au Johnson
python examples/example_plot.py main BaF2 Bosomworth-300K
Conventions
- Wavelengths are micrometers everywhere, matching the convention of refractiveindex.info.
- Tabulated arrays are raw bytes, packed as little-endian IEEE 754 float32. See examples above for decoding.
Licensing and attribution
The refractiveindex.info database is distributed under CC0
1.0 (public domain). When
publishing results that rely on a particular material entry, please cite the
original authors. Their citation strings are preserved verbatim in
MaterialEntry.references.
print(indicio.get_material("main", "SiO2", "Malitson").references)
The indicio library code itself is distributed under its own LICENSE in
the source tree.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file indicio-1.0.1.tar.gz.
File metadata
- Download URL: indicio-1.0.1.tar.gz
- Upload date:
- Size: 13.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
700b9cf1996b33122f6613de14b8114297f6bf978c85fdd43ba5061174105798
|
|
| MD5 |
9b98837ed0cd1690cc128ef68ec9f6a9
|
|
| BLAKE2b-256 |
8af5ad7c7e7b66dffefeea138d6cae66864ad5d9e45073246403ba4019416224
|
File details
Details for the file indicio-1.0.1-py3-none-any.whl.
File metadata
- Download URL: indicio-1.0.1-py3-none-any.whl
- Upload date:
- Size: 13.0 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"43","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
845a317cb0aa0c2086abdcc4f6e475496cab19b950ac7c9a81dd6aa8d38c8d1f
|
|
| MD5 |
84ad67393f989369095343a08ce2f43c
|
|
| BLAKE2b-256 |
138a6e7eb9d8fcbcbe4c1146f18dc15d60f150887dd3798f896246edbb94ed01
|