PyOptik is a powerful Python tool designed to import refractive indexes and extinction coefficients for various materials across different wavelengths. The data provided by PyOptik can be used in numerous applications, including simulating light interactions with particles. All data is sourced from the reputable RefractiveIndex.INFO database.
- Comprehensive Database Access: Seamlessly import refractive index and extinction coefficient data for a wide range of materials.
- Simulation Ready: Ideal for light-matter interaction simulations, particularly in optics and photonics.
- Simple API: Easy-to-use API that integrates well with other Python libraries.
- Open Source: Fully open-source.
To install PyOptik, simply use pip:
pip install pyoptik
After installing PyOptik, you can easily access material properties:
from PyOptik import Material
# Access the refractive index of BK7 glass
bk7 = Material.BK7
n = bk7.compute_refractive_index(0.55e-6)
print(f"Refractive index at 0.55 µm: {n}")
Here is a quick example demonstrating how to use PyOptik to retrieve and plot the refractive index of a material:
import numpy as np
from PyOptik import Material
# Define wavelength range
wavelengths = np.linspace(0.3e-6, 2.5e-6, 100)
# Retrieve refractive index for BK7 glass
bk7 = Material.BK7
n_values = bk7.compute_refractive_index(wavelengths)
# Plot the results
bk7.plot()
This code produces the following figure:
You can also add a custom element to your library providing a URL from refractiveindex.info website.
from PyOptik.utils import download_yml_file
from PyOptik.directories import sellmeier_data_path # or tabulated_data_path for tabulated elements
download_yml_file(
filename='test',
url='https://refractiveindex.info/database/data-nk/main/H2O/Daimon-19.0C.yml',
location=tabulated_data_path
)
Evidently, you can also remove element from the library using as follows:
from PyOptik.utils import remove_element
remove_element(filename='test', location='any') # location can be "any", "sellmeier" or "tabulated"
To test locally after cloning the GitHub repository, install the dependencies and run the tests:
git clone https://github.com/MartinPdeS/PyOptik.git
cd PyOptik
pip install .
pytest
PyOptik is open to contributions. Whether you're fixing bugs, adding new features, or improving documentation, your help is welcome! Please feel free to fork the repository and submit pull requests.
As of 2024, PyOptik is still under development. If you would like to collaborate, it would be a pleasure to hear from you. Contact me at:
Author: Martin Poinsinet de Sivry-Houle