PyOptik 0.7.11__tar.gz → 0.7.16.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.
Files changed (75) hide show
  1. pyoptik-0.7.16.post0/.github/dependabot.yml +11 -0
  2. pyoptik-0.7.16.post0/.github/workflows/deploy_workflow.yml +53 -0
  3. pyoptik-0.7.16.post0/.gitignore +15 -0
  4. pyoptik-0.7.16.post0/.readthedocs.yml +35 -0
  5. {pyoptik-0.7.11 → pyoptik-0.7.16.post0}/PKG-INFO +38 -26
  6. {pyoptik-0.7.11 → pyoptik-0.7.16.post0}/PyOptik/__init__.py +7 -0
  7. pyoptik-0.7.16.post0/PyOptik/_version.py +16 -0
  8. {pyoptik-0.7.11 → pyoptik-0.7.16.post0}/PyOptik/directories.py +1 -11
  9. {pyoptik-0.7.11 → pyoptik-0.7.16.post0}/PyOptik/experiment_material.py +25 -27
  10. {pyoptik-0.7.11 → pyoptik-0.7.16.post0}/PyOptik/sellmeier_material.py +31 -30
  11. {pyoptik-0.7.11 → pyoptik-0.7.16.post0}/PyOptik.egg-info/PKG-INFO +38 -26
  12. pyoptik-0.7.16.post0/PyOptik.egg-info/SOURCES.txt +60 -0
  13. {pyoptik-0.7.11 → pyoptik-0.7.16.post0}/PyOptik.egg-info/requires.txt +5 -9
  14. pyoptik-0.7.16.post0/PyOptik.egg-info/top_level.txt +1 -0
  15. pyoptik-0.7.16.post0/docs/Makefile +19 -0
  16. pyoptik-0.7.16.post0/docs/examples/README.rst +6 -0
  17. pyoptik-0.7.16.post0/docs/images/logo.png +0 -0
  18. pyoptik-0.7.16.post0/docs/make.bat +35 -0
  19. pyoptik-0.7.16.post0/docs/source/_static/default.css +19 -0
  20. pyoptik-0.7.16.post0/docs/source/code.rst +16 -0
  21. {pyoptik-0.7.11 → pyoptik-0.7.16.post0}/docs/source/conf.py +6 -18
  22. pyoptik-0.7.16.post0/docs/source/gallery/add_material.ipynb +43 -0
  23. pyoptik-0.7.16.post0/docs/source/gallery/add_material.rst +68 -0
  24. pyoptik-0.7.16.post0/docs/source/gallery/add_material_codeobj.pickle +0 -0
  25. pyoptik-0.7.16.post0/docs/source/gallery/get_values.ipynb +43 -0
  26. pyoptik-0.7.16.post0/docs/source/gallery/get_values.rst +66 -0
  27. pyoptik-0.7.16.post0/docs/source/gallery/get_values_codeobj.pickle +0 -0
  28. pyoptik-0.7.16.post0/docs/source/gallery/images/sphx_glr_plot_sellmeier_0_001.png +0 -0
  29. pyoptik-0.7.16.post0/docs/source/gallery/images/sphx_glr_plot_sellmeier_1_001.png +0 -0
  30. pyoptik-0.7.16.post0/docs/source/gallery/images/thumb/sphx_glr_add_material_thumb.png +0 -0
  31. pyoptik-0.7.16.post0/docs/source/gallery/images/thumb/sphx_glr_get_values_thumb.png +0 -0
  32. pyoptik-0.7.16.post0/docs/source/gallery/images/thumb/sphx_glr_plot_sellmeier_0_thumb.png +0 -0
  33. pyoptik-0.7.16.post0/docs/source/gallery/images/thumb/sphx_glr_plot_sellmeier_1_thumb.png +0 -0
  34. pyoptik-0.7.16.post0/docs/source/gallery/index.rst +103 -0
  35. pyoptik-0.7.16.post0/docs/source/gallery/plot_sellmeier_0.ipynb +43 -0
  36. pyoptik-0.7.16.post0/docs/source/gallery/plot_sellmeier_0.py.md5 +1 -0
  37. pyoptik-0.7.16.post0/docs/source/gallery/plot_sellmeier_0.rst +225 -0
  38. pyoptik-0.7.16.post0/docs/source/gallery/plot_sellmeier_0_codeobj.pickle +0 -0
  39. pyoptik-0.7.16.post0/docs/source/gallery/plot_sellmeier_1.ipynb +43 -0
  40. pyoptik-0.7.16.post0/docs/source/gallery/plot_sellmeier_1.py.md5 +1 -0
  41. pyoptik-0.7.16.post0/docs/source/gallery/plot_sellmeier_1.rst +225 -0
  42. pyoptik-0.7.16.post0/docs/source/gallery/plot_sellmeier_1_codeobj.pickle +0 -0
  43. pyoptik-0.7.16.post0/docs/source/gallery/sg_execution_times.rst +19 -0
  44. pyoptik-0.7.16.post0/docs/source/index.rst +16 -0
  45. pyoptik-0.7.16.post0/docs/source/references.rst +4 -0
  46. pyoptik-0.7.16.post0/pyproject.toml +67 -0
  47. pyoptik-0.7.16.post0/setup.cfg +4 -0
  48. {pyoptik-0.7.11 → pyoptik-0.7.16.post0}/tests/test_measurements.py +0 -2
  49. {pyoptik-0.7.11 → pyoptik-0.7.16.post0}/tests/test_sellmeier.py +0 -2
  50. pyoptik-0.7.11/MANIFEST.in +0 -19
  51. pyoptik-0.7.11/PyOptik/VERSION +0 -1
  52. pyoptik-0.7.11/PyOptik/__pycache__/__init__.cpython-310.pyc +0 -0
  53. pyoptik-0.7.11/PyOptik/__pycache__/experiment_material.cpython-310.pyc +0 -0
  54. pyoptik-0.7.11/PyOptik/__pycache__/sellmeier_material.cpython-310.pyc +0 -0
  55. pyoptik-0.7.11/PyOptik.egg-info/SOURCES.txt +0 -35
  56. pyoptik-0.7.11/PyOptik.egg-info/top_level.txt +0 -3
  57. pyoptik-0.7.11/pyproject.toml +0 -10
  58. pyoptik-0.7.11/setup.cfg +0 -84
  59. pyoptik-0.7.11/setup.py +0 -6
  60. pyoptik-0.7.11/tests/__pycache__/__init__.cpython-310.pyc +0 -0
  61. pyoptik-0.7.11/tests/__pycache__/test_measurements.cpython-310.pyc +0 -0
  62. pyoptik-0.7.11/tests/__pycache__/test_sellmeier.cpython-310.pyc +0 -0
  63. {pyoptik-0.7.11 → pyoptik-0.7.16.post0}/LICENSE +0 -0
  64. {pyoptik-0.7.11 → pyoptik-0.7.16.post0}/PyOptik.egg-info/dependency_links.txt +0 -0
  65. {pyoptik-0.7.11 → pyoptik-0.7.16.post0}/README.rst +0 -0
  66. {pyoptik-0.7.11 → pyoptik-0.7.16.post0}/docs/examples/measurements_tio2.py +0 -0
  67. {pyoptik-0.7.11 → pyoptik-0.7.16.post0}/docs/examples/measurements_water.py +0 -0
  68. {pyoptik-0.7.11 → pyoptik-0.7.16.post0}/docs/examples/sellmeier_bk7.py +0 -0
  69. {pyoptik-0.7.11 → pyoptik-0.7.16.post0}/docs/examples/sellmeier_sf5.py +0 -0
  70. {pyoptik-0.7.11 → pyoptik-0.7.16.post0}/docs/examples/sellmeier_silica.py +0 -0
  71. {pyoptik-0.7.11 → pyoptik-0.7.16.post0}/docs/source/gallery/add_material.py +0 -0
  72. {pyoptik-0.7.11 → pyoptik-0.7.16.post0}/docs/source/gallery/get_values.py +0 -0
  73. {pyoptik-0.7.11 → pyoptik-0.7.16.post0}/docs/source/gallery/plot_sellmeier_0.py +0 -0
  74. {pyoptik-0.7.11 → pyoptik-0.7.16.post0}/docs/source/gallery/plot_sellmeier_1.py +0 -0
  75. {pyoptik-0.7.11 → pyoptik-0.7.16.post0}/tests/__init__.py +0 -0
