Python interface for data on refractiveindex.info
Project description
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
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 pyindexrepo-0.1.16.tar.gz.
File metadata
- Download URL: pyindexrepo-0.1.16.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e53e09ef3f007ac32da879b093830311050604f54686622365574a0b11302c70
|
|
| MD5 |
ca0495c00fa036898fb1493bca54ba9c
|
|
| BLAKE2b-256 |
7a5b7852b2376aca5c03274c5aa1140b277855d4fed1a08bbceb798c06a272c4
|
Provenance
The following attestation bundles were made for pyindexrepo-0.1.16.tar.gz:
Publisher:
release.yaml on Stuermer/PyIndexRepo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyindexrepo-0.1.16.tar.gz -
Subject digest:
e53e09ef3f007ac32da879b093830311050604f54686622365574a0b11302c70 - Sigstore transparency entry: 196099780
- Sigstore integration time:
-
Permalink:
Stuermer/PyIndexRepo@c2443ed4e4f0a78ca793a838fb4d499c95ad9117 -
Branch / Tag:
refs/tags/0.1.16 - Owner: https://github.com/Stuermer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@c2443ed4e4f0a78ca793a838fb4d499c95ad9117 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyindexrepo-0.1.16-py3-none-any.whl.
File metadata
- Download URL: pyindexrepo-0.1.16-py3-none-any.whl
- Upload date:
- Size: 16.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1178a5ba0dbbcac73d1f4f5b165bfef37000e992d86ea1cadc0241caf35437ef
|
|
| MD5 |
88a98a98efec6f6e149e5d6fe6428b08
|
|
| BLAKE2b-256 |
47e109ed0fb6dadb440934a74355161347c857ebaa078674e70ac207a803ac6a
|
Provenance
The following attestation bundles were made for pyindexrepo-0.1.16-py3-none-any.whl:
Publisher:
release.yaml on Stuermer/PyIndexRepo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyindexrepo-0.1.16-py3-none-any.whl -
Subject digest:
1178a5ba0dbbcac73d1f4f5b165bfef37000e992d86ea1cadc0241caf35437ef - Sigstore transparency entry: 196099781
- Sigstore integration time:
-
Permalink:
Stuermer/PyIndexRepo@c2443ed4e4f0a78ca793a838fb4d499c95ad9117 -
Branch / Tag:
refs/tags/0.1.16 - Owner: https://github.com/Stuermer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@c2443ed4e4f0a78ca793a838fb4d499c95ad9117 -
Trigger Event:
push
-
Statement type: