PyOptik 1.7.2.post0__tar.gz → 1.8.0.post0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PKG-INFO +68 -9
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/__init__.py +3 -3
- pyoptik-1.8.0.post0/PyOptik/__main__.py +6 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/_version.py +2 -2
- pyoptik-1.8.0.post0/PyOptik/data/classics.yml +28 -0
- pyoptik-1.8.0.post0/PyOptik/data/glasses.yml +20 -0
- pyoptik-1.8.0.post0/PyOptik/data/metals.yml +20 -0
- pyoptik-1.8.0.post0/PyOptik/data/minimal.yml +7 -0
- pyoptik-1.8.0.post0/PyOptik/data/organics.yml +11 -0
- pyoptik-1.8.0.post0/PyOptik/data/others.yml +4 -0
- pyoptik-1.8.0.post0/PyOptik/data/sellmeier/air.yml +15 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/directories.py +2 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/material/base_class.py +10 -7
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/material/sellmeier_class.py +4 -2
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/material/tabulated_class.py +0 -1
- pyoptik-1.8.0.post0/PyOptik/material_bank.py +184 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/utils.py +96 -23
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik.egg-info/PKG-INFO +68 -9
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik.egg-info/SOURCES.txt +9 -7
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/README.rst +68 -9
- pyoptik-1.8.0.post0/development/dev_0.py +14 -0
- pyoptik-1.8.0.post0/docs/examples/utils/build_library.py +31 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/code.rst +2 -18
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/conf.py +7 -4
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/pyproject.toml +2 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/tests/test_sellmeier.py +6 -1
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/tests/test_tabulated.py +4 -2
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/tests/test_usual_material.py +2 -1
- pyoptik-1.8.0.post0/tests/test_utils.py +132 -0
- pyoptik-1.7.2.post0/PyOptik/__main__.py +0 -6
- pyoptik-1.7.2.post0/PyOptik/data/sellmeier/__init__.py +0 -8
- pyoptik-1.7.2.post0/PyOptik/data/sellmeier/default.py +0 -16
- pyoptik-1.7.2.post0/PyOptik/data/sellmeier/fluorine_doped_silica_1%.yml +0 -8
- pyoptik-1.7.2.post0/PyOptik/data/sellmeier/fluorine_doped_silica_2%.yml +0 -9
- pyoptik-1.7.2.post0/PyOptik/data/sellmeier/silica.yml +0 -15
- pyoptik-1.7.2.post0/PyOptik/data/tabulated/__init__.py +0 -8
- pyoptik-1.7.2.post0/PyOptik/data/tabulated/default.py +0 -11
- pyoptik-1.7.2.post0/PyOptik/material_bank.py +0 -72
- pyoptik-1.7.2.post0/tests/test_utils.py +0 -75
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/.github/dependabot.yml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/.github/workflows/deploy_anaconda.yml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/.github/workflows/deploy_coverage.yml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/.github/workflows/deploy_documentation.yml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/.github/workflows/deploy_workflow.yml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/.gitignore +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/.readthedocs.yml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/LICENSE +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/data/__init__.py +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/data/sellmeier/BAK1.yml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/data/sellmeier/BK7.yml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/data/sellmeier/SF5.yml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/data/sellmeier/ZBLAN.yml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/data/sellmeier/argon.yml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/data/sellmeier/crown.yml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/data/sellmeier/flint.yml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/data/sellmeier/fused_silica.yml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/data/sellmeier/germanium.yml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/data/sellmeier/lithium_niobate.yml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/data/sellmeier/polystyren.yml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/data/sellmeier/silicon.yml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/data/sellmeier/soda_lime_glass.yml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/data/sellmeier/water.yml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/data/tabulated/aluminium.yml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/data/tabulated/calcium.yml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/data/tabulated/copper.yml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/data/tabulated/gold.yml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/data/tabulated/iron.yml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/data/tabulated/nickel.yml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/data/tabulated/silver.yml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/data/tabulated/sodium.yml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/data/tabulated/zinc.yml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/material/__init__.py +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik/units.py +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik.egg-info/dependency_links.txt +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik.egg-info/requires.txt +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/PyOptik.egg-info/top_level.txt +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/Makefile +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/examples/README.rst +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/examples/sellmeier/README.rst +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/examples/sellmeier/plot_bk7.py +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/examples/sellmeier/plot_silica.py +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/examples/sellmeier/plot_water.py +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/examples/tabulated/README.rst +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/examples/tabulated/plot_sf5.py +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/examples/tabulated/plot_silver.py +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/examples/utils/README.rst +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/examples/utils/create_sellmeier_file.py +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/examples/utils/create_tabulated_file.py +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/examples/utils/download_yml_file.py +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/images/example_bk7.png +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/images/logo.png +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/make.bat +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/_static/default.css +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/index.rst +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/sellmeier/images/sphx_glr_plot_bk7_001.png +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/sellmeier/images/sphx_glr_plot_silica_001.png +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/sellmeier/images/sphx_glr_plot_water_001.png +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/sellmeier/images/thumb/sphx_glr_plot_bk7_thumb.png +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/sellmeier/images/thumb/sphx_glr_plot_silica_thumb.png +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/sellmeier/images/thumb/sphx_glr_plot_water_thumb.png +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/sellmeier/index.rst +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/sellmeier/plot_bk7.ipynb +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/sellmeier/plot_bk7.py +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/sellmeier/plot_bk7.py.md5 +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/sellmeier/plot_bk7.rst +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/sellmeier/plot_bk7_codeobj.pickle +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/sellmeier/plot_silica.ipynb +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/sellmeier/plot_silica.py +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/sellmeier/plot_silica.py.md5 +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/sellmeier/plot_silica.rst +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/sellmeier/plot_silica_codeobj.pickle +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/sellmeier/plot_water.ipynb +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/sellmeier/plot_water.py +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/sellmeier/plot_water.py.md5 +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/sellmeier/plot_water.rst +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/sellmeier/plot_water_codeobj.pickle +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/sellmeier/sg_execution_times.rst +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/tabulated/images/sphx_glr_plot_sf5_001.png +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/tabulated/images/sphx_glr_plot_silver_001.png +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/tabulated/images/thumb/sphx_glr_plot_sf5_thumb.png +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/tabulated/images/thumb/sphx_glr_plot_silver_thumb.png +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/tabulated/index.rst +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/tabulated/plot_sf5.ipynb +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/tabulated/plot_sf5.py +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/tabulated/plot_sf5.py.md5 +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/tabulated/plot_sf5.rst +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/tabulated/plot_sf5_codeobj.pickle +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/tabulated/plot_silver.ipynb +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/tabulated/plot_silver.py +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/tabulated/plot_silver.py.md5 +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/tabulated/plot_silver.rst +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/tabulated/plot_silver_codeobj.pickle +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/tabulated/sg_execution_times.rst +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/utils/create_sellmeier_file.ipynb +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/utils/create_sellmeier_file.py +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/utils/create_sellmeier_file.py.md5 +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/utils/create_sellmeier_file.rst +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/utils/create_sellmeier_file_codeobj.pickle +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/utils/create_tabulated_file.ipynb +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/utils/create_tabulated_file.py +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/utils/create_tabulated_file.py.md5 +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/utils/create_tabulated_file.rst +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/utils/create_tabulated_file_codeobj.pickle +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/utils/download_yml_file.ipynb +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/utils/download_yml_file.py +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/utils/download_yml_file.py.md5 +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/utils/download_yml_file.rst +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/utils/download_yml_file_codeobj.pickle +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/utils/images/sphx_glr_create_sellmeier_file_001.png +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/utils/images/sphx_glr_create_tabulated_file_001.png +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/utils/images/sphx_glr_download_yml_file_001.png +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/utils/images/thumb/sphx_glr_create_sellmeier_file_thumb.png +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/utils/images/thumb/sphx_glr_create_tabulated_file_thumb.png +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/utils/images/thumb/sphx_glr_download_yml_file_thumb.png +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/utils/index.rst +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/gallery/utils/sg_execution_times.rst +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/index.rst +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/docs/source/references.rst +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/meta.yaml +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/setup.cfg +0 -0
- {pyoptik-1.7.2.post0 → pyoptik-1.8.0.post0}/tests/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PyOptik
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.8.0.post0
|
|
4
4
|
Summary: A package for refractive index values.
|
|
5
5
|
Author-email: Martin Poinsinet de Sivry-Houle <martin.poinsinet.de.sivry@gmail.com>
|
|
6
6
|
License: MIT License
|
|
@@ -62,7 +62,7 @@ PyOptik
|
|
|
62
62
|
|
|
63
63
|
PyOptik is a powerful Python tool designed to import refractive indexes and extinction coefficients for various materials across different wavelengths. The data provided by PyOptik can be used in numerous applications, including simulating light interactions with particles. All data is sourced from the reputable RefractiveIndex.INFO database.
|
|
64
64
|
|
|
65
|
-
|
|
|
65
|
+
|logo|
|
|
66
66
|
|
|
67
67
|
.. list-table::
|
|
68
68
|
:widths: 10 25 25 25
|
|
@@ -99,10 +99,67 @@ To install PyOptik, simply use `pip` or `conda`:
|
|
|
99
99
|
pip install PyOptik
|
|
100
100
|
conda install --channels martinpdes pyoptik
|
|
101
101
|
|
|
102
|
+
Building the Material Library
|
|
103
|
+
*****************************
|
|
104
|
+
|
|
105
|
+
PyOptik allows you to build and customize a local material library, importing material data from various categories. You can download the following categories of materials from the RefractiveIndex.INFO database:
|
|
106
|
+
|
|
107
|
+
- `classics`: Commonly used optical materials.
|
|
108
|
+
- `glasses`: Various types of glass materials.
|
|
109
|
+
- `metals`: Different metal materials for optical simulations.
|
|
110
|
+
- `organics`: Organic materials with optical properties.
|
|
111
|
+
- `others`: Other optical materials.
|
|
112
|
+
- `all`: Download all available categories at once.
|
|
113
|
+
|
|
114
|
+
To build a material library, use the `build_library` function. This will download and save the material data to your local machine.
|
|
115
|
+
|
|
116
|
+
**Example: Building the Material Library:**
|
|
117
|
+
|
|
118
|
+
In this example, we will download the `others` category of materials and remove any previously existing data in that category:
|
|
119
|
+
|
|
120
|
+
.. code:: python
|
|
121
|
+
|
|
122
|
+
from PyOptik.utils import build_library
|
|
123
|
+
|
|
124
|
+
# Download the 'others' category and remove previous files
|
|
125
|
+
build_library('others', remove_previous=True)
|
|
126
|
+
|
|
127
|
+
**Available Categories:**
|
|
128
|
+
|
|
129
|
+
To download materials from another category, simply pass the category name as an argument to `build_library`. For example:
|
|
130
|
+
|
|
131
|
+
.. code:: python
|
|
132
|
+
|
|
133
|
+
# Download materials from the 'glasses' category
|
|
134
|
+
build_library('glasses')
|
|
135
|
+
|
|
136
|
+
To download all material categories at once:
|
|
137
|
+
|
|
138
|
+
.. code:: python
|
|
139
|
+
|
|
140
|
+
# Download all available material categories
|
|
141
|
+
build_library('all')
|
|
142
|
+
|
|
143
|
+
You can also set the `remove_previous` parameter to `True` to remove old data before downloading new material data.
|
|
144
|
+
|
|
145
|
+
Viewing Available Materials
|
|
146
|
+
***************************
|
|
147
|
+
|
|
148
|
+
Once you have built the material library, you can view all the available materials using the `MaterialBank` class. This will print a list of materials stored in your local library.
|
|
149
|
+
|
|
150
|
+
**Example:**
|
|
151
|
+
|
|
152
|
+
.. code:: python
|
|
153
|
+
|
|
154
|
+
from PyOptik import MaterialBank
|
|
155
|
+
|
|
156
|
+
# Print the available materials in a tabulated format
|
|
157
|
+
MaterialBank.print_materials()
|
|
158
|
+
|
|
102
159
|
Simple Usage
|
|
103
160
|
************
|
|
104
161
|
|
|
105
|
-
After installing PyOptik, you can easily access material properties:
|
|
162
|
+
After installing PyOptik and building the material library, you can easily access material properties:
|
|
106
163
|
|
|
107
164
|
.. code:: python
|
|
108
165
|
|
|
@@ -113,7 +170,6 @@ After installing PyOptik, you can easily access material properties:
|
|
|
113
170
|
n = bk7.compute_refractive_index(0.55e-6)
|
|
114
171
|
print(f"Refractive index at 0.55 µm: {n}")
|
|
115
172
|
|
|
116
|
-
|
|
117
173
|
Example
|
|
118
174
|
*******
|
|
119
175
|
|
|
@@ -136,8 +192,12 @@ Here is a quick example demonstrating how to use PyOptik to retrieve and plot th
|
|
|
136
192
|
|
|
137
193
|
This code produces the following figure: |example_bk7|
|
|
138
194
|
|
|
195
|
+
Adding and Removing Custom Materials
|
|
196
|
+
************************************
|
|
197
|
+
|
|
198
|
+
You can add a custom material to your library by providing a URL from `refractiveindex.info <https://refractiveindex.info>`_.
|
|
139
199
|
|
|
140
|
-
|
|
200
|
+
**Adding a Custom Material:**
|
|
141
201
|
|
|
142
202
|
.. code:: python
|
|
143
203
|
|
|
@@ -150,8 +210,9 @@ You can also add a custom element to your library providing a URL from `refracti
|
|
|
150
210
|
location=tabulated_data_path
|
|
151
211
|
)
|
|
152
212
|
|
|
153
|
-
|
|
213
|
+
**Removing a Material:**
|
|
154
214
|
|
|
215
|
+
You can also remove a material from the library as follows:
|
|
155
216
|
|
|
156
217
|
.. code:: python
|
|
157
218
|
|
|
@@ -185,12 +246,10 @@ As of 2024, PyOptik is still under development. If you would like to collaborate
|
|
|
185
246
|
|
|
186
247
|
**Email**: `martin.poinsinet.de.sivry@gmail.com <mailto:martin.poinsinet.de.sivry@gmail.com?subject=PyOptik>`_
|
|
187
248
|
|
|
188
|
-
|
|
189
|
-
|
|
190
249
|
.. |python| image:: https://img.shields.io/pypi/pyversions/pyoptik.svg
|
|
191
250
|
:target: https://www.python.org/
|
|
192
251
|
|
|
193
|
-
.. |
|
|
252
|
+
.. |logo| image:: https://github.com/MartinPdeS/PyOptik/raw/master/docs/images/logo.png
|
|
194
253
|
|
|
195
254
|
.. |example_bk7| image:: https://github.com/MartinPdeS/PyOptik/raw/master/docs/images/example_bk7.png
|
|
196
255
|
:target: https://github.com/MartinPdeS/PyOptik/blob/master/docs/images/example_bk7.png
|
|
@@ -5,10 +5,10 @@ except ImportError:
|
|
|
5
5
|
__version__ = "0.0.0"
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
from .utils import
|
|
9
|
-
from .material_bank import
|
|
8
|
+
from .utils import build_library
|
|
9
|
+
from .material_bank import MaterialBank
|
|
10
10
|
from .material import TabulatedMaterial
|
|
11
11
|
from .material import SellmeierMaterial
|
|
12
12
|
from .material import base_class
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Material = MaterialBank # For retro-compatiibility
|
|
@@ -12,5 +12,5 @@ __version__: str
|
|
|
12
12
|
__version_tuple__: VERSION_TUPLE
|
|
13
13
|
version_tuple: VERSION_TUPLE
|
|
14
14
|
|
|
15
|
-
__version__ = version = '1.
|
|
16
|
-
__version_tuple__ = version_tuple = (1,
|
|
15
|
+
__version__ = version = '1.8.0.post0'
|
|
16
|
+
__version_tuple__ = version_tuple = (1, 8, 0)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
sellmeier:
|
|
2
|
+
ZBLAN: https://refractiveindex.info/database/data-nk/glass/misc/ZBLAN/Gan.yml
|
|
3
|
+
BK7: https://refractiveindex.info/database/data-nk/glass/schott/N-BK7.yml
|
|
4
|
+
fused_silica: https://refractiveindex.info/database/data-nk/main/SiO2/Malitson.yml
|
|
5
|
+
BAK1: https://refractiveindex.info/database/data-nk/glass/schott/N-BAK1.yml
|
|
6
|
+
SF5: https://refractiveindex.info/database/data-nk/glass/schott/N-SF5.yml
|
|
7
|
+
water: https://refractiveindex.info/database/data-nk/main/H2O/Daimon-19.0C.yml
|
|
8
|
+
polystyren: https://refractiveindex.info/database/data-nk/organic/(C8H8)n%20-%20polystyrene/Sultanova.yml
|
|
9
|
+
lithium_niobate: https://refractiveindex.info/database/data-nk/main/LiNbO3/Zelmon-o.yml
|
|
10
|
+
germanium: https://refractiveindex.info/database/data-nk/main/Ge/Icenogle.yml
|
|
11
|
+
silicon: https://refractiveindex.info/database/data-nk/main/Si/Salzberg.yml
|
|
12
|
+
soda_lime_glass: https://refractiveindex.info/database/data-nk/glass/misc/soda-lime/Rubin-clear.yml
|
|
13
|
+
crown: https://refractiveindex.info/database/data-nk/glass/schott/K7.yml
|
|
14
|
+
flint: https://refractiveindex.info/database/data-nk/glass/schott/F2.yml
|
|
15
|
+
argon: https://refractiveindex.info/database/data-nk/main/Ar/Bideau-Mehu.yml
|
|
16
|
+
air: https://refractiveindex.info/database/data-nk/other/mixed%20gases/air/Ciddor.yml
|
|
17
|
+
water: https://refractiveindex.info/database/data-nk/main/H2O/Daimon-19.0C.yml
|
|
18
|
+
|
|
19
|
+
tabulated:
|
|
20
|
+
silver: https://refractiveindex.info/database/data-nk/main/Ag/Johnson.yml
|
|
21
|
+
aluminium: https://refractiveindex.info/database/data-nk/main/Al/Rakic.yml
|
|
22
|
+
gold: https://refractiveindex.info/database/data-nk/main/Au/Johnson.yml
|
|
23
|
+
calcium: https://refractiveindex.info/database/data-nk/main/Ca/Mathewson.yml
|
|
24
|
+
copper: https://refractiveindex.info/database/data-nk/main/Cu/Johnson.yml
|
|
25
|
+
iron: https://refractiveindex.info/database/data-nk/main/Fe/Johnson.yml
|
|
26
|
+
sodium: https://refractiveindex.info/database/data-nk/main/Na/Smith.yml
|
|
27
|
+
nickel: https://refractiveindex.info/database/data-nk/main/Ni/Johnson.yml
|
|
28
|
+
zinc: https://refractiveindex.info/database/data-nk/main/Zn/Werner.yml
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
sellmeier:
|
|
2
|
+
ZBLAN: https://refractiveindex.info/database/data-nk/glass/misc/ZBLAN/Gan.yml
|
|
3
|
+
BK7: https://refractiveindex.info/database/data-nk/glass/schott/N-BK7.yml
|
|
4
|
+
fused_silica: https://refractiveindex.info/database/data-nk/main/SiO2/Malitson.yml
|
|
5
|
+
BAK1: https://refractiveindex.info/database/data-nk/glass/schott/N-BAK1.yml
|
|
6
|
+
BAF10: https://refractiveindex.info/database/data-nk/glass/schott/N-BAF10.yml
|
|
7
|
+
SF5: https://refractiveindex.info/database/data-nk/glass/schott/N-SF5.yml
|
|
8
|
+
SF10: https://refractiveindex.info/database/data-nk/glass/schott/N-SF10.yml
|
|
9
|
+
SF11: https://refractiveindex.info/database/data-nk/glass/schott/N-SF11.yml
|
|
10
|
+
LASF9: https://refractiveindex.info/database/data-nk/glass/schott/N-LASF9.yml
|
|
11
|
+
FK51A: https://refractiveindex.info/database/data-nk/glass/schott/N-FK51A.yml
|
|
12
|
+
water: https://refractiveindex.info/database/data-nk/main/H2O/Daimon-19.0C.yml
|
|
13
|
+
polystyren: https://refractiveindex.info/database/data-nk/organic/(C8H8)n%20-%20polystyrene/Sultanova.yml
|
|
14
|
+
lithium_niobate: https://refractiveindex.info/database/data-nk/main/LiNbO3/Zelmon-o.yml
|
|
15
|
+
germanium: https://refractiveindex.info/database/data-nk/main/Ge/Icenogle.yml
|
|
16
|
+
silicon: https://refractiveindex.info/database/data-nk/main/Si/Salzberg.yml
|
|
17
|
+
soda_lime_glass: https://refractiveindex.info/database/data-nk/glass/misc/soda-lime/Rubin-clear.yml
|
|
18
|
+
crown: https://refractiveindex.info/database/data-nk/glass/schott/K7.yml
|
|
19
|
+
flint: https://refractiveindex.info/database/data-nk/glass/schott/F2.yml
|
|
20
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
tabulated:
|
|
2
|
+
silver: https://refractiveindex.info/database/data-nk/main/Ag/Johnson.yml
|
|
3
|
+
aluminium: https://refractiveindex.info/database/data-nk/main/Al/Rakic.yml
|
|
4
|
+
gold: https://refractiveindex.info/database/data-nk/main/Au/Johnson.yml
|
|
5
|
+
calcium: https://refractiveindex.info/database/data-nk/main/Ca/Mathewson.yml
|
|
6
|
+
copper: https://refractiveindex.info/database/data-nk/main/Cu/Johnson.yml
|
|
7
|
+
iron: https://refractiveindex.info/database/data-nk/main/Fe/Johnson.yml
|
|
8
|
+
sodium: https://refractiveindex.info/database/data-nk/main/Na/Smith.yml
|
|
9
|
+
nickel: https://refractiveindex.info/database/data-nk/main/Ni/Johnson.yml
|
|
10
|
+
zinc: https://refractiveindex.info/database/data-nk/main/Zn/Werner.yml
|
|
11
|
+
chromium: https://refractiveindex.info/database/data-nk/main/Cr/Johnson.yml
|
|
12
|
+
titanium: https://refractiveindex.info/database/data-nk/main/Ti/Johnson.yml
|
|
13
|
+
tungsten: https://refractiveindex.info/database/data-nk/main/W/Werner.yml
|
|
14
|
+
lead: https://refractiveindex.info/database/data-nk/main/Pb/Werner.yml
|
|
15
|
+
bismuth: https://refractiveindex.info/database/data-nk/main/Bi/Werner.yml
|
|
16
|
+
magnesium: https://refractiveindex.info/database/data-nk/main/Mg/Hagemann.yml
|
|
17
|
+
paladium: https://refractiveindex.info/database/data-nk/main/Pd/Johnson.yml
|
|
18
|
+
rhodium: https://refractiveindex.info/database/data-nk/main/Rh/Arndt.yml
|
|
19
|
+
vanadium: https://refractiveindex.info/database/data-nk/main/V/Johnson.yml
|
|
20
|
+
tantalum: https://refractiveindex.info/database/data-nk/main/Ta/Werner.yml
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
sellmeier:
|
|
2
|
+
argon: https://refractiveindex.info/database/data-nk/main/Ar/Bideau-Mehu.yml
|
|
3
|
+
air: https://refractiveindex.info/database/data-nk/other/mixed%20gases/air/Ciddor.yml
|
|
4
|
+
water: https://refractiveindex.info/database/data-nk/main/H2O/Daimon-19.0C.yml
|
|
5
|
+
|
|
6
|
+
tabulated:
|
|
7
|
+
zinc: https://refractiveindex.info/database/data-nk/main/Zn/Werner.yml
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
sellmeier:
|
|
2
|
+
ethanol: https://refractiveindex.info/database/data-nk/organic/C2H6O%20-%20ethanol/Rheims.yml
|
|
3
|
+
methanol: https://refractiveindex.info/database/data-nk/organic/CH4O%20-%20methanol/El-Kashef.yml
|
|
4
|
+
propanol: https://refractiveindex.info/database/data-nk/organic/C3H8O%20-%20propanol/Kozma.yml
|
|
5
|
+
ethylene: https://refractiveindex.info/database/data-nk/organic/C2H4%20-%20ethylene/Loria.yml
|
|
6
|
+
acetylene: https://refractiveindex.info/database/data-nk/organic/C2H2%20-%20acetylene/Loria.yml
|
|
7
|
+
methane: https://refractiveindex.info/database/data-nk/organic/CH4%20-%20methane/Loria.yml
|
|
8
|
+
ethane: https://refractiveindex.info/database/data-nk/organic/C2H6%20-%20ethane/Loria.yml
|
|
9
|
+
acetone: https://refractiveindex.info/database/data-nk/organic/C3H6O%20-%20acetone/Rheims.yml
|
|
10
|
+
glycerol: https://refractiveindex.info/database/data-nk/organic/C3H8O3%20-%20glycerol/Rheims.yml
|
|
11
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# this file is part of refractiveindex.info database
|
|
2
|
+
# refractiveindex.info database is in the public domain
|
|
3
|
+
# copyright and related rights waived via CC0 1.0
|
|
4
|
+
|
|
5
|
+
REFERENCES: "P. E. Ciddor. Refractive index of air: new equations for the visible and near infrared, <a href=\"https://doi.org/10.1364/AO.35.001566\"><i>Appl. Optics</i> <b>35</b>, 1566-1573 (1996)</a><br>[<a href=\"https://github.com/polyanskiy/refractiveindex.info-scripts/blob/master/scripts/Ciddor%201996%20-%20air.py\">Calculation script (Python)</a> - can be used to calculate the refractive index of air for specific values of humidity, temperature, pressure, and CO<sub>2</sub> concentration]"
|
|
6
|
+
COMMENTS: "Standard air: dry air at 15 °C, 101.325 kPa and with 450 ppm CO<sub>2</sub> content."
|
|
7
|
+
DATA:
|
|
8
|
+
- type: formula 6
|
|
9
|
+
wavelength_range: 0.23 1.690
|
|
10
|
+
coefficients: 0 0.05792105 238.0185 0.00167917 57.362
|
|
11
|
+
SPECS:
|
|
12
|
+
n_is_absolute: true
|
|
13
|
+
wavelength_is_vacuum: true
|
|
14
|
+
temperature: 15 °C
|
|
15
|
+
pressure: 101325 Pa
|
|
@@ -30,6 +30,8 @@ examples_path = root_path.joinpath('examples')
|
|
|
30
30
|
sellmeier_data_path = root_path.joinpath('data/sellmeier')
|
|
31
31
|
tabulated_data_path = root_path.joinpath('data/tabulated')
|
|
32
32
|
|
|
33
|
+
data_path = root_path.joinpath('data')
|
|
34
|
+
|
|
33
35
|
|
|
34
36
|
if __name__ == '__main__':
|
|
35
37
|
for path_name in __all__:
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding: utf-8 -*-
|
|
3
3
|
|
|
4
|
+
from typing import Callable
|
|
4
5
|
from PyOptik.units import Quantity, meter
|
|
5
6
|
import numpy
|
|
6
7
|
import warnings
|
|
@@ -28,13 +29,13 @@ class BaseMaterial:
|
|
|
28
29
|
"""
|
|
29
30
|
return self.__str__()
|
|
30
31
|
|
|
31
|
-
def _check_wavelength(self,
|
|
32
|
+
def _check_wavelength(self, wavelength: Quantity) -> None:
|
|
32
33
|
"""
|
|
33
34
|
Checks if a wavelength is within the material's allowable range and raises a warning if it is not.
|
|
34
35
|
|
|
35
36
|
Parameters
|
|
36
37
|
----------
|
|
37
|
-
|
|
38
|
+
wavelength : Quantity
|
|
38
39
|
The wavelength to check, in micrometers.
|
|
39
40
|
|
|
40
41
|
Raises
|
|
@@ -45,29 +46,31 @@ class BaseMaterial:
|
|
|
45
46
|
if self.wavelength_bound is not None:
|
|
46
47
|
min_value, max_value = self.wavelength_bound
|
|
47
48
|
|
|
48
|
-
if numpy.any((
|
|
49
|
+
if numpy.any((wavelength < min_value) | (wavelength > max_value)):
|
|
49
50
|
warnings.warn(
|
|
50
|
-
f"Wavelength range goes from {
|
|
51
|
+
f"Wavelength range goes from {wavelength.min().to_compact()} to {wavelength.max().to_compact()} "
|
|
51
52
|
f"which is outside the allowable range of {min_value.to_compact()} to {max_value.to_compact()} µm. "
|
|
52
53
|
f"[Material: {self.filename}]"
|
|
53
54
|
)
|
|
54
55
|
|
|
55
|
-
def ensure_units(func):
|
|
56
|
+
def ensure_units(func) -> Callable:
|
|
56
57
|
"""
|
|
57
58
|
Decorator to ensure that the wavelength parameter has the correct units.
|
|
58
59
|
|
|
59
60
|
Parameters
|
|
60
61
|
----------
|
|
61
|
-
func :
|
|
62
|
+
func : Callable
|
|
62
63
|
The function to wrap.
|
|
63
64
|
|
|
64
65
|
Returns
|
|
65
66
|
-------
|
|
66
|
-
|
|
67
|
+
Callable
|
|
67
68
|
The wrapped function that ensures wavelength is a Quantity in meters.
|
|
68
69
|
"""
|
|
69
70
|
def wrapper(self, wavelength: Quantity = None, *args, **kwargs):
|
|
70
71
|
if wavelength is None:
|
|
72
|
+
if self.wavelength_bound is None:
|
|
73
|
+
raise ValueError('Wavelenght must be provided for computation.')
|
|
71
74
|
wavelength = numpy.linspace(self.wavelength_bound[0].magnitude, self.wavelength_bound[1].magnitude, 100) * self.wavelength_bound.units
|
|
72
75
|
|
|
73
76
|
if not isinstance(wavelength, Quantity):
|
|
@@ -36,6 +36,7 @@ class SellmeierMaterial(BaseMaterial):
|
|
|
36
36
|
The formula type to use for refractive index calculation.
|
|
37
37
|
"""
|
|
38
38
|
filename: str
|
|
39
|
+
|
|
39
40
|
coefficients: Optional[numpy.ndarray] = Field(default=None)
|
|
40
41
|
wavelength_bound: Optional[Tuple[float, float]] = Field(default=None)
|
|
41
42
|
reference: Optional[str] = Field(default=None)
|
|
@@ -73,12 +74,13 @@ class SellmeierMaterial(BaseMaterial):
|
|
|
73
74
|
# Extract wavelength range
|
|
74
75
|
if 'wavelength_range' in parsed_yaml['DATA'][0]:
|
|
75
76
|
data_str = parsed_yaml['DATA'][0]['wavelength_range'].split()
|
|
77
|
+
|
|
76
78
|
self.wavelength_bound = numpy.array([float(val) for val in data_str]) * micrometer
|
|
77
79
|
|
|
78
80
|
else:
|
|
79
81
|
self.wavelength_bound = None
|
|
80
82
|
|
|
81
|
-
# Extract reference
|
|
83
|
+
# # Extract reference
|
|
82
84
|
self.reference = parsed_yaml.get('REFERENCES', None)
|
|
83
85
|
|
|
84
86
|
@BaseMaterial.ensure_units
|
|
@@ -185,4 +187,4 @@ class SellmeierMaterial(BaseMaterial):
|
|
|
185
187
|
f"wavelength_range: {self.wavelength_bound},\n"
|
|
186
188
|
f"formula_type: {self.formula_type},\n"
|
|
187
189
|
f"reference: '{self.reference}')"
|
|
188
|
-
)
|
|
190
|
+
)
|
|
@@ -5,7 +5,6 @@ import numpy
|
|
|
5
5
|
from pydantic.dataclasses import dataclass, Field
|
|
6
6
|
from typing import Optional, Union
|
|
7
7
|
import yaml
|
|
8
|
-
import warnings
|
|
9
8
|
from PyOptik.directories import tabulated_data_path
|
|
10
9
|
from PyOptik.material.base_class import BaseMaterial
|
|
11
10
|
from MPSPlots.styles import mps
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
from typing import List
|
|
7
|
+
from PyOptik.material.sellmeier_class import SellmeierMaterial
|
|
8
|
+
from PyOptik.material.tabulated_class import TabulatedMaterial
|
|
9
|
+
from PyOptik.utils import download_yml_file, remove_element
|
|
10
|
+
from PyOptik.directories import tabulated_data_path, sellmeier_data_path
|
|
11
|
+
from tabulate import tabulate
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class MaterialBankMeta(type):
|
|
15
|
+
"""
|
|
16
|
+
Metaclass to handle dynamic material lookup for the MaterialBank class.
|
|
17
|
+
"""
|
|
18
|
+
def __getattr__(cls, material_name: str):
|
|
19
|
+
"""
|
|
20
|
+
Retrieve a material by name dynamically at the class level.
|
|
21
|
+
|
|
22
|
+
Parameters
|
|
23
|
+
----------
|
|
24
|
+
material_name : str
|
|
25
|
+
The name of the material to retrieve.
|
|
26
|
+
|
|
27
|
+
Returns
|
|
28
|
+
-------
|
|
29
|
+
Union[SellmeierMaterial, TabulatedMaterial]
|
|
30
|
+
An instance of the material if found.
|
|
31
|
+
|
|
32
|
+
Raises
|
|
33
|
+
------
|
|
34
|
+
FileNotFoundError
|
|
35
|
+
If the material is not found in either the Sellmeier or Tabulated lists.
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
if material_name in cls.sellmeier():
|
|
39
|
+
print('--'*50, material_name, material_name.__class__)
|
|
40
|
+
return SellmeierMaterial(filename=material_name)
|
|
41
|
+
|
|
42
|
+
if material_name in cls.tabulated():
|
|
43
|
+
return TabulatedMaterial(filename=material_name)
|
|
44
|
+
|
|
45
|
+
raise FileNotFoundError(f'Material: [{material_name}] could not be found.')
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class MaterialBank(metaclass=MaterialBankMeta):
|
|
49
|
+
"""
|
|
50
|
+
A class representing a centralized material bank for common optical materials available in the PyOptik library.
|
|
51
|
+
|
|
52
|
+
The `MaterialBank` class provides access to a predefined list of materials used in optical simulations,
|
|
53
|
+
categorized into Sellmeier and Tabulated materials. It allows users to dynamically retrieve materials
|
|
54
|
+
based on their names without the need to instantiate the class. The material bank can be expanded
|
|
55
|
+
or modified by adding or removing materials from the bank, and it provides utilities to fetch material data
|
|
56
|
+
dynamically when accessed as class attributes.
|
|
57
|
+
|
|
58
|
+
Attributes
|
|
59
|
+
----------
|
|
60
|
+
all : list
|
|
61
|
+
A combined list of all materials, including both Sellmeier and Tabulated materials.
|
|
62
|
+
|
|
63
|
+
Usage
|
|
64
|
+
-----
|
|
65
|
+
Materials can be accessed directly as class attributes:
|
|
66
|
+
|
|
67
|
+
>>> material = MaterialBank
|
|
68
|
+
>>> bk7_material = material.BK7 # Dynamically retrieves the BK7 material.
|
|
69
|
+
|
|
70
|
+
To add a new material to the Sellmeier bank:
|
|
71
|
+
|
|
72
|
+
>>> material.add_sellmeier_to_bank("new_material.yml", "http://example.com/material.yml")
|
|
73
|
+
|
|
74
|
+
To remove a material from the bank:
|
|
75
|
+
|
|
76
|
+
>>> material.remove_item_from_bank("obsolete_material.yml")
|
|
77
|
+
|
|
78
|
+
Raises
|
|
79
|
+
------
|
|
80
|
+
FileNotFoundError
|
|
81
|
+
If a material is not found in either the Sellmeier or Tabulated material lists.
|
|
82
|
+
"""
|
|
83
|
+
|
|
84
|
+
@classmethod
|
|
85
|
+
def sellmeier(cls) -> List[str]:
|
|
86
|
+
return [
|
|
87
|
+
os.path.splitext(f)[0] for f in os.listdir(sellmeier_data_path) if os.path.isfile(os.path.join(sellmeier_data_path, f)) and f.endswith('.yml')
|
|
88
|
+
]
|
|
89
|
+
|
|
90
|
+
@classmethod
|
|
91
|
+
def tabulated(cls) -> List[str]:
|
|
92
|
+
return [
|
|
93
|
+
os.path.splitext(f)[0] for f in os.listdir(tabulated_data_path) if os.path.isfile(os.path.join(tabulated_data_path, f)) and f.endswith('.yml')
|
|
94
|
+
]
|
|
95
|
+
|
|
96
|
+
@classmethod
|
|
97
|
+
def all(self) -> List[str]:
|
|
98
|
+
return self.sellmeier() + self.tabulated()
|
|
99
|
+
|
|
100
|
+
@classmethod
|
|
101
|
+
def print_materials(cls) -> None:
|
|
102
|
+
"""
|
|
103
|
+
Prints out all the available Sellmeier and Tabulated materials in a tabulated format.
|
|
104
|
+
"""
|
|
105
|
+
sellmeier_materials = cls.sellmeier()
|
|
106
|
+
tabulated_materials = cls.tabulated()
|
|
107
|
+
|
|
108
|
+
# Create data for the table
|
|
109
|
+
table_data = []
|
|
110
|
+
max_len = max(len(sellmeier_materials), len(tabulated_materials))
|
|
111
|
+
for i in range(max_len):
|
|
112
|
+
sellmeier = sellmeier_materials[i] if i < len(sellmeier_materials) else ""
|
|
113
|
+
tabulated = tabulated_materials[i] if i < len(tabulated_materials) else ""
|
|
114
|
+
table_data.append([sellmeier, tabulated])
|
|
115
|
+
|
|
116
|
+
# Define headers
|
|
117
|
+
headers = ["Sellmeier Materials", "Tabulated Materials"]
|
|
118
|
+
|
|
119
|
+
# Print the table using tabulate
|
|
120
|
+
print(tabulate(table_data, headers=headers, tablefmt="grid"))
|
|
121
|
+
|
|
122
|
+
@classmethod
|
|
123
|
+
def add_sellmeier_to_bank(cls, filename: str, url: str) -> None:
|
|
124
|
+
"""
|
|
125
|
+
Add a Sellmeier material to the material bank.
|
|
126
|
+
|
|
127
|
+
Downloads a YAML file containing the Sellmeier material data from a specified URL and stores it
|
|
128
|
+
in the Sellmeier materials directory.
|
|
129
|
+
|
|
130
|
+
Parameters
|
|
131
|
+
----------
|
|
132
|
+
filename : str
|
|
133
|
+
The name of the file to be saved in the Sellmeier material bank.
|
|
134
|
+
url : str
|
|
135
|
+
The URL from where the material file is downloaded.
|
|
136
|
+
|
|
137
|
+
Returns
|
|
138
|
+
-------
|
|
139
|
+
None
|
|
140
|
+
"""
|
|
141
|
+
return download_yml_file(filename=filename, url=url, location=sellmeier_data_path)
|
|
142
|
+
|
|
143
|
+
@classmethod
|
|
144
|
+
def add_tabulated_to_bank(cls, filename: str, url: str) -> None:
|
|
145
|
+
"""
|
|
146
|
+
Add a Tabulated material to the material bank.
|
|
147
|
+
|
|
148
|
+
Downloads a YAML file containing the Tabulated material data from a specified URL and stores it
|
|
149
|
+
in the Tabulated materials directory.
|
|
150
|
+
|
|
151
|
+
Parameters
|
|
152
|
+
----------
|
|
153
|
+
filename : str
|
|
154
|
+
The name of the file to be saved in the Tabulated material bank.
|
|
155
|
+
url : str
|
|
156
|
+
The URL from where the material file is downloaded.
|
|
157
|
+
|
|
158
|
+
Returns
|
|
159
|
+
-------
|
|
160
|
+
None
|
|
161
|
+
"""
|
|
162
|
+
return download_yml_file(filename=filename, url=url, location=tabulated_data_path)
|
|
163
|
+
|
|
164
|
+
@classmethod
|
|
165
|
+
def remove_item_from_bank(cls, filename: str, location: str = 'any') -> None:
|
|
166
|
+
"""
|
|
167
|
+
Remove a material file from the material bank.
|
|
168
|
+
|
|
169
|
+
Deletes a material file from either the Sellmeier, Tabulated, or both directories based on the location.
|
|
170
|
+
If `location` is set to 'any', it will search for the material file in both directories and remove it.
|
|
171
|
+
|
|
172
|
+
Parameters
|
|
173
|
+
----------
|
|
174
|
+
filename : str
|
|
175
|
+
The name of the material file to be removed.
|
|
176
|
+
location : str, optional
|
|
177
|
+
The location to search for the material ('sellmeier', 'tabulated', or 'any').
|
|
178
|
+
Default is 'any'.
|
|
179
|
+
|
|
180
|
+
Returns
|
|
181
|
+
-------
|
|
182
|
+
None
|
|
183
|
+
"""
|
|
184
|
+
remove_element(filename=filename, location=location)
|