PyOptik 0.7.11__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.
Files changed (36) hide show
  1. pyoptik-0.7.11/LICENSE +21 -0
  2. pyoptik-0.7.11/MANIFEST.in +19 -0
  3. pyoptik-0.7.11/PKG-INFO +105 -0
  4. pyoptik-0.7.11/PyOptik/VERSION +1 -0
  5. pyoptik-0.7.11/PyOptik/__init__.py +40 -0
  6. pyoptik-0.7.11/PyOptik/__pycache__/__init__.cpython-310.pyc +0 -0
  7. pyoptik-0.7.11/PyOptik/__pycache__/experiment_material.cpython-310.pyc +0 -0
  8. pyoptik-0.7.11/PyOptik/__pycache__/sellmeier_material.cpython-310.pyc +0 -0
  9. pyoptik-0.7.11/PyOptik/directories.py +47 -0
  10. pyoptik-0.7.11/PyOptik/experiment_material.py +112 -0
  11. pyoptik-0.7.11/PyOptik/sellmeier_material.py +118 -0
  12. pyoptik-0.7.11/PyOptik.egg-info/PKG-INFO +105 -0
  13. pyoptik-0.7.11/PyOptik.egg-info/SOURCES.txt +35 -0
  14. pyoptik-0.7.11/PyOptik.egg-info/dependency_links.txt +1 -0
  15. pyoptik-0.7.11/PyOptik.egg-info/requires.txt +25 -0
  16. pyoptik-0.7.11/PyOptik.egg-info/top_level.txt +3 -0
  17. pyoptik-0.7.11/README.rst +57 -0
  18. pyoptik-0.7.11/docs/examples/measurements_tio2.py +23 -0
  19. pyoptik-0.7.11/docs/examples/measurements_water.py +23 -0
  20. pyoptik-0.7.11/docs/examples/sellmeier_bk7.py +23 -0
  21. pyoptik-0.7.11/docs/examples/sellmeier_sf5.py +23 -0
  22. pyoptik-0.7.11/docs/examples/sellmeier_silica.py +23 -0
  23. pyoptik-0.7.11/docs/source/conf.py +168 -0
  24. pyoptik-0.7.11/docs/source/gallery/add_material.py +16 -0
  25. pyoptik-0.7.11/docs/source/gallery/get_values.py +14 -0
  26. pyoptik-0.7.11/docs/source/gallery/plot_sellmeier_0.py +19 -0
  27. pyoptik-0.7.11/docs/source/gallery/plot_sellmeier_1.py +19 -0
  28. pyoptik-0.7.11/pyproject.toml +10 -0
  29. pyoptik-0.7.11/setup.cfg +84 -0
  30. pyoptik-0.7.11/setup.py +6 -0
  31. pyoptik-0.7.11/tests/__init__.py +0 -0
  32. pyoptik-0.7.11/tests/__pycache__/__init__.cpython-310.pyc +0 -0
  33. pyoptik-0.7.11/tests/__pycache__/test_measurements.cpython-310.pyc +0 -0
  34. pyoptik-0.7.11/tests/__pycache__/test_sellmeier.cpython-310.pyc +0 -0
  35. pyoptik-0.7.11/tests/test_measurements.py +22 -0
  36. pyoptik-0.7.11/tests/test_sellmeier.py +23 -0