@@ -0,0 +1,11 @@
1
+ # Specify reviewers for pull requests
2
+
3
+ version: 2
4
+ updates:
5
+ - package-ecosystem: "pip"
6
+ directory: "/"
7
+ target-branch: "master"
8
+ schedule:
9
+ interval: "weekly"
10
+ day: "sunday"
11
+ time: "09:00"
@@ -0,0 +1,53 @@
1
+ name: Deploy
2
+
3
+ on:
4
+ push:
5
+ branches: [ "master" ]
6
+ tags:
7
+ - '*'
8
+ pull_request:
9
+ branches: [ "master" ]
10
+
11
+ permissions:
12
+ contents: write
13
+
14
+ jobs:
15
+ build_pure_python:
16
+ runs-on: ubuntu-latest
17
+ steps:
18
+ - uses: MartinPdeS/MPSActions/build_pure_python_package@master
19
+ with:
20
+ python-version: '3.10'
21
+
22
+ publish_coverage:
23
+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
24
+ needs: [build_pure_python]
25
+ runs-on: ubuntu-latest
26
+ steps:
27
+ - uses: MartinPdeS/MPSActions/publish_coverage@master
28
+ with:
29
+ package-name: PyOptik
30
+ python-version: "3.10"
31
+ auth: ${{ secrets.GIST_TOKEN }}
32
+ gistID: 8fa5a7d93dc020b1f624012220f6ebbd
33
+
34
+ publish_documentation:
35
+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
36
+ needs: [build_pure_python]
37
+ runs-on: ubuntu-latest
38
+ steps:
39
+ - uses: MartinPdeS/MPSActions/publish_documentation@master
40
+ with:
41
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42
+ package-name: PyOptik
43
+ python-version: "3.10" #no documentation for python 3.7 (pickle5 not present˘)
44
+
45
+ publish_wheel:
46
+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
47
+ needs: [build_pure_python, publish_documentation, publish_coverage]
48
+ runs-on: ubuntu-latest
49
+ steps:
50
+ - uses: MartinPdeS/MPSActions/publish_pypi@master
51
+ with:
52
+ python-version: "3.10"
53
+ password: ${{ secrets.PYPI_API_TOKEN }}
@@ -0,0 +1,15 @@
1
+ *.DS_store
2
+ *.ipynb_checkpoints*
3
+ *__pycache__*
4
+ *.so
5
+ *.pytest_cache
6
+
7
+ dist
8
+ build
9
+ *.egg*
10
+ perso/
11
+
12
+ CMakeCache.txt
13
+ CMakeFiles
14
+ install_manifest.txt
15
+ cmake_install.cmake
@@ -0,0 +1,35 @@
1
+ # .readthedocs.yml
2
+ # Read the Docs configuration file
3
+ # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4
+
5
+ # Required
6
+ version: 2
7
+
8
+ submodules:
9
+ include: all
10
+ recursive: true
11
+
12
+ build:
13
+ os: ubuntu-22.04
14
+
15
+
16
+ tools:
17
+ python: "3.10"
18
+ jobs:
19
+ pre_install:
20
+ - Xvfb :99 &
21
+ - export DISPLAY=:99
22
+ - cd docs && rm -rf source/gallery
23
+ - sleep 3
24
+
25
+ python:
26
+ install:
27
+ - method: pip
28
+ path: .
29
+ extra_requirements:
30
+ - documentation
31
+
32
+ sphinx:
33
+ builder: html
34
+ configuration: docs/source/conf.py
35
+ fail_on_warning: false
@@ -1,18 +1,33 @@
1
1
  Metadata-Version: 2.1
