Skip to content

Repository files navigation

Python interface to RefractiveIndex database

Tests DOI

Python interface to the refractiveindex.info database. The database (~15 MB) is bundled. Install with

pip install refractiveindex

Usage

import refractiveindex as ri

# load a material by shelf, book and page
SiO = ri.RefractiveIndexMaterial(shelf='main', book='SiO', page='Hass')
# or from the address-bar URL of a refractiveindex.info page
SiO2 = ri.RefractiveIndexMaterial.from_url(
    'https://refractiveindex.info/?shelf=main&book=SiO2&page=Malitson'
)

# find names, best match first
ri.search('SiO2')
#  0  main/SiO2/Malitson                       Malitson 1965: n 0.21–6.7 µm [Fused silica]
#  1  main/SiO2/Nyakuchena                     Nyakuchena et al. 2023: n 1.10–1.65 µm [Fused silica]
#  ...
# only pages with k data that covers 1550 nm
ri.search('SiO2', quantity='k', wavelength=1550)
SiO2 = ri.search('SiO2')[0].material()

# wavelength in nm by default
SiO.get_refractive_index(600)        # 1.9655

# unit= accepts 'nm', 'um', 'mm', 'm', 'A', 'cm-1', 'THz', 'eV'; arrays work too
SiO.get_extinction_coefficient([0.6, 0.7], unit='um')  # array([0.001, 0.00075])

# permittivity for exp(-iωt) (default) or exp(+iωt) time dependence
SiO.get_epsilon(600)                        # (3.8633+0.0039j)
SiO.get_epsilon(600, exp_type='exp(+iwt)')  # (3.8633-0.0039j)

# valid wavelength range
SiO.get_wl_range(unit='nm')          # (240.0, 14000.0)

Documentation

See DOCUMENTATION.md for unit conversions, separate n and k ranges, values outside the range, and other copies of the database.

How to cite

If you use this package in published work, please cite the database paper and this package, and state the database version.

Database:

Polyanskiy, M. N. Refractiveindex.info database of optical constants.
Scientific Data 11, 94 (2024).
https://doi.org/10.1038/s41597-023-02898-2

BibTeX:

@article{polyanskiy2024,
  title   = {Refractiveindex.info database of optical constants},
  author  = {Polyanskiy, Mikhail N.},
  journal = {Scientific Data},
  volume  = {11},
  pages   = {94},
  year    = {2024},
  doi     = {10.1038/s41597-023-02898-2}
}

This package:

Toftul, I. and refractiveindex contributors. refractiveindex: Python interface to the refractiveindex.info database.
Zenodo. https://doi.org/10.5281/zenodo.23682585

@software{toftul_refractiveindex,
  author = {Toftul, Ivan and {refractiveindex contributors}},
  title  = {refractiveindex: Python interface to the refractiveindex.info database},
  doi    = {10.5281/zenodo.23682585},
  url    = {https://github.com/toftul/refractiveindex}
}

For reproducibility, add the package version and the database version. The database is CC0.

from importlib.metadata import version
print(version('refractiveindex'))
print(ri.DATABASE_VERSION)
print(ri.DATABASE_COMMIT)

See also

Releases

Packages

Used by

Contributors

Languages