Metadata-Version: 2.2
Name: refractiveindex2
Version: 0.0.3
Summary: A python interface to the refractiveindex.info database.
Author-email: Martin Schubert <mfschubert@gmail.com>
Maintainer-email: Martin Schubert <mfschubert@gmail.com>
License: MIT License
        
        Copyright (c) 2025 Martin Schubert
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: pyyaml
Requires-Dist: requests
Requires-Dist: types-PyYAML
Requires-Dist: types-requests
Provides-Extra: tests
Requires-Dist: parameterized; extra == "tests"
Requires-Dist: pytest; extra == "tests"
Requires-Dist: pytest-cov; extra == "tests"
Provides-Extra: dev
Requires-Dist: bump-my-version; extra == "dev"
Requires-Dist: darglint; extra == "dev"
Requires-Dist: isort; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Requires-Dist: pre-commit; extra == "dev"

# A python interface to refractiveindex.info
![Continuous integration](https://github.com/mfschubert/refractiveindex2/actions/workflows/build-ci.yml/badge.svg)
![PyPI version](https://img.shields.io/pypi/v/refractiveindex2)

This repo is based on the [refractiveindex repo](https://github.com/toftul/refractiveindex) by [Ivan Toftul](https://github.com/toftul), which itself is based on the `refractiveindex.py` module from the [PyTMM project](https://github.com/kitchenknif/PyTMM) by [Pavel Dmitriev](https://github.com/kitchenknif). It provides a python interface to the [refractiveindex.info database](https://github.com/polyanskiy/refractiveindex.info-database) by [Mikhail Polyanskiy](https://github.com/polyanskiy).

Compared to other interfaces to the database, `refractiveindex2` implements additional formulas required by some materials in the database and is rewritten to have a simpler class structure. It also includes extensive tests for all materials in the database.


## Installation

```
pip install refractiveindex2
```

## Usage


```python
import refractiveindex2 as ri

SiO = ri.RefractiveIndexMaterial(shelf="main", book="SiO", page="Hass")

wavelength_um = 0.6  # [microns]

SiO.get_epsilon(wavelength_um=wavelength_um)
# (3.8633404437869827 + 0.003931076923076923j)

SiO.get_refractive_index(wavelength_um=wavelength_um)
# (1.96553846)

SiO.get_extinction_coefficient(wavelength_um=wavelength_um)
# (0.001)
```

Notes:
- here the time dependence is assumed to be $\mathrm{e}^{-\mathrm{i} \omega t}$, so $\mathrm{Im}(\varepsilon) > 0$ is responsible for the losses.
- if there is a space in the name, one should write underscore instead of it, i.e. not `page='Rodriguez-de Marcos'` but `page='Rodriguez-de_Marcos'`.


## How to get material page names

You can find the proper “page” name by hovering your cursor on the link in the Data section

![How to get page name](docs/img/material_page_names.png)

Or you can look up folders in this repository<br>
https://github.com/polyanskiy/refractiveindex.info-database

## Known issues
For unknown reasons, download of the database can be slow on some systems. You can avoid this by manually downloading the zip file with the `SHA` hard-coded in the `refractiveindex.py` module, e.g.
```
https://github.com/polyanskiy/refractiveindex.info-database/archive/{SHA}.zip
```
which will be a file named
```
refractiveindex.info-database-{SHA}.zip
```
Then, manually add this file to the `src/refractiveindex2/database/{SHA}` directory, creating the directory if needed. This ensures that the automatic download of the database on first module import is avoided.


## Related projects

- https://github.com/stillyslalom/RefractiveIndex.jl
- https://github.com/kitchenknif/PyTMM
- https://github.com/toftul/refractiveindex
- https://github.com/polyanskiy/refractiveindex.info-database