2
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
3
+ Version: 0.7.16.post0
4
+ Summary: A package for refractive index values.
5
+ Author-email: Martin Poinsinet de Sivry-Houle <martin.poinsinet.de.sivry@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2020 Martin de Sivry
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Keywords: refracive index,optics
13
29
  Classifier: Programming Language :: Python
14
30
  Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.10
16
31
  Classifier: Programming Language :: Python :: 3.11
17
32
  Classifier: Programming Language :: Python :: 3.12
18
33
  Classifier: Programming Language :: Python :: Implementation :: CPython
@@ -20,22 +35,14 @@ Classifier: Development Status :: 4 - Beta
20
35
  Classifier: Topic :: Scientific/Engineering :: Physics
21
36
  Classifier: License :: OSI Approved :: MIT License
22
37
  Classifier: Intended Audience :: Science/Research
38
+ Requires-Python: >=3.10
23
39
  Description-Content-Type: text/x-rst
24
40
  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"
41
+ Requires-Dist: pydantic>=2.6.3
42
+ Requires-Dist: numpy
43
+ Requires-Dist: scipy
44
+ Requires-Dist: MPSTools
45
+ Requires-Dist: tabulate
39
46
  Provides-Extra: testing
40
47
  Requires-Dist: pytest>=0.6; extra == "testing"
