Skip to main content

Python interface for various refractive index databases

Project description

RefIdxDB-Logo

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.

[!note] If your source is not implemented, feel free to open an issue! You can also try to implement it yourself. You can take refidx and aria as a reference on what needs to be implemented.

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 downlaoded!
Bye :)

$ # Replace table with plot to diplay 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 │
└───────────┴──────────┴──────────┘

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.

[!warning] Only wavelengths are currently supported, since they are my main use-case. If you have a proposal on how to add wave number support, please submit an issue/PR.

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_nk

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:

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

refidxdb-0.0.2.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

refidxdb-0.0.2-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file refidxdb-0.0.2.tar.gz.

File metadata

  • Download URL: refidxdb-0.0.2.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for refidxdb-0.0.2.tar.gz
Algorithm Hash digest
SHA256 ff12961119682e2a4f37031308656012bb9f92f5927945d3d7748cc9b731adca
MD5 af91c4d6afa8132e7f3650f88b63f5ed
BLAKE2b-256 7fc4b3eea60c8a40d2c441f917789a53c74924b398a4d7a4e60d498ab9059eb7

See more details on using hashes here.

Provenance

The following attestation bundles were made for refidxdb-0.0.2.tar.gz:

Publisher: pypi.yml on arunoruto/RefIdxDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file refidxdb-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: refidxdb-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for refidxdb-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4e29abae0b912c95b89f1152b892f71dcd5ccd5b2aeec4f01007103074b08011
MD5 488819ac8dad6c153862eb7198f46632
BLAKE2b-256 d8fd601a7768dd1da7ebec52b2d184dd92bf6bc398a8aa4b8e442bc1f03339e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for refidxdb-0.0.2-py3-none-any.whl:

Publisher: pypi.yml on arunoruto/RefIdxDB

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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