Giter Site home page Giter Site logo

opticalmaterialspy's People

Contributors

heitzmann avatar joamatab avatar jtambasco avatar stefanfrick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

opticalmaterialspy's Issues

Link to another python module with optical material properties

Hi, if you needed permittivity spectra for common optical materials, please take a look at https://github.com/FilipDominec/python-meep-utils/blob/master/meep_materials.py

In the referred file, the permittivity is composed as a sum of discrete Lorentzian oscillators, in which form the materials can be loaded to the MEEP FDTD simulation. (The exact material-loading routine is https://github.com/FilipDominec/python-meep-utils/blob/master/meep_utils.py#L211 )

The permittivity spectra can be compared with experimental data from many papers, see http://www.fzu.cz/~dominecf/eps/

Note also that there is another project trying to give easy access to optical constants on github: https://github.com/polyanskiy/refractiveindex.info-database

Regards, Filip

CSV url parsing error from refractiveindex.info?

It seems like the url parsing of refractive index might be out of date?

csv_url = 'https://refractiveindex.info/data_csv.php?datafile=data/%s/%s/%s.yml' \

example:
import opticalmaterialspy as m si = m.RefractiveIndexWeb('https://refractiveindex.info/?shelf=main&book=Si&page=Li-293K')
returns http error 404 from urllib after parsing it

Either way, the adjusted format seems to work on my end
csv_url = 'https://refractiveindex.info/data_csv.php?datafile=database/data-nk/%s/%s/%s.yml' \

Help! Cannot get web links to work

I tried to use the web links to download indices of materials not included in the module:

import opticalmaterialspy as mat

Web link for refractive index of diamond

m = mat.RefractiveIndexWeb('https://refractiveindex.info/?shelf=main&book=GaAs&page=Aspnes')

Refractive index @ 532nm.

print('n(532nm):', m.n(532)) # Knows 1550 must be [nm].

Group velocity refractive index @ 532nm.

print('n_gv(532nm):', m.ng(532))

Group velocity dispersion @ 532nm.

print('GVD(0.532um):', m.gvd(0.532))

=====================
I get the following errors from this code:

Traceback (most recent call last):

File "", line 1, in
runfile('C:/Users/Kevin.Knabe/.spyder-py3/scripts/optical_materials/optical_materials_test_from_web.py', wdir='C:/Users/Kevin.Knabe/.spyder-py3/scripts/optical_materials')

File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)

File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/Kevin.Knabe/.spyder-py3/scripts/optical_materials/optical_materials_test_from_web.py", line 11, in
m = mat.RefractiveIndexWeb('https://refractiveindex.info/?shelf=main&book=GaAs&page=Aspnes')

File "C:\ProgramData\Anaconda3\lib\site-packages\opticalmaterialspy\material.py", line 53, in init
data = self._get_csv(fields)

File "C:\ProgramData\Anaconda3\lib\site-packages\opticalmaterialspy\material.py", line 85, in _get_csv
data = np.array([[float(x) for x in d.split(',')] for d in data]).T

File "C:\ProgramData\Anaconda3\lib\site-packages\opticalmaterialspy\material.py", line 85, in
data = np.array([[float(x) for x in d.split(',')] for d in data]).T

File "C:\ProgramData\Anaconda3\lib\site-packages\opticalmaterialspy\material.py", line 85, in
data = np.array([[float(x) for x in d.split(',')] for d in data]).T

ValueError: could not convert string to float:

User vs system cache directory

The current implementation uses

path = os.path.dirname(__file__)
fn_cache = path + '/.material.cache'

as cache directory. For system-wide installations, the user usually doesn't have write permission to this path. Wouldn't it be best to use the user cache directory by default?

We could use AppDirs to get the correct path in a cross-platform way.
Another solution, which doesn't require external dependencies, would be to simply use

path = os.path.expanduser('~')
fn_cache = path + '/.material.cache'

but this would create the file straight into the user's home, which is not very polite IMHO.

Installing with PIP, and refractive index info does not work

Installing with "pip install opticalmaterialspy", and that went fine. The version installed is 0.20, which is also reflected on the python packaging index.

But I'm unable to get to the refractive index working. Do you have any idea what's up?
I'm not able to find the function anywhere, in the files. I might be doing something wrong.

I'm really hoping to get this to work - it's highly desirable to have a consistent way of calling the optical parameters!

Support for lossy materials

Would it be possible to add support for lossy materials to properly address #4 and improve #7?
I'd be willing to give it a try if @jtambasco agrees to it.
If it works I can submit a PR later.

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.