41
48
  Requires-Dist: pytest-cov>=2.0; extra == "testing"
@@ -44,7 +51,12 @@ Requires-Dist: mypy>=0.910; extra == "testing"
44
51
  Requires-Dist: flake8>=3.9; extra == "testing"
45
52
  Requires-Dist: tox>=3.24; extra == "testing"
46
53
  Requires-Dist: coverage==6.5.0; extra == "testing"
47
- Requires-Dist: PyMieScatt==1.8.1.1; extra == "testing"
54
+ Provides-Extra: documentation
55
+ Requires-Dist: numpydoc==1.6.0; extra == "documentation"
56
+ Requires-Dist: sphinx>=5.1.1; extra == "documentation"
57
+ Requires-Dist: sphinx-gallery==0.15.0; extra == "documentation"
58
+ Requires-Dist: sphinx-rtd-theme==2.0.0; extra == "documentation"
59
+ Requires-Dist: pydata-sphinx-theme==0.14.1; extra == "documentation"
48
60
 
49
61
  |Logo|
50
62
 
@@ -4,6 +4,13 @@ import numpy
4
4
  import pandas
5
5
 
6
6
 
7
+ try:
8
+ from ._version import version as __version__ # noqa: F401
9
+
10
+ except ImportError:
11
+ __version__ = "0.0.0"
12
+
13
+
7
14
  class UsualMaterial:
8
15
  BK7 = Sellmeier('BK7')
9
16
  FusedSilica = Sellmeier('silica')
@@ -0,0 +1,16 @@
1
+ # file generated by setuptools_scm
2
+ # don't change, don't track in version control
3
+ TYPE_CHECKING = False
4
+ if TYPE_CHECKING:
5
+ from typing import Tuple, Union
6
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
7
+ else:
8
+ VERSION_TUPLE = object
9
+
10
+ version: str
11
+ __version__: str
12
+ __version_tuple__: VERSION_TUPLE
13
+ version_tuple: VERSION_TUPLE
14
+
15
+ __version__ = version = '0.7.16.post0'
16
+ __version_tuple__ = version_tuple = (0, 7, 16)
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
- import os
5
4
  from pathlib import Path
6
5
  import PyOptik
7
6
 
@@ -11,8 +10,7 @@ __all__ = [
11
10
  'project_path',
12
11
  'doc_path',
13
12
  'doc_css_path',
14
- 'logo_path',
15
- 'version_path',
13
+ 'logo_path'
16
14
  ]
17
15
 
18
16
  root_path = Path(PyOptik.__path__[0])
@@ -27,16 +25,8 @@ doc_css_path = doc_path.joinpath('source/_static/default.css')
27
25
 
28
26
  logo_path = doc_path.joinpath('images/logo.png')
29
27
 
30
- version_path = root_path.joinpath('VERSION')
31
-
32
28
  examples_path = root_path.joinpath('examples')
33
29
 
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
30
 
41
31
  if __name__ == '__main__':
42
32
  for path_name in __all__:
@@ -2,27 +2,26 @@
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
4
  import os
5
- from typing import Union, Iterable
5
+ from typing import Union, Iterable, NoReturn
6
6
  from MPSTools.material_catalogue.loader import get_material_index
7
- from MPSPlots.render2D import SceneList
8
-
7
+ import matplotlib.pyplot as plt
9
8
  from MPSTools.tools.directories import measurements_file_path
10
9
  from pydantic.dataclasses import dataclass
11
10
 
12
11
 
13
- def valid_name(string):
12
+ def valid_name(string: str) -> bool:
13
+ """Check if the provided string is a valid material name."""
14
14
  return not string.startswith('_')
