GithubHelp home page GithubHelp logo

mnishida / rii_pandas Goto Github PK

View Code? Open in Web Editor NEW
8.0 4.0 1.0 70 MB

Python 3 + Pandas wrapper for the refractiveindex.info database by Mikhail Polyanskiy.

License: MIT License

Python 90.76% Makefile 1.03% Cython 8.21%
pandas python

rii_pandas's Introduction

RII_Pandas (refractiveindex.info-pandas)

PyPI version Anaconda Version Lint and Test

Python 3 + Pandas wrapper for the refractiveindex.info database developed by Mikhail Polyanskiy.

Pandas DataFrame creation was made with modified versions of dboperations.py from refractiveindex.info-sqlite package developed by Hugo Guillén.

Features

  • Create Pandas DataFrame by parsing database files cloned from Polyanskiy's GitHub repository.
  • Drude-Lorentz model (formula 21) and Brendel-Bormann model (formula 22) are available to describe metallic dielectric function.

Install

Install and update using pip

$ pip install -U riip

Install using conda

$ conda install -c mnishida riip

Usage

>>> import riip
>>> ri = riip.RiiDataFrame()

Polyanskiy's 'refractiveindex.info database' is cloned from GitHub repository, and three csv files, 'catalog.csv', 'raw_data.csv' and 'grid_data.csv' are created. They are located in 'data' folder under the installation directory. This process may take a few minutes, but it will happen only the first time you start it after installation.

>>> ri.search("Al")                      # search material contains the string
>>> ri.select(
      "2.5 < n < 3 and 0.4 < wl < 0.8"
    )                                    # select materials that fullfill the condition
>>> print(ri.show([23, 118]))            # show catalog
>>> print(ri.read(23))                   # read the data book
>>> ri.references(23)                    # see references
>>> ri.plot(23, "n")                     # plot wavelength dependence of refractive index

>>> Al = ri.material(
  {"book": "Al", "page": "Mathewson"})   # create material with book and page
>>> Al = ri.material({"id": 23})         # create material with id number

It may not be safe to use "id" in your application importing this package. The id number may be changed when an update is done on your local database.

>>> import numpy as np
>>> wls = np.linspace(0.5, 1.6)          # wavelength from 0.5 μm to 1.6 μm
>>> Al.n(wls)                            # refractive index
>>> Al.k(wls)                            # extinction coefficient
>>> Al.eps(wls)                          # complex permittivity

For more information, see RII_Pandas User's Guide.

Update database

If refractiveindex.info database is updated, you can pull it to the local database by

>>> import riip
>>> ri = riip.RiiDataFrame()
>>> ri.update_db()

Uninstall

$ pip uninstall riip

or

$ conda uninstall riip

Dependencies

  • python 3
  • numpy
  • scipy
  • pandas
  • pyyaml
  • gitpython

Version

0.7.0

rii_pandas's People

Contributors

mnishida avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

joamatab

rii_pandas's Issues

No such file or directory error: library.yml

I installed the latest version (0.6.16) of RII_Pandas using pip on Windows. When I tried to run RII_Pandas for the first time and build the database, I got the following error:

import riip
ri = riip.RiiDataFrame()
Catalog file not found.
Cloning Repository...
Done.
Creating catalog file...
Traceback (most recent call last):
File "", line 1, in
File "C:\Python311\Lib\site-packages\riip\dataframe.py", line 113, in init
_catalog, _raw_data = self._load_catalog_and_raw_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\riip\dataframe.py", line 133, in _load_catalog_and_raw_data
catalog = self._add_my_db_to_catalog(self._create_catalog())
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\riip\dataframe.py", line 222, in _create_catalog
list(self._extract_entry(self._db_path)),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\riip\dataframe.py", line 167, in _extract_entry
with open(library_file, "r", encoding="utf-8") as f:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Python311\Lib\site-packages\riip\data\refractiveindex.info-database\database\library.yml'

This may be because the Polyanskiy directory now has library-nk.yml and library-n2.yml files, instead of a library.yml file.

Raw Data File creation error

I get the following error when attempting to run riip for the first time, during the "creating raw data file" stage:

Python 3.9.12 (main, Apr 5 2022, 06:56:58)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.

Commands:
import riip
ri = riip.RiiDataFrame()

Output:
Catalog file not found.
Cloning Repository...
Done.
Creating catalog file...
Done.
Creating raw data file...
Traceback (most recent call last):
File "", line 1, in
File "/.local/lib/python3.9/site-packages/riip/dataframe.py", line 113, in init
_catalog, _raw_data = self._load_catalog_and_raw_data()
File "/.local/lib/python3.9/site-packages/riip/dataframe.py", line 138, in _load_catalog_and_raw_data
raw_data, catalog = self._create_raw_data_and_modify_catalog(catalog)
File "/.local/lib/python3.9/site-packages/riip/dataframe.py", line 424, in _create_raw_data_and_modify_catalog
df_idx, catalog = self._extract_raw_data(idx, catalog)
File "/.local/lib/python3.9/site-packages/riip/dataframe.py", line 287, in _extract_raw_data
wls_n, ns, ks = np.array(
ValueError: too many values to unpack (expected 3)

Add 'name' column in catalog

'id' number may change when database update. Therefore, using id to specify material may not be safe. it will be better to add simple unique name at database creation or update, and use it to specify material.

Add hash column in catalog

  • select columns to be used for the evaluation of hash.
    • Include "model": "riip" for the evaluation of hash
  • PyOptMat will evaluate hash for custom material
    • "model": "dielectric", "model": "pec", "RI" will be used
    • Used material data are summarized in a hash table.

create tutorial

Add some explanations to examples.ipynb and create tutorial.ipynb

ValueError: too many values to unpack (expected 3)

issue within riip

when entering line:
"ri = riip.RiiDataFrame()"

there is a warning produced "FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead."

and an error:
<<
"line 287, in _extract_raw_data
wls_n, ns, ks = np.array("
ValueError: too many values to unpack (expected 3). >>

is this new to this release?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.