RefIdxDB
Python interface for various refractive index databases
I was tired to download files from here and there, parse them each manually and locally. Hence, I copied most of my parsing code into this project, so it can be developed further.
Installation
refidxdb can be downloaded from PiPy.org:
pip install refidxdb
After the pip command, the refidxdb command should be available.
CLI
The main purpose of the CLI is to download and cache the databases locally and interact with it.
The data will be downloaded to $HOME/.cache/refidxdb under a folder corresponding to the class name.
Please use refidxdb --help to explore the functionality.
Example:
$ # Download all databases
$ # equivalent to refidxdb db --download aria,refidx
$ refidxdb db --download all
Downloading the database for RefIdx from https://github.com/polyanskiy/refractiveindex.info-database/releases/download/v2024-08-14/rii-database-2024-08-14.zip to /home/mar/.cache/refidxdb/RefIdx
Downloading the database for Aria from https://eodg.atm.ox.ac.uk/ARIA/data_files/ARIA.zip to /home/mar/.cache/refidxdb/Aria
All databases downloaded!
Bye :)
$ # Replace table with plot to display a graph of the data in the terminal
$ refidxdb show --db aria --data "data_files/Minerals/Olivine/z_orientation_(Fabian_et_al._2001)/olivine_Z_Fabian_2001.ri" --display table --bounds 2.5,15.5
shape: (2_748, 3)
┌───────────┬──────────┬──────────┐
│ w ┆ n ┆ k │
│ --- ┆ --- ┆ --- │
│ f64 ┆ f64 ┆ f64 │
╞═══════════╪══════════╪══════════╡
│ 2.500617 ┆ 1.619696 ┆ 0.000053 │
│ 2.501381 ┆ 1.619685 ┆ 0.000053 │
│ 2.502144 ┆ 1.619674 ┆ 0.000053 │
│ 2.502909 ┆ 1.619663 ┆ 0.000053 │
│ 2.503674 ┆ 1.619652 ┆ 0.000053 │
│ … ┆ … ┆ … │
│ 15.369648 ┆ 1.42662 ┆ 0.036282 │
│ 15.398545 ┆ 1.419686 ┆ 0.036761 │
│ 15.427528 ┆ 1.412672 ┆ 0.037256 │
│ 15.456643 ┆ 1.405576 ┆ 0.037768 │
│ 15.485869 ┆ 1.398394 ┆ 0.038299 │
└───────────┴──────────┴──────────┘
$ # Explore the databases using streamlit
$ refidxdb explore
/home/user/Projects/refidxdb/refidxdb
You can now view your Streamlit app in your browser.
Local URL: http://localhost:8501
Network URL: http://10.42.42.212:8501
API
RefIdxDB: is the main blueprint class from which all the specific parser classes need to inherit.
This yields a unified API, i.e., all the instances have the same methods available.
path: is the path leading to the wanted file relative to the database.
This value can be usually copied from the URL.
data: represents the raw data obtained from the file found under path.
nk: are the parsed real and imaginary parts of the refractive index.
The main column is always the wavelength, i.e., wave numbers will always be transformed into wavelengths.
interpolate: you rarely want to use the tables as is, therefore an interpolation method is implemented
to calculate n and k for a target wavelength.
Supported DBs
refractiveindex.info
refractiveindex.info mainly differentiates between raw data with wavelengths in micrometers,
or polynomial functions which hold for a certain range. The raw data is contained in YAML files,
with each data type being referenced.
Currently, supported data types are:
tabulated_nktabulated_ntabulated_kformula 1formula 2formula 3
ARIA - Aerosol Refractive Index Archive
Aria consists of ri files, which are whitespace separated values.
The header is prefixed by a hashtag #. The FORMAT value gives information about the column labels.
Both wavelengths WAVL and wave numbers WAVN will be read correctly and transformed into wavelengths
with no SI prefix (meters [m]). The default scales for wavelengths and wave numbers are 1e-6 (micrometers)
and 1e2 (centimeters^-1).
Similar projects
RefIdxDB is, to the best of my knowledge, the only project that tries to unify multiple databases under one API. Nevertheless, there are projects that have tried to achieve the same for a single database:
- refractiveindex
- PyTMM - the API is implemented in refractiveindex.py
- PyOptik
TODO
- Aria has sometimes spaces or URL encoded characters.
Those need to be decoded using
urllib.parse.unquote. - Fix for
refidx:data-nk/other/commercial polymers/CR-39/mono.yml
Metadata
Release files for refidxdb 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| refidxdb-1.0.0.tar.gz | 12.8 kB | Without provenance | Details for refidxdb-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| refidxdb-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for refidxdb-1.0.0-py3-none-any.whl |
Total release size: 30.3 kB
Release files / refidxdb-1.0.0.tar.gz
| Download URL | refidxdb-1.0.0.tar.gz |
|---|---|
| Size | 12.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
da088b827f8def23cf997a1454902e5d2bdb36a74fe939acb5f13b841d59b1b7
|
|
BLAKE2b-256 checksum How to use checksums |
e97860a2daa7cb2d5b25749d09ba29227142cf42c9d707fa26466954f6c92af2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / refidxdb-1.0.0-py3-none-any.whl
| Download URL | refidxdb-1.0.0-py3-none-any.whl |
|---|---|
| Size | 17.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
037fab2834acd2b988c993ee278e912edded1a721b38ec9d6bff61e2533b88aa
|
|
BLAKE2b-256 checksum How to use checksums |
232f18304a79417296009f04e0aa91c240ec33d199b7d8a8fa86d33aeca8a2a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for refidxdb 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.