pyoptik-0.7.11/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Martin de Sivry
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,19 @@
1
+ graft PyOptik
2
+
3
+ include MANIFEST.in
4
+ include LICENSE
5
+ include README.rst
6
+ include setup.py
7
+ include setup.cfg
8
+ include pyproject.toml
9
+ graft tests
10
+
11
+ global-exclude __pycache__
12
+ global-exclude .DS_Store
13
+
14
+ exclude *.ipynb
15
+ exclude *.txt
16
+ exclude *.yaml
17
+ exclude *.yml
18
+
19
+ exclude .git*
@@ -0,0 +1,105 @@
1
+ Metadata-Version: 2.1
2
+ Name: PyOptik
3
+ Version: 0.7.11
4
+ Summary: A package/library for refractive index values.
5
+ Home-page: https://github.com/MartinPdeS/PyOptik
6
+ Author: Martin Poinsinet de Sivry
7
+ Author-email: Martin.poinsinet.de.sivry@gmail.com
8
+ License: MIT
9
+ Keywords: refractive index
10
+ Platform: unix
11
+ Platform: linux
12
+ Platform: osx
13
+ Classifier: Programming Language :: Python
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: Implementation :: CPython
19
+ Classifier: Development Status :: 4 - Beta
20
+ Classifier: Topic :: Scientific/Engineering :: Physics
21
+ Classifier: License :: OSI Approved :: MIT License
22
+ Classifier: Intended Audience :: Science/Research
23
+ Description-Content-Type: text/x-rst
24
+ License-File: LICENSE
25
+ Requires-Dist: pydantic==2.6.3
26
+ Requires-Dist: matplotlib==3.8.2
27
+ Requires-Dist: numpy>=1.26.0
28
+ Requires-Dist: requests==2.31.0
29
+ Requires-Dist: pandas==2.1.1
30
+ Requires-Dist: bs4==0.0.1
31
+ Requires-Dist: MPSTools==0.2.3
32
+ Requires-Dist: MPSPlots>=1.4.2
33
+ Provides-Extra: documentation
34
+ Requires-Dist: numpydoc==1.6.0; extra == "documentation"
35
+ Requires-Dist: sphinx>=5.1.1; extra == "documentation"
36
+ Requires-Dist: sphinx-gallery==0.15.0; extra == "documentation"
37
+ Requires-Dist: sphinx-rtd-theme==2.0.0; extra == "documentation"
38
+ Requires-Dist: pydata-sphinx-theme==0.14.1; extra == "documentation"
39
+ Provides-Extra: testing
40
+ Requires-Dist: pytest>=0.6; extra == "testing"
41
+ Requires-Dist: pytest-cov>=2.0; extra == "testing"
42
+ Requires-Dist: pytest-json-report==1.5.0; extra == "testing"
43
+ Requires-Dist: mypy>=0.910; extra == "testing"
44
+ Requires-Dist: flake8>=3.9; extra == "testing"
45
+ Requires-Dist: tox>=3.24; extra == "testing"
46
+ Requires-Dist: coverage==6.5.0; extra == "testing"
47
+ Requires-Dist: PyMieScatt==1.8.1.1; extra == "testing"
48
+
49
+ |Logo|
50
+
51
+ |python|
52
+ |docs|
53
+ |unittest|
54
+ |PyPi|
55
+ |PyPi_download|
56
+
57
+ PyOptik
58
+ =======
59
+
60
+
61
+
62
+ PyOptik is a tool that can be used to import refractive indexes and extinction
63
+ coefficients for different materials at different wavelengths. This data can then
64
+ be used for different applications like simulating light interaction's with
65
+ particules. All the data comes from RefractiveIndex.INFO.
66
+
67
+ Testing
68
+ *******
69
+
70
+ To test localy (with cloning the GitHub repository) you'll need to install the dependencies and run the coverage command as
71
+
72
+ .. code:: python
73
+
74
+ >>> git clone https://github.com/MartinPdeS/PyOptik.git
75
+ >>> cd TradeTide
76
+ >>> pip install -r requirements/requirements.txt
77
+ >>> pytest
78
+
79
+ ----
80
+
81
+
82
+ Contact Information
83
+ ************************
84
+ As of 2024, the project is still under development. If you want to collaborate, it would be a pleasure! I encourage you to contact me.
85
+
86
+ PyOptik was written by `Martin Poinsinet de Sivry-Houle <https://github.com/MartinPdS>`_ .
87
+
88
+ Email:`martin.poinsinet-de-sivry@polymtl.ca <mailto:martin.poinsinet-de-sivry@polymtl.ca?subject=PyOptik>`_ .
89
+
90
+
91
+ .. |python| image:: https://img.shields.io/pypi/pyversions/pyoptik.svg
92
+ :target: https://www.python.org/
93
+
94
+ .. |Logo| image:: https://github.com/MartinPdeS/PyOptik/raw/master/docs/images/logo.png
95
+
96
+ .. |docs| image:: https://readthedocs.org/projects/pyoptik/badge/?version=latest
97
+ :target: https://pyoptik.readthedocs.io/en/latest/
98
+
99
+ .. |PyPi| image:: https://badge.fury.io/py/pyoptik.svg
100
+ :target: https://badge.fury.io/py/pyoptik
101
+
102
+ .. |PyPi_download| image:: https://img.shields.io/pypi/dm/pyoptik.svg
103
+ :target: https://pypistats.org/packages/pyoptik
104
+
105
+ .. |unittest| image:: https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/MartinPdeS/8fa5a7d93dc020b1f624012220f6ebbd/raw/15873eb6e38185c878026b9474148b8daab96b2e/PyOptik_coverage_badge.json
@@ -0,0 +1 @@
1
+ 0.7.11
@@ -0,0 +1,40 @@
1
+ from PyOptik.experiment_material import DataMeasurement
2
+ from PyOptik.sellmeier_material import Sellmeier
3
+ import numpy
4
+ import pandas
5
+
6
+
7
+ class UsualMaterial:
8
+ BK7 = Sellmeier('BK7')
9
+ FusedSilica = Sellmeier('silica')
10
+ SodaLimeGlass = DataMeasurement('sodalimeglass')
11
+ Silver = DataMeasurement('silver')
12
+ Gold = DataMeasurement('gold')
13
+ Aluminium = DataMeasurement('aluminium')
14
+ SI = Sellmeier('silica')
15
+ SIO2 = DataMeasurement('sio2')
16
+ TIO2 = DataMeasurement('tio2')
17
+ Polystyrene = DataMeasurement('polystyrene')
18
+ Water = DataMeasurement('water')
19
+ Ethanol = DataMeasurement('ethanol')
20
+
21
+ @classmethod
22
+ def get_from_string(cls, material_str):
23
+ material_str = numpy.atleast_1d(material_str)
24
+
25
+ material_str = [
26
+ mat for mat in material_str if not pandas.isnull(mat)
27
+ ]
28
+
29
+ values = [
30
+ getattr(cls, string) for string in material_str
31
+ ]
32
+
33
+ values = numpy.asarray(values)
34
+
35
+ if values.size == 0:
36
+ return numpy.nan
37
+
38
+ return values
39
+
40
+ # -
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ import os
5
+ from pathlib import Path
6
+ import PyOptik
7
+
8
+
9
+ __all__ = [
10
+ 'root_path',
11
+ 'project_path',
12
+ 'doc_path',
13
+ 'doc_css_path',
14
+ 'logo_path',
15
+ 'version_path',
16
+ ]
17
+
18
+ root_path = Path(PyOptik.__path__[0])
19
+
20
+ project_path = root_path.parents[0]
21
+
22
+ example_directory = root_path.joinpath('examples')
23
+
24
+ doc_path = project_path.joinpath('docs')
25
+
26
+ doc_css_path = doc_path.joinpath('source/_static/default.css')
27
+
28
+ logo_path = doc_path.joinpath('images/logo.png')
29
+
30
+ version_path = root_path.joinpath('VERSION')
31
+
32
+ examples_path = root_path.joinpath('examples')
33
+
34
+ ZeroPath = os.path.dirname(root_path)
35
+
36
+ DataPath = os.path.join(root_path, 'Data')
37
+
38
+ NPZPath = os.path.join(DataPath, 'npz')
39
+
40
+
41
+ if __name__ == '__main__':
42
+ for path_name in __all__:
43
+ path = locals()[path_name]
44
+ print(path)
45
+ assert path.exists(), f"Path {path_name} do not exists"
46
+
47
+ # -
@@ -0,0 +1,112 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ import os
5
+ from typing import Union, Iterable
6
+ from MPSTools.material_catalogue.loader import get_material_index
7
+ from MPSPlots.render2D import SceneList
8
+
9
+ from MPSTools.tools.directories import measurements_file_path
10
+ from pydantic.dataclasses import dataclass
11
+
12
+
13
+ def valid_name(string):
14
+ return not string.startswith('_')
15
+
16
+
17
+ list_of_available_files = os.listdir(measurements_file_path)
18
+
19
+ material_list = [element[:-5] for element in list_of_available_files]
20
+
21
+ material_list = list(filter(valid_name, material_list))
22
+
23
+
24
+ @dataclass
25
+ class DataMeasurement():
26
+ """
27
+ A class for computing the refractive index using locally saved measurement data for specified materials.
28
+
29
+ Attributes:
30
+ material_name (str): The name of the material.
31
+
32
+ Methods:
33
+ reference (str): Returns the bibliographic reference for the material's data.
34
+ get_refractive_index: Computes the refractive index for given wavelength(s).
35
+ plot: Visualizes the refractive index as a function of wavelength.
36
+ """
37
+
38
+ material_name: str
39
+
40
+ def __post_init__(self):
41
+ """
42
+ Initializes the DataMeasurement object with a specified material name.
43
+
44
+ Parameters:
45
+ material_name (str): The name of the material for which to compute the refractive index.
46
+ """
47
+ if self.material_name not in material_list:
48
+ raise ValueError(f"{self.material_name} is not in the list of available materials.")
49
+
50
+ @property
51
+ def reference(self) -> str:
52
+ """
53
+ Retrieves the bibliographic reference for the material's data.
54
+
55
+ Returns:
56
+ str: The bibliographic reference for the material's measurement data.
57
+ """
58
+ raise NotImplementedError("Feature not implemented yet.")
59
+
60
+ def get_refractive_index(self, wavelength_range: Union[float, Iterable]) -> Union[float, Iterable]:
61
+ """
62
+ Computes the refractive index for the specified wavelength range using the material's measurement data.
63
+
64
+ Parameters:
65
+ wavelength_range (Union[float, Iterable]): The wavelength(s) in meters.
66
+
67
+ Returns:
68
+ Union[float, Iterable]: The refractive index or indices for the specified wavelength(s).
69
+ """
70
+ return get_material_index(
71
+ material_name=self.material_name,
72
+ wavelength=wavelength_range,
73
+ subdir='measurements'
74
+ )
75
+
76
+ def plot(self, wavelength_range: Iterable) -> SceneList:
77
+ """
78
+ Generates a plot of the refractive index as a function of wavelength for the specified material.
79
+
80
+ Parameters:
81
+ wavelength_range (Iterable): The range of wavelengths to plot.
82
+
83
+ Returns:
84
+ SceneList: An object containing the plot of refractive index against wavelength.
85
+ """
86
+ scene = SceneList()
87
+ ax = scene.append_ax(x_label='Wavelength [m]', y_label='Refractive index')
88
+
89
+ refractive_index = self.get_refractive_index(wavelength_range)
90
+ ax.add_line(x=wavelength_range, y=refractive_index, line_width=2)
91
+
92
+ return scene
93
+
94
+ def __repr__(self) -> str:
95
+ """
96
+ Provides a formal string representation of the DataMeasurement object.
97
+
98
+ Returns:
99
+ str: Formal representation of the object, showing the material name.
100
+ """
101
+ return str(self.material_name)
102
+
103
+ def __str__(self) -> str:
104
+ """
105
+ Provides an informal string representation of the DataMeasurement object.
106
+
107
+ Returns:
108
+ str: Informal representation of the object.
109
+ """
110
+ return self.__repr__()
111
+
112
+ # -
@@ -0,0 +1,118 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ import os
5
+ import numpy as np
6
+ from typing import Union, Iterable
7
+ from MPSTools.material_catalogue.loader import get_material_index
8
+ from MPSPlots.render2D import SceneList
9
+ from MPSTools.tools.directories import sellmeier_file_path
10
+ from pydantic.dataclasses import dataclass
11
+
12
+
13
+ def valid_name(string):
14
+ return not string.startswith('_')
15
+
16
+
17
+ list_of_available_files = os.listdir(sellmeier_file_path)
18
+
19
+ material_list = [element[:-5] for element in list_of_available_files]
20
+
21
+ material_list = list(filter(valid_name, material_list))
22
+
23
+
24
+ @dataclass
25
+ class Sellmeier():
26
+ """
27
+ A class for computing the refractive index using the Sellmeier equation based on locally stored Sellmeier coefficients.
28
+
29
+ Attributes:
30
+ material_name (str): Name of the material.
31
+ sellmeier_coefficients (dict): Sellmeier coefficients for the material loaded from a local source.
32
+
33
+ Methods:
34
+ reference: Returns the reference for the Sellmeier coefficients.
35
+ get_refractive_index: Computes the refractive index for given wavelengths.
36
+ plot: Plots the refractive index as a function of the wavelength.
37
+ """
38
+ material_name: str
39
+
40
+ def __post_init__(self):
41
+ """
42
+ Initializes the DataMeasurement object with a specified material name.
43
+
44
+ Parameters:
45
+ material_name (str): The name of the material for which to compute the refractive index.
46
+ """
47
+ if self.material_name not in material_list:
48
+ raise ValueError(f"{self.material_name} is not in the list of available materials.")
49
+
50
+ @property
51
+ def reference(self) -> str:
52
+ """
53
+ Returns the bibliographic reference for the Sellmeier coefficients.
54
+
55
+ Returns:
56
+ str: The bibliographic reference.
57
+ """
58
+ return self.sellmeier_coefficients['sellmeier']['reference']
59
+
60
+ def get_refractive_index(self, wavelength_range: Union[float, Iterable]) -> Union[float, np.ndarray]:
61
+ """
62
+ Computes the refractive index for the specified wavelength(s) using the Sellmeier equation.
63
+
64
+ Parameters:
65
+ wavelength_range (Union[float, Iterable]): The wavelength(s) in meters for which to compute the refractive index.
66
+
67
+ Returns:
68
+ Union[float, np.ndarray]: The computed refractive index, either as a scalar or a NumPy array.
69
+ """
70
+ return_scalar = np.isscalar(wavelength_range)
71
+ wavelength_array = np.atleast_1d(wavelength_range).astype(float)
72
+
73
+ refractive_index = get_material_index(
74
+ material_name=self.material_name,
75
+ wavelength=wavelength_array,
76
+ subdir='sellmeier'
77
+ )
78
+
79
+ return refractive_index.item() if return_scalar else refractive_index
80
+
81
+ def plot(self, wavelength_range: Iterable) -> SceneList:
82
+ """
83
+ Plots the refractive index as a function of wavelength over a specified range.
84
+
85
+ Parameters:
86
+ wavelength_range (Iterable): The range of wavelengths to plot, in meters.
87
+
88
+ Returns:
89
+ SceneList: A SceneList object containing the plot.
90
+ """
91
+ scene = SceneList()
92
+ ax = scene.append_ax(x_label='Wavelength [m]', y_label='Refractive index')
93
+
94
+ refractive_index = self.get_refractive_index(wavelength_range)
95
+
96
+ ax.add_line(x=wavelength_range, y=refractive_index, line_width=2)
97
+
98
+ return scene
99
+
100
+ def __repr__(self) -> str:
101
+ """
102
+ Provides a formal string representation of the DataMeasurement object.
103
+
104
+ Returns:
105
+ str: Formal representation of the object, showing the material name.
106
+ """
107
+ return str(self.material_name)
108
+
109
+ def __str__(self) -> str:
110
+ """
111
+ Provides an informal string representation of the DataMeasurement object.
112
+
113
+ Returns:
114
+ str: Informal representation of the object.
115
+ """
116
+ return self.__repr__()
117
+
118
+ # -
@@ -0,0 +1,105 @@
1
+ Metadata-Version: 2.1
2
+ Name: PyOptik
3
+ Version: 0.7.11
4
+ Summary: A package/library for refractive index values.
5
+ Home-page: https://github.com/MartinPdeS/PyOptik
6
+ Author: Martin Poinsinet de Sivry
7
+ Author-email: Martin.poinsinet.de.sivry@gmail.com
8
+ License: MIT
9
+ Keywords: refractive index
10
+ Platform: unix
11
+ Platform: linux
12
+ Platform: osx
13
+ Classifier: Programming Language :: Python
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: Implementation :: CPython
19
+ Classifier: Development Status :: 4 - Beta
20
+ Classifier: Topic :: Scientific/Engineering :: Physics
21
+ Classifier: License :: OSI Approved :: MIT License
22
+ Classifier: Intended Audience :: Science/Research
23
+ Description-Content-Type: text/x-rst
24
+ License-File: LICENSE
25
+ Requires-Dist: pydantic==2.6.3
26
+ Requires-Dist: matplotlib==3.8.2
27
+ Requires-Dist: numpy>=1.26.0
28
+ Requires-Dist: requests==2.31.0
29
+ Requires-Dist: pandas==2.1.1
30
+ Requires-Dist: bs4==0.0.1
31
+ Requires-Dist: MPSTools==0.2.3
32
+ Requires-Dist: MPSPlots>=1.4.2
33
+ Provides-Extra: documentation
34
+ Requires-Dist: numpydoc==1.6.0; extra == "documentation"
35
+ Requires-Dist: sphinx>=5.1.1; extra == "documentation"
36
+ Requires-Dist: sphinx-gallery==0.15.0; extra == "documentation"
37
+ Requires-Dist: sphinx-rtd-theme==2.0.0; extra == "documentation"
38
+ Requires-Dist: pydata-sphinx-theme==0.14.1; extra == "documentation"
39
+ Provides-Extra: testing
40
+ Requires-Dist: pytest>=0.6; extra == "testing"
41
+ Requires-Dist: pytest-cov>=2.0; extra == "testing"
42
+ Requires-Dist: pytest-json-report==1.5.0; extra == "testing"
43
+ Requires-Dist: mypy>=0.910; extra == "testing"
44
+ Requires-Dist: flake8>=3.9; extra == "testing"
45
+ Requires-Dist: tox>=3.24; extra == "testing"
46
+ Requires-Dist: coverage==6.5.0; extra == "testing"
47
+ Requires-Dist: PyMieScatt==1.8.1.1; extra == "testing"
48
+
49
+ |Logo|
50
+
51
+ |python|
52
+ |docs|
53
+ |unittest|
54
+ |PyPi|
55
+ |PyPi_download|
56
+
57
+ PyOptik
58
+ =======
59
+
60
+
61
+
62
+ PyOptik is a tool that can be used to import refractive indexes and extinction
63
+ coefficients for different materials at different wavelengths. This data can then
64
+ be used for different applications like simulating light interaction's with
65
+ particules. All the data comes from RefractiveIndex.INFO.
66
+
67
+ Testing
68
+ *******
69
+
70
+ To test localy (with cloning the GitHub repository) you'll need to install the dependencies and run the coverage command as
71
+
72
+ .. code:: python
73
+
74
+ >>> git clone https://github.com/MartinPdeS/PyOptik.git
75
+ >>> cd TradeTide
76
+ >>> pip install -r requirements/requirements.txt
77
+ >>> pytest
78
+
79
+ ----
80
+
81
+
82
+ Contact Information
83
+ ************************
84
+ As of 2024, the project is still under development. If you want to collaborate, it would be a pleasure! I encourage you to contact me.
85
+
86
+ PyOptik was written by `Martin Poinsinet de Sivry-Houle <https://github.com/MartinPdS>`_ .
87
+
88
+ Email:`martin.poinsinet-de-sivry@polymtl.ca <mailto:martin.poinsinet-de-sivry@polymtl.ca?subject=PyOptik>`_ .
89
+
90
+
91
+ .. |python| image:: https://img.shields.io/pypi/pyversions/pyoptik.svg
92
+ :target: https://www.python.org/
93
+
94
+ .. |Logo| image:: https://github.com/MartinPdeS/PyOptik/raw/master/docs/images/logo.png
95
+
96
+ .. |docs| image:: https://readthedocs.org/projects/pyoptik/badge/?version=latest
97
+ :target: https://pyoptik.readthedocs.io/en/latest/
98
+
99
+ .. |PyPi| image:: https://badge.fury.io/py/pyoptik.svg
100
+ :target: https://badge.fury.io/py/pyoptik
101
+
102
+ .. |PyPi_download| image:: https://img.shields.io/pypi/dm/pyoptik.svg
103
+ :target: https://pypistats.org/packages/pyoptik
104
+
105
+ .. |unittest| image:: https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/MartinPdeS/8fa5a7d93dc020b1f624012220f6ebbd/raw/15873eb6e38185c878026b9474148b8daab96b2e/PyOptik_coverage_badge.json
@@ -0,0 +1,35 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.rst
4
+ pyproject.toml
5
+ setup.cfg
6
+ setup.py
7
+ PyOptik/VERSION
8
+ PyOptik/__init__.py
9
+ PyOptik/directories.py
10
+ PyOptik/experiment_material.py
11
+ PyOptik/sellmeier_material.py
12
+ PyOptik.egg-info/PKG-INFO
13
+ PyOptik.egg-info/SOURCES.txt
14
+ PyOptik.egg-info/dependency_links.txt
15
+ PyOptik.egg-info/requires.txt
16
+ PyOptik.egg-info/top_level.txt
17
+ PyOptik/__pycache__/__init__.cpython-310.pyc
18
+ PyOptik/__pycache__/experiment_material.cpython-310.pyc
19
+ PyOptik/__pycache__/sellmeier_material.cpython-310.pyc
20
+ docs/examples/measurements_tio2.py
21
+ docs/examples/measurements_water.py
22
+ docs/examples/sellmeier_bk7.py
23
+ docs/examples/sellmeier_sf5.py
24
+ docs/examples/sellmeier_silica.py
25
+ docs/source/conf.py
26
+ docs/source/gallery/add_material.py
27
+ docs/source/gallery/get_values.py
28
+ docs/source/gallery/plot_sellmeier_0.py
29
+ docs/source/gallery/plot_sellmeier_1.py
30
+ tests/__init__.py
31
+ tests/test_measurements.py
32
+ tests/test_sellmeier.py
33
+ tests/__pycache__/__init__.cpython-310.pyc
34
+ tests/__pycache__/test_measurements.cpython-310.pyc
35
+ tests/__pycache__/test_sellmeier.cpython-310.pyc
@@ -0,0 +1,25 @@
1
+ pydantic==2.6.3
2
+ matplotlib==3.8.2
3
+ numpy>=1.26.0
4
+ requests==2.31.0
5
+ pandas==2.1.1
6
+ bs4==0.0.1
7
+ MPSTools==0.2.3
8
+ MPSPlots>=1.4.2
9
+
10
+ [documentation]
11
+ numpydoc==1.6.0
12
+ sphinx>=5.1.1
13
+ sphinx-gallery==0.15.0
14
+ sphinx-rtd-theme==2.0.0
15
+ pydata-sphinx-theme==0.14.1
16
+
17
+ [testing]
18
+ pytest>=0.6
19
+ pytest-cov>=2.0
20
+ pytest-json-report==1.5.0
21
+ mypy>=0.910
22
+ flake8>=3.9
23
+ tox>=3.24
24
+ coverage==6.5.0
25
+ PyMieScatt==1.8.1.1
@@ -0,0 +1,3 @@
1
+ PyOptik
2
+ dist
3
+ docs
@@ -0,0 +1,57 @@
1
+ |Logo|
2
+
3
+ |python|
4
+ |docs|
5
+ |unittest|
6
+ |PyPi|
7
+ |PyPi_download|
8
+
9
+ PyOptik
10
+ =======
11
+
12
+
13
+
14
+ PyOptik is a tool that can be used to import refractive indexes and extinction
15
+ coefficients for different materials at different wavelengths. This data can then
16
+ be used for different applications like simulating light interaction's with
17
+ particules. All the data comes from RefractiveIndex.INFO.
18
+
19
+ Testing
20
+ *******
21
+
22
+ To test localy (with cloning the GitHub repository) you'll need to install the dependencies and run the coverage command as
23
+
24
+ .. code:: python
25
+
26
+ >>> git clone https://github.com/MartinPdeS/PyOptik.git
27
+ >>> cd TradeTide
28
+ >>> pip install -r requirements/requirements.txt
29
+ >>> pytest
30
+
31
+ ----
32
+
33
+
34
+ Contact Information
35
+ ************************
36
+ As of 2024, the project is still under development. If you want to collaborate, it would be a pleasure! I encourage you to contact me.
37
+
38
+ PyOptik was written by `Martin Poinsinet de Sivry-Houle <https://github.com/MartinPdS>`_ .
39
+
40
+ Email:`martin.poinsinet-de-sivry@polymtl.ca <mailto:martin.poinsinet-de-sivry@polymtl.ca?subject=PyOptik>`_ .
41
+
42
+
43
+ .. |python| image:: https://img.shields.io/pypi/pyversions/pyoptik.svg
44
+ :target: https://www.python.org/
45
+
46
+ .. |Logo| image:: https://github.com/MartinPdeS/PyOptik/raw/master/docs/images/logo.png
47
+
48
+ .. |docs| image:: https://readthedocs.org/projects/pyoptik/badge/?version=latest
49
+ :target: https://pyoptik.readthedocs.io/en/latest/
50
+
51
+ .. |PyPi| image:: https://badge.fury.io/py/pyoptik.svg
52
+ :target: https://badge.fury.io/py/pyoptik
53
+
54
+ .. |PyPi_download| image:: https://img.shields.io/pypi/dm/pyoptik.svg
55
+ :target: https://pypistats.org/packages/pyoptik
56
+
57
+ .. |unittest| image:: https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/MartinPdeS/8fa5a7d93dc020b1f624012220f6ebbd/raw/15873eb6e38185c878026b9474148b8daab96b2e/PyOptik_coverage_badge.json
@@ -0,0 +1,23 @@
1
+ """
2
+ Plot the Refractive Index of Optical Material: Ti02
3
+ ===================================================
4
+
5
+ This module demonstrates the usage of the PyOptik library to calculate and plot the refractive index of the optical material SF5 over a specified range of wavelengths.
6
+
7
+ """
8
+
9
+ import numpy
10
+ from PyOptik import DataMeasurement
11
+
12
+ # Initialize the material with the Sellmeier model
13
+ material = DataMeasurement('tio2')
14
+
15
+ # Calculate refractive index at specific wavelengths
16
+ RI = material.get_refractive_index(wavelength_range=[1310e-9, 1550e-9])
17
+
18
+ # Display calculated refractive indices at sample wavelengths
19
+ figure = material.plot(
20
+ wavelength_range=numpy.linspace(10e-9, 3500e-9, 300)
21
+ )
22
+
23
+ figure.show()
@@ -0,0 +1,23 @@
1
+ """
2
+ Plot the Refractive Index of Optical Material: Water
3
+ ====================================================
4
+
5
+ This module demonstrates the usage of the PyOptik library to calculate and plot the refractive index of the optical material SF5 over a specified range of wavelengths.
6
+
7
+ """
8
+
9
+ import numpy
10
+ from PyOptik import DataMeasurement
11
+
12
+ # Initialize the material with the Sellmeier model
13
+ material = DataMeasurement('water')
14
+
15
+ # Calculate refractive index at specific wavelengths
16
+ RI = material.get_refractive_index(wavelength_range=[1310e-9, 1550e-9])
17
+
18
+ # Display calculated refractive indices at sample wavelengths
19
+ figure = material.plot(
20
+ wavelength_range=numpy.linspace(300e-9, 3500e-9, 300)
21
+ )
22
+
23
+ figure.show()
@@ -0,0 +1,23 @@
1
+ """
2
+ Plot the Refractive Index of Optical Material: BK7
3
+ =====================================================
4
+
5
+ This module demonstrates the usage of the PyOptik library to calculate and plot the refractive index of the optical material SF5 over a specified range of wavelengths.
6
+
7
+ """
8
+
9
+ import numpy
10
+ from PyOptik import Sellmeier
11
+
12
+ # Initialize the material with the Sellmeier model
13
+ material = Sellmeier('BK7')
14
+
15
+ # Calculate refractive index at specific wavelengths
16
+ RI = material.get_refractive_index(wavelength_range=[1310e-9, 1550e-9])
17
+
18
+ # Display calculated refractive indices at sample wavelengths
19
+ figure = material.plot(
20
+ wavelength_range=numpy.linspace(300e-9, 3500e-9, 300)
21
+ )
22
+
23
+ figure.show()
@@ -0,0 +1,23 @@
1
+ """
2
+ Plot the Refractive Index of Optical Material: SF5
3
+ ==================================================
4
+
5
+ This module demonstrates the usage of the PyOptik library to calculate and plot the refractive index of the optical material SF5 over a specified range of wavelengths.
6
+
7
+ """
8
+
9
+ import numpy
10
+ from PyOptik import Sellmeier
11
+
12
+ # Initialize the material with the Sellmeier model
13
+ material = Sellmeier('SF5')
14
+
15
+ # Calculate refractive index at specific wavelengths
16
+ RI = material.get_refractive_index(wavelength_range=[1310e-9, 1550e-9])
17
+
18
+ # Display calculated refractive indices at sample wavelengths
19
+ figure = material.plot(
20
+ wavelength_range=numpy.linspace(300e-9, 3500e-9, 300)
21
+ )
22
+
23
+ figure.show()
@@ -0,0 +1,23 @@
1
+ """
2
+ Plot the Refractive Index of Optical Material: Silica
3
+ =====================================================
4
+
5
+ This module demonstrates the usage of the PyOptik library to calculate and plot the refractive index of the optical material SF5 over a specified range of wavelengths.
6
+
7
+ """
8
+
9
+ import numpy
10
+ from PyOptik import Sellmeier
11
+
12
+ # Initialize the material with the Sellmeier model
13
+ material = Sellmeier('silica')
14
+
15
+ # Calculate refractive index at specific wavelengths
16
+ RI = material.get_refractive_index(wavelength_range=[1310e-9, 1550e-9])
17
+
18
+ # Display calculated refractive indices at sample wavelengths
19
+ figure = material.plot(
20
+ wavelength_range=numpy.linspace(300e-9, 3500e-9, 300)
21
+ )
22
+
23
+ figure.show()
@@ -0,0 +1,168 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ import sys
5
+ from sphinx_gallery.sorting import FileNameSortKey
6
+ from packaging.version import parse
7
+ from MPSPlots.styles import use_mpsplots_style
8
+
9
+
10
+ from PyOptik.directories import (
11
+ project_path,
12
+ doc_css_path,
13
+ version_path,
14
+ )
15
+
16
+
17
+ sys.path.insert(0, project_path)
18
+ sys.path.insert(0, project_path.joinpath('PyOptik'))
19
+
20
+
21
+ def setup(app):
22
+ app.add_css_file(str(doc_css_path))
23
+
24
+
25
+ autodoc_mock_imports = [
26
+ 'numpy',
27
+ 'matplotlib',
28
+ 'scipy'
29
+ 'numpydoc',
30
+ 'MPSPlots',
31
+ ]
32
+
33
+
34
+ project = 'PyOptik'
35
+ copyright = '2024, Martin Poinsinet de Sivry-Houle'
36
+ author = 'Martin Poinsinet de Sivry-Houle'
37
+
38
+
39
+ with open(version_path, "r+") as f:
40
+ version = release = f.read()
41
+
42
+
43
+ extensions = [
44
+ 'sphinx.ext.mathjax',
45
+ 'numpydoc',
46
+ 'sphinx_gallery.gen_gallery',
47
+ ]
48
+
49
+
50
+ def reset_mpl(gallery_conf, fname):
51
+ use_mpsplots_style()
52
+
53
+
54
+ sphinx_gallery_conf = {
55
+ 'examples_dirs': '../examples',
56
+ 'gallery_dirs': 'gallery',
57
+ 'image_scrapers': ('matplotlib'),
58
+ 'ignore_pattern': '/__',
59
+ 'plot_gallery': True,
60
+ 'thumbnail_size': [600, 600],
61
+ 'download_all_examples': False,
62
+ 'reset_modules': reset_mpl,
63
+ 'line_numbers': False,
64
+ 'remove_config_comments': True,
65
+ 'within_subsection_order': FileNameSortKey,
66
+ 'capture_repr': ('_repr_html_', '__repr__'),
67
+ 'nested_sections': True,
68
+ }
69
+
70
+
71
+ autodoc_default_options = {
72
+ 'members': False,
73
+ 'members-order': 'bysource',
74
+ 'undoc-members': False,
75
+ 'show-inheritance': True,
76
+ }
77
+
78
+ numpydoc_show_class_members = False
79
+
80
+ source_suffix = '.rst'
81
+
82
+ master_doc = 'index'
83
+
84
+ language = 'en'
85
+
86
+ highlight_language = 'python3'
87
+
88
+ html_theme = "pydata_sphinx_theme"
89
+
90
+ # -- Options for HTML output -------------------------------------------------
91
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
92
+
93
+ exclude_trees = []
94
+ default_role = "autolink"
95
+ pygments_style = "sphinx"
96
+
97
+ # -- Sphinx-gallery configuration --------------------------------------------
98
+
99
+ v = parse(release)
100
+ if v.release is None:
101
+ raise ValueError(f"Ill-formed version: {version!r}. Version should follow PEP440")
102
+
103
+ if v.is_devrelease:
104
+ binder_branch = "main"
105
+ else:
106
+ major, minor = v.release[:2]
107
+ binder_branch = f"v{major}.{minor}.x"
108
+
109
+ html_theme_options = {
110
+ # Navigation bar
111
+ "logo": {
112
+ "alt_text": "PyOptik's logo",
113
+ "text": "PyOptik",
114
+ "link": "https://pyoptik.readthedocs.io/en/latest/",
115
+ },
116
+ "icon_links": [
117
+ {
118
+ "name": "GitHub",
119
+ "url": "https://github.com/MartinPdeS/PyOptik",
120
+ "icon": "fa-brands fa-github",
121
+ },
122
+ {
123
+ "name": "PyPI",
124
+ "url": "https://pypi.org/project/pyoptik/",
125
+ "icon": "fa-solid fa-box",
126
+ },
127
+ ],
128
+ "navbar_align": "left",
129
+ "navbar_end": ["version-switcher", "navbar-icon-links"],
130
+ "show_prev_next": False,
131
+ "show_version_warning_banner": True,
132
+ # Footer
133
+ "footer_start": ["copyright"],
134
+ "footer_end": ["sphinx-version", "theme-version"],
135
+ # Other
136
+ "pygment_light_style": "default",
137
+ "pygment_dark_style": "github-dark",
138
+ }
139
+
140
+ htmlhelp_basename = 'PyOptikdoc'
141
+
142
+ latex_elements = {}
143
+
144
+
145
+ latex_documents = [
146
+ (master_doc, 'PyOptik.tex', 'PyOptik Documentation',
147
+ 'Martin Poinsinet de Sivry-Houle', 'manual'),
148
+ ]
149
+
150
+ man_pages = [
151
+ (master_doc, 'supymode', 'PyOptik Documentation',
152
+ [author], 1)
153
+ ]
154
+
155
+ texinfo_documents = [
156
+ (master_doc, 'PyOptik', 'PyOptik Documentation',
157
+ author, 'PyOptik', 'One line description of project.',
158
+ 'Miscellaneous'),
159
+ ]
160
+
161
+ epub_title = project
162
+
163
+ html_static_path = ['_static']
164
+ templates_path = ['_templates']
165
+ html_css_files = ['default.css']
166
+ epub_exclude_files = ['search.html']
167
+
168
+ # -
@@ -0,0 +1,16 @@
1
+ """
2
+ Add hoc docstring
3
+ =================
4
+
5
+ """
6
+
7
+ from PyOptik import DataBank
8
+ from PyOptik.ExpData import SaveData
9
+
10
+ print(DataBank())
11
+
12
+ url = 'https://refractiveindex.info/data_csv.php?datafile=data/main/Si/Aspnes.yml'
13
+
14
+ SaveData(name='SI', url=url)
15
+
16
+ print(DataBank())
@@ -0,0 +1,14 @@
1
+ """
2
+ Add hoc docstring
3
+ =================
4
+
5
+ """
6
+
7
+ from PyOptik import DataBank, ExpData
8
+
9
+ print(DataBank())
10
+
11
+ dat = ExpData('BK7')
12
+
13
+ dat.GetRI([5e-7])
14
+
@@ -0,0 +1,19 @@
1
+ """
2
+ Plot refractive index of material: BK7
3
+ ======================================
4
+
5
+ """
6
+
7
+ import numpy
8
+ from PyOptik import Sellmeier
9
+
10
+
11
+ material = Sellmeier('BK7')
12
+
13
+ RI = material.get_refractive_index(wavelength=[1310e-9, 1550e-9])
14
+
15
+ figure = material.plot(
16
+ wavelength_range=numpy.linspace(300e-9, 3500e-9, 300)
17
+ )
18
+
19
+ figure.show()
@@ -0,0 +1,19 @@
1
+ """
2
+ Plot refractive index of material: Silica
3
+ =========================================
4
+
5
+ """
6
+
7
+ import numpy
8
+ from PyOptik import Sellmeier
9
+
10
+
11
+ material = Sellmeier('silica')
12
+
13
+ RI = material.get_refractive_index(wavelength=[1310e-9, 1550e-9])
14
+
15
+ figure = material.plot(
16
+ wavelength_range=numpy.linspace(300e-9, 3500e-9, 300)
17
+ )
18
+
19
+ figure.show()
@@ -0,0 +1,10 @@
1
+ [tool.pytest.ini_options]
2
+ addopts = [
3
+ "--import-mode=importlib",
4
+ '-v',
5
+ '-ra',
6
+ ]
7
+
8
+ testpaths = "tests"
9
+
10
+ minversion = 6.0
@@ -0,0 +1,84 @@
1
+ [metadata]
2
+ name = PyOptik
3
+ description = A package/library for refractive index values.
4
+ keywords =
5
+ refractive index
6
+ version = file: PyOptik/VERSION
7
+ long_description = file: README.rst
8
+ long_description_content_type = text/x-rst
9
+ author = Martin Poinsinet de Sivry
10
+ author_email = Martin.poinsinet.de.sivry@gmail.com
11
+ platforms = unix, linux, osx
12
+ url = https://github.com/MartinPdeS/PyOptik
13
+ license = MIT
14
+ license_files = LICENSE
15
+ readme = README.rst
16
+ documentation = https://pyoptik.readthedocs.io/
17
+ classifiers =
18
+ Programming Language :: Python
19
+ Programming Language :: Python :: 3
20
+ Programming Language :: Python :: 3.10
21
+ Programming Language :: Python :: 3.11
22
+ Programming Language :: Python :: 3.12
23
+ Programming Language :: Python :: Implementation :: CPython
24
+ Development Status :: 4 - Beta
25
+ Topic :: Scientific/Engineering :: Physics
26
+ License :: OSI Approved :: MIT License
27
+ Intended Audience :: Science/Research
28
+
29
+ [options]
30
+ packages = find_namespace:
31
+ include_package_data = True
32
+ python_requires > = 3.8
33
+ install_requires =
34
+ pydantic==2.6.3
35
+ matplotlib==3.8.2
36
+ numpy>=1.26.0
37
+ requests==2.31.0
38
+ pandas==2.1.1
39
+ bs4==0.0.1
40
+ MPSTools==0.2.3
41
+ MPSPlots>=1.4.2
42
+ setup_requires =
43
+ setuptools>=69.0.2
44
+
45
+ [options.packages.find]
46
+ exclude =
47
+ extern
48
+ docs
49
+ tests
50
+
51
+ [options.extras_require]
52
+ documentation =
53
+ numpydoc==1.6.0
54
+ sphinx>=5.1.1
55
+ sphinx-gallery==0.15.0
56
+ sphinx-rtd-theme==2.0.0
57
+ pydata-sphinx-theme==0.14.1
58
+ testing =
59
+ pytest>=0.6
60
+ pytest-cov>=2.0
61
+ pytest-json-report==1.5.0
62
+ mypy>=0.910
63
+ flake8>=3.9
64
+ tox>=3.24
65
+ coverage==6.5.0
66
+ PyMieScatt==1.8.1.1
67
+
68
+ [flake8]
69
+ max-line-length = 200
70
+ per-file-ignores = __init__.py:F401
71
+ ignore = W605
72
+
73
+ [coverage:run]
74
+ source = PyOptik
75
+ omit =
76
+ PyOptik/validation_data/*
77
+
78
+ [sdist]
79
+ formats = zip, gztar
80
+
81
+ [egg_info]
82
+ tag_build =
83
+ tag_date = 0
84
+
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ from setuptools import setup
5
+
6
+ setup()
File without changes
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ import numpy
5
+ from unittest.mock import patch
6
+ import pytest
7
+ from PyOptik import DataMeasurement
8
+ from PyOptik.experiment_material import material_list
9
+
10
+
11
+ @pytest.mark.parametrize('material_name', material_list, ids=material_list)
12
+ @patch("matplotlib.pyplot.show")
13
+ def test_material_plot(patch, material_name: str):
14
+ material = DataMeasurement(material_name)
15
+
16
+ wavelength_range = numpy.linspace(400e-9, 1000e-9, 30)
17
+
18
+ figure = material.plot(wavelength_range=wavelength_range)
19
+
20
+ figure.show()
21
+
22
+ # -
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ import numpy
5
+ from unittest.mock import patch
6
+ import pytest
7
+ from PyOptik import Sellmeier
8
+ from PyOptik.sellmeier_material import material_list
9
+
10
+
11
+ @pytest.mark.parametrize('material_name', material_list, ids=material_list)
12
+ @patch("matplotlib.pyplot.show")
13
+ def test_material_plot(patch, material_name: str):
14
+ material = Sellmeier(material_name)
15
+
16
+ wavelength_range = numpy.linspace(400e-9, 1000e-9, 30)
17
+
18
+ figure = material.plot(wavelength_range=wavelength_range)
19
+
20
+ figure.show()
21
+
22
+
23
+ # -