jtambasco / opticalmaterialspy Goto Github PK
View Code? Open in Web Editor NEWPython library with optical material properties.
License: MIT License
Python library with optical material properties.
License: MIT License
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
It seems like the url parsing of refractive index might be out of date?
import opticalmaterialspy as m si = m.RefractiveIndexWeb('https://refractiveindex.info/?shelf=main&book=Si&page=Li-293K')
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' \
I tried to use the web links to download indices of materials not included in the module:
import opticalmaterialspy as mat
m = mat.RefractiveIndexWeb('https://refractiveindex.info/?shelf=main&book=GaAs&page=Aspnes')
print('n(532nm):', m.n(532)) # Knows 1550 must be [nm].
print('n_gv(532nm):', m.ng(532))
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:
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 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!
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.