Metadata-Version: 2.4
Name: refidx2se
Version: 0.1.1
Summary: Lightweight interface to the refractiveindex.info database with refellips support
Author-email: Aiden Gauer <aiden.gauer@stonybrook.edu>
License: MIT
Project-URL: Homepage, https://github.com/agauer/refidx2se
Project-URL: Bug Tracker, https://github.com/agauer/refidx2se/issues
Keywords: ellipsometry,refractive-index,data-analysis,thin-films
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Physics
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.24
Requires-Dist: pandas>=2.2
Requires-Dist: requests>=2.28
Requires-Dist: pyyaml>=6.0
Requires-Dist: refractiveindex>=0.2
Requires-Dist: refellips>=0.0.6
Requires-Dist: refnx>=0.1.60
Provides-Extra: dev
Requires-Dist: pytest>=7.4; extra == "dev"
Requires-Dist: pytest-cov>=4.1; extra == "dev"
Requires-Dist: responses>=0.24; extra == "dev"
Requires-Dist: ruff>=0.4; extra == "dev"
Requires-Dist: mypy>=1.8; extra == "dev"
Dynamic: license-file

# refidx2se

[![CI](https://github.com/agauer/refidx2se/actions/workflows/ci.yml/badge.svg)](https://github.com/agauer/refidx2se/actions)
[![PyPI](https://img.shields.io/pypi/v/refidx2se)](https://pypi.org/project/refidx2se/)
[![Python](https://img.shields.io/pypi/pyversions/refidx2se)](https://pypi.org/project/refidx2se/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)

A lightweight Python interface to the [refractiveindex.info](https://refractiveindex.info) database, with built-in conversion to [`refellips`](https://github.com/refnx/refellips) `RI` objects for spectroscopic ellipsometry workflows.

## Features

- **Search** the full refractiveindex.info catalog by material name (case-insensitive, partial matching).
- **Load** any material entry directly into a `refellips.RI` object — no manual file management.
- Wavelength ranges are **automatically clipped** to the material's valid range.
- Catalog fetched from GitHub and **cached in-process** — only one network request per session.

## Installation

```bash
pip install refidx2se
```

Or from source:

```bash
git clone https://github.com/agauer/refidx2se.git
cd refidx2se
pip install -e ".[dev]"
```

## Quick start

```python
import numpy as np
import refidx2se
from refellips.reflect_modelSE import ReflectModelSE
from refellips.dispersion import RI, load_material

# 1. Explore available entries
refidx2se.print_material_options("SiO2")
# 4 entries matching 'SiO2':
#   option   shelf        book                      page                                description
#   -------- ------------ ------------------------- ----------------------------------- ---------------------------------------------
#   0        main         SiO2                      Malitson                            Malitson 1965: n 0.21–6.7 µm
#   1        main         SiO2                      ...

# 2. Pick one by index
shelf, book, page = refidx2se.return_material_option("SiO2", idx=0)

# 3. Load into refellips
wavelengths = np.linspace(400, 900, 200)   # nm
ri = refidx2se.rim_to_refellips(shelf, book, page, wavelengths)

# 4. Create a model
si = load_material("silicon")
air = RI("/path/to/refellips/materials/air.csv")

est_thickness = 20  # Å
min_thickness = 1
max_thickness = 50

sio2 = ri(est_thickness)
sio2.thick.setp(vary=True, bounds=(min_thickness, max_thickness))

stack = air() | sio2 | si()
model = ReflectModelSE(stack)

# 5. Continue with refellips analysis
```

## API reference

### `search_material(book: str) -> list[dict]`

Returns all catalog entries whose book name contains `book` (case-insensitive).
Each dict has keys `shelf`, `book`, `page`, `name`.

### `return_material_option(book: str, idx: int = 0) -> tuple[str, str, str]`

Returns `(shelf, book, page)` for the *idx*-th match. Raises `ValueError` if
no matches exist or `idx` is out of range.

### `print_material_options(book: str) -> None`

Pretty-prints a numbered table of all matches — handy for interactive use.

### `rim_to_refellips(shelf, book, page, wavelengths_nm) -> refellips.RI`

Fetches the material from refractiveindex.info, clips the requested wavelength
array to the material's valid range, and returns a `refellips.RI` object.
Missing *k* data is silently replaced with zeros.

## License

MIT — see [LICENSE](LICENSE).
