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.
Usage
Basics
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.
There are two main classes that allow interacting with the data: 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
File details
Details for the file pyindexrepo-0.1.0.tar.gz
.
File metadata
- Download URL: pyindexrepo-0.1.0.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.10.13 Linux/5.15.0-125-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d0c1f847df2f9d6e8ee5ebdb254760756c72b7ffa666bd1766cd92e12484202 |
|
MD5 | af0eef291b635af24ebfc37d7cc8ffd7 |
|
BLAKE2b-256 | c279a769c028e63e92e3a00969dae31d86e3ece0dadce7129c927b253cdbf776 |
File details
Details for the file pyindexrepo-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: pyindexrepo-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.10.13 Linux/5.15.0-125-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c593d17e0118d865be09cae170de0403f65f82c7339a3953aec5621a54177555 |
|
MD5 | 997328e1273809cf155653b21698bf16 |
|
BLAKE2b-256 | 0e347930aeba298c1a8fd8c3c8596c676fce16ecac2bd74a338c6ff051643671 |