15
15
 
16
16
 
17
+ # List of available materials
17
18
  list_of_available_files = os.listdir(measurements_file_path)
18
-
19
19
  material_list = [element[:-5] for element in list_of_available_files]
20
-
21
20
  material_list = list(filter(valid_name, material_list))
22
21
 
23
22
 
24
23
  @dataclass
25
- class DataMeasurement():
24
+ class DataMeasurement:
26
25
  """
27
26
  A class for computing the refractive index using locally saved measurement data for specified materials.
28
27
 
@@ -30,19 +29,18 @@ class DataMeasurement():
30
29
  material_name (str): The name of the material.
31
30
 
32
31
  Methods:
33
- reference (str): Returns the bibliographic reference for the material's data.
32
+ reference: Returns the bibliographic reference for the material's data.
34
33
  get_refractive_index: Computes the refractive index for given wavelength(s).
35
34
  plot: Visualizes the refractive index as a function of wavelength.
36
35
  """
37
-
38
36
  material_name: str
39
37
 
40
38
  def __post_init__(self):
41
39
  """
42
40
  Initializes the DataMeasurement object with a specified material name.
43
41
 
44
- Parameters:
45
- material_name (str): The name of the material for which to compute the refractive index.
42
+ Raises:
43
+ ValueError: If the material_name is not in the list of available materials.
46
44
  """
47
45
  if self.material_name not in material_list:
48
46
  raise ValueError(f"{self.material_name} is not in the list of available materials.")
@@ -54,18 +52,21 @@ class DataMeasurement():
54
52
 
55
53
  Returns:
56
54
  str: The bibliographic reference for the material's measurement data.
55
+
56
+ Raises:
57
+ NotImplementedError: If the feature is not implemented yet.
57
58
  """
58
59
  raise NotImplementedError("Feature not implemented yet.")
59
60
 
60
- def get_refractive_index(self, wavelength_range: Union[float, Iterable]) -> Union[float, Iterable]:
61
+ def get_refractive_index(self, wavelength_range: Union[float, Iterable[float]]) -> Union[float, Iterable[float]]:
61
62
  """
62
63
  Computes the refractive index for the specified wavelength range using the material's measurement data.
63
64
 
64
65
  Parameters:
65
- wavelength_range (Union[float, Iterable]): The wavelength(s) in meters.
66
+ wavelength_range (Union[float, Iterable[float]]): The wavelength(s) in meters.
66
67
 
67
68
  Returns:
68
- Union[float, Iterable]: The refractive index or indices for the specified wavelength(s).
69
+ Union[float, Iterable[float]]: The refractive index or indices for the specified wavelength(s).
69
70
  """
70
71
  return get_material_index(
71
72
  material_name=self.material_name,
@@ -73,23 +74,22 @@ class DataMeasurement():
73
74
  subdir='measurements'
74
75
  )
75
76
 
76
- def plot(self, wavelength_range: Iterable) -> SceneList:
77
+ def plot(self, wavelength_range: Iterable[float]) -> NoReturn:
77
78
  """
78
79
  Generates a plot of the refractive index as a function of wavelength for the specified material.
79
80
 
80
81
  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.
82
+ wavelength_range (Iterable[float]): The range of wavelengths to plot.
85
83
  """
86
- scene = SceneList()
87
- ax = scene.append_ax(x_label='Wavelength [m]', y_label='Refractive index')
84
+ figure, ax = plt.subplots(1, 1)
85
+ ax.set_xlabel('Wavelength [m]')
86
+ ax.set_ylabel('Refractive index')
88
87
 
89
88
  refractive_index = self.get_refractive_index(wavelength_range)
90
- ax.add_line(x=wavelength_range, y=refractive_index, line_width=2)
89
+ ax.plot(wavelength_range, refractive_index.real, linewidth=2, label='real part')
90
+ ax.plot(wavelength_range, refractive_index.imag, linewidth=2, label='imag part')
91
91
 
92
- return scene
92
+ plt.show()
93
93
 
94
94
  def __repr__(self) -> str:
95
95
  """
@@ -98,7 +98,7 @@ class DataMeasurement():
98
98
  Returns:
99
99
  str: Formal representation of the object, showing the material name.
100
100
  """
101
- return str(self.material_name)
101
+ return f"DataMeasurement(material_name='{self.material_name}')"
102
102
 
103
103
  def __str__(self) -> str:
104
104
  """
@@ -107,6 +107,4 @@ class DataMeasurement():
107
107
  Returns:
108
108
  str: Informal representation of the object.
109
109
  """
110
- return self.__repr__()
111
-
112
- # -
110
+ return self.material_name
@@ -2,33 +2,32 @@
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
4
  import os
5
- import numpy as np
6
- from typing import Union, Iterable
5
+ import numpy
6
+ from typing import Union, Iterable, NoReturn
7
7
  from MPSTools.material_catalogue.loader import get_material_index
8
- from MPSPlots.render2D import SceneList
8
+ import matplotlib.pyplot as plt
9
9
  from MPSTools.tools.directories import sellmeier_file_path
10
10
  from pydantic.dataclasses import dataclass
11
11
 
12
12
 
13
- def valid_name(string):
13
+ def valid_name(string: str) -> bool:
14
+ """Check if the provided string is a valid material name."""
14
15
  return not string.startswith('_')
15
16
 
16
17
 
18
+ # List of available materials
17
19
  list_of_available_files = os.listdir(sellmeier_file_path)
18
-
19
20
  material_list = [element[:-5] for element in list_of_available_files]
20
-
21
21
  material_list = list(filter(valid_name, material_list))
22
22
 
23
23
 
24
24
  @dataclass
25
- class Sellmeier():
25
+ class Sellmeier:
26
26
  """
27
27
  A class for computing the refractive index using the Sellmeier equation based on locally stored Sellmeier coefficients.
28
28
 
29
29
  Attributes:
30
30
  material_name (str): Name of the material.
31
- sellmeier_coefficients (dict): Sellmeier coefficients for the material loaded from a local source.
32
31
 
33
32
  Methods:
34
33
  reference: Returns the reference for the Sellmeier coefficients.
@@ -39,13 +38,18 @@ class Sellmeier():
39
38
 
40
39
  def __post_init__(self):
41
40
  """
42
- Initializes the DataMeasurement object with a specified material name.
41
+ Initializes the Sellmeier object with a specified material name.
43
42
 
44
- Parameters:
45
- material_name (str): The name of the material for which to compute the refractive index.
43
+ Raises:
44
+ ValueError: If the material_name is not in the list of available materials.
46
45
  """
47
46
  if self.material_name not in material_list:
48
47
  raise ValueError(f"{self.material_name} is not in the list of available materials.")
48
+ self.sellmeier_coefficients = get_material_index(
49
+ material_name=self.material_name,
50
+ wavelength=numpy.array([1.0]), # Dummy wavelength to load coefficients
51
+ subdir='sellmeier'
52
+ )
49
53
 
50
54
  @property
51
55
  def reference(self) -> str:
@@ -57,7 +61,7 @@ class Sellmeier():
57
61
  """
58
62
  return self.sellmeier_coefficients['sellmeier']['reference']
59
63
 
60
- def get_refractive_index(self, wavelength_range: Union[float, Iterable]) -> Union[float, np.ndarray]:
64
+ def get_refractive_index(self, wavelength_range: Union[float, Iterable]) -> Union[float, numpy.ndarray]:
61
65
  """
62
66
  Computes the refractive index for the specified wavelength(s) using the Sellmeier equation.
63
67
 
@@ -65,10 +69,10 @@ class Sellmeier():
65
69
  wavelength_range (Union[float, Iterable]): The wavelength(s) in meters for which to compute the refractive index.
66
70
 
67
71
  Returns:
68
- Union[float, np.ndarray]: The computed refractive index, either as a scalar or a NumPy array.
72
+ Union[float, numpy.ndarray]: The computed refractive index, either as a scalar or a NumPy array.
69
73
  """
70
- return_scalar = np.isscalar(wavelength_range)
71
- wavelength_array = np.atleast_1d(wavelength_range).astype(float)
74
+ return_scalar = numpy.isscalar(wavelength_range)
75
+ wavelength_array = numpy.atleast_1d(wavelength_range).astype(float)
72
76
 
73
77
  refractive_index = get_material_index(
74
78
  material_name=self.material_name,
@@ -78,41 +82,38 @@ class Sellmeier():
78
82
 
79
83
  return refractive_index.item() if return_scalar else refractive_index
80
84
 
81
- def plot(self, wavelength_range: Iterable) -> SceneList:
85
+ def plot(self, wavelength_range: Iterable) -> NoReturn:
82
86
  """
83
87
  Plots the refractive index as a function of wavelength over a specified range.
84
88
 
85
89
  Parameters:
86
90
  wavelength_range (Iterable): The range of wavelengths to plot, in meters.
87
-
88
- Returns:
89
- SceneList: A SceneList object containing the plot.
90
91
  """
91
- scene = SceneList()
92
- ax = scene.append_ax(x_label='Wavelength [m]', y_label='Refractive index')
92
+ figure, ax = plt.subplots(1, 1)
93
+ ax.set_xlabel('Wavelength [m]')
94
+ ax.set_ylabel('Refractive index')
93
95
 
94
96
  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
97
+ ax.plot(wavelength_range, refractive_index, linewidth=2)
98
+ plt.show()
99
99
 
100
100
  def __repr__(self) -> str:
101
101
  """
102
- Provides a formal string representation of the DataMeasurement object.
102
+ Provides a formal string representation of the Sellmeier object.
103
103
 
104
104
  Returns:
105
105
  str: Formal representation of the object, showing the material name.
106
106
  """
107
- return str(self.material_name)
107
+ return f"Sellmeier(material_name='{self.material_name}')"
108
108
 
109
109
  def __str__(self) -> str:
110
110
  """
111
- Provides an informal string representation of the DataMeasurement object.
111
+ Provides an informal string representation of the Sellmeier object.
112
112
 
113
113
  Returns:
114
114
  str: Informal representation of the object.
115
115
  """
116
- return self.__repr__()
116
+ return self.material_name
117
+
117
118
 
118
- # -
119
+ Material = Sellmeier
@@ -1,18 +1,33 @@
1
1
  Metadata-Version: 2.1
2
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
3
+ Version: 0.7.16.post0
4
+ Summary: A package for refractive index values.
5
+ Author-email: Martin Poinsinet de Sivry-Houle <martin.poinsinet.de.sivry@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2020 Martin de Sivry
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Keywords: refracive index,optics
13
29
  Classifier: Programming Language :: Python
14
30
  Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.10
16
31
  Classifier: Programming Language :: Python :: 3.11
17
32
  Classifier: Programming Language :: Python :: 3.12
18
33
  Classifier: Programming Language :: Python :: Implementation :: CPython
@@ -20,22 +35,14 @@ Classifier: Development Status :: 4 - Beta
20
35
  Classifier: Topic :: Scientific/Engineering :: Physics
21
36
  Classifier: License :: OSI Approved :: MIT License
22
37
  Classifier: Intended Audience :: Science/Research
38
+ Requires-Python: >=3.10
23
39
  Description-Content-Type: text/x-rst
24
40
  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"
41
+ Requires-Dist: pydantic>=2.6.3
42
+ Requires-Dist: numpy
43
+ Requires-Dist: scipy
44
+ Requires-Dist: MPSTools
45
+ Requires-Dist: tabulate
39
46
  Provides-Extra: testing
40
47
  Requires-Dist: pytest>=0.6; extra == "testing"
41
48
  Requires-Dist: pytest-cov>=2.0; extra == "testing"
@@ -44,7 +51,12 @@ Requires-Dist: mypy>=0.910; extra == "testing"
44
51
  Requires-Dist: flake8>=3.9; extra == "testing"
45
52
  Requires-Dist: tox>=3.24; extra == "testing"
46
53
  Requires-Dist: coverage==6.5.0; extra == "testing"
47
- Requires-Dist: PyMieScatt==1.8.1.1; extra == "testing"
54
+ Provides-Extra: documentation
55
+ Requires-Dist: numpydoc==1.6.0; extra == "documentation"
56
+ Requires-Dist: sphinx>=5.1.1; extra == "documentation"
57
+ Requires-Dist: sphinx-gallery==0.15.0; extra == "documentation"
58
+ Requires-Dist: sphinx-rtd-theme==2.0.0; extra == "documentation"
59
+ Requires-Dist: pydata-sphinx-theme==0.14.1; extra == "documentation"
48
60
 
49
61
  |Logo|
50
62