PyIndexRepo
This package gives access to the refractive index data from RefractiveIndex.info.
The focus of this package is to provide a convenient interface to the data, and be efficient in the calculation of (temperature-dependent) refractive indices. Internally, the YAML data are converted to Python objects, for convenient access. Numba is used to speed up recursive calculations.
Usage
Basics
There are multiple ways to access the data. The most basic way is to use the RefractiveIndexLibrary class:
from pyindexrepo import RefractiveIndexLibrary
db = RefractiveIndexLibrary(auto_upgrade=True)
bk7 = db.search_material_by_page_name('N-BK7')[0] # returns a list of different BK7 glasses
print(bk7.get_n(0.5875618))
When executed for the first time, the database from the RefractiveIndex Github Repo will be downloaded and converted to a python object. This process takes a few minutes. Consecutive calls will load the database object from a local file (almost instantaneously).
Auto-upgrade of the library is supported, but switched off by default.
The search function will return a list of materials, as there are multiple materials with the same name. You can also select the material by 'shelf', 'book' and 'page' as specified in the RefractiveIndex.info database.
from pyindexrepo import RefractiveIndexLibrary
db = RefractiveIndexLibrary(auto_upgrade=True)
bk7 = db.get_material('specs', 'schott', 'N-BK7')
print(bk7.get_n(0.5875618))
For further information how to interact with the data, please refer to the documentation.
In particular, check the API of the RefractiveIndexLibrary class and the Material class.
Temperature data
When temperature data is available, the refractive index of a material can be queried at any temperature within the valid temperature range:
import numpy as np
from pyindexrepo import RefractiveIndexLibrary
db = RefractiveIndexLibrary(auto_upgrade=True)
bk7 = db.search_material_by_page_name('N-BK7')[0] # returns a list of different BK7 glasses
wl = np.linspace(0.4, 0.7, 10000)
print(bk7.get_n_at_temperature(wl, temperature=30))
[1.53088657 1.53088257 1.53087857 ... 1.51309187 1.51309107 1.51309027]
Installation
pip install pyindexrepo
Metadata
Release files for PyIndexRepo 0.1.16
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyindexrepo-0.1.16.tar.gz | 16.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyindexrepo-0.1.16-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.8 kB
Release files / pyindexrepo-0.1.16.tar.gz
| Download URL | pyindexrepo-0.1.16.tar.gz |
|---|---|
| Size | 16.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e53e09ef3f007ac32da879b093830311050604f54686622365574a0b11302c70
|
|
BLAKE2b-256 checksum How to use checksums |
7a5b7852b2376aca5c03274c5aa1140b277855d4fed1a08bbceb798c06a272c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 13, 2025.
Transparency logRelease files / pyindexrepo-0.1.16-py3-none-any.whl
| Download URL | pyindexrepo-0.1.16-py3-none-any.whl |
|---|---|
| Size | 16.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1178a5ba0dbbcac73d1f4f5b165bfef37000e992d86ea1cadc0241caf35437ef
|
|
BLAKE2b-256 checksum How to use checksums |
47e109ed0fb6dadb440934a74355161347c857ebaa078674e70ac207a803ac6a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 13, 2025.
Transparency log