Skip to main content

A package for refractive index values.

Project description

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.

Logo

Testing

Unittest Status

Unittest coverage

Package

PyPi

PyPi_download

anaconda

Meta

python

Documentation Status

Features

  • 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.

Installation

To install PyOptik, simply use pip or conda:

pip install PyOptik
conda install --channels martinpdes pyoptik

Simple Usage

After installing PyOptik, you can easily access material properties:

from PyOptik import MaterialBank

# Access the refractive index of BK7 glass
bk7 = MaterialBank.BK7
n = bk7.compute_refractive_index(0.55e-6)
print(f"Refractive index at 0.55 µm: {n}")

Example

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 MaterialBank

# Define wavelength range
wavelengths = np.linspace(0.3e-6, 2.5e-6, 100)

# Retrieve refractive index for BK7 glass
bk7 = MaterialBank.BK7
n_values = bk7.compute_refractive_index(wavelengths)

# Plot the results
bk7.plot()

This code produces the following figure: example_bk7

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"

Testing

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

Contributing

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.

Contact Information

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

Email: martin.poinsinet.de.sivry@gmail.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyoptik-1.7.3.post0.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

PyOptik-1.7.3.post0-py3-none-any.whl (43.5 kB view details)

Uploaded Python 3

File details

Details for the file pyoptik-1.7.3.post0.tar.gz.

File metadata

  • Download URL: pyoptik-1.7.3.post0.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for pyoptik-1.7.3.post0.tar.gz
Algorithm Hash digest
SHA256 15986d27e0653fb2e868bfc45e0e5f12876f5d4f21c97825753c0ed0c02549e7
MD5 f75f1e06adabe9a1f0f9a180b25516e7
BLAKE2b-256 ad6f270b158d6758a736c8ee8d60c3fe7ce75548d684d43b075355195b513cd2

See more details on using hashes here.

File details

Details for the file PyOptik-1.7.3.post0-py3-none-any.whl.

File metadata

File hashes

Hashes for PyOptik-1.7.3.post0-py3-none-any.whl
Algorithm Hash digest
SHA256 7a907a8868b95e217ae7a5297aa576147fc82fb4664d7d6efaf41b6f4c83d534
MD5 66634616ec6e9986ebbe7615df22552d
BLAKE2b-256 cc9bc8e80015c687d8e5f27459f7de597add0e28dbfd8a4004af87f2bf1c172f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page