Skip to main content

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:

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

indicio-1.0.0.tar.gz (13.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

indicio-1.0.0-py3-none-any.whl (13.0 MB view details)

Uploaded Python 3

File details

Details for the file indicio-1.0.0.tar.gz.

File metadata

  • Download URL: indicio-1.0.0.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

Hashes for indicio-1.0.0.tar.gz
Algorithm Hash digest
SHA256 54dd08b428b65848b47fb551b84b001d34d0267a39c44a57422e2e16261154cd
MD5 a0fb3312450aef60a9755dde027a29f7
BLAKE2b-256 33b02b87ba9974c947a2a183a8430756634f1d733f5e32feda457a981faf3f3e

See more details on using hashes here.

File details

Details for the file indicio-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: indicio-1.0.0-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

Hashes for indicio-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a357f13c6948f4dcd086215c81b55da606fefff5e13e53836677e2fe1585cf69
MD5 486f5f6f445e68b78bb559cbaef3d283
BLAKE2b-256 5eacd924f9f4fb8f18cab6f169f960d5c9cec0366b799b96307f475f16fd9168

See more details on using hashes here.

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