PyOptik 1.3.0.post0__tar.gz → 1.3.1.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 (107) hide show
  1. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/.gitignore +1 -0
  2. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PKG-INFO +49 -23
  3. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/_version.py +2 -2
  4. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/sellmeier_class.py +22 -21
  5. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/tabulated_class.py +17 -13
  6. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/utils.py +36 -2
  7. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik.egg-info/PKG-INFO +49 -23
  8. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik.egg-info/SOURCES.txt +3 -5
  9. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/README.rst +48 -22
  10. pyoptik-1.3.1.post0/docs/images/example_bk7.png +0 -0
  11. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/tests/test_sellmeier.py +0 -9
  12. pyoptik-1.3.1.post0/tests/test_utils.py +28 -0
  13. pyoptik-1.3.0.post0/PyOptik/data/tabulated/test.yml +0 -14
  14. pyoptik-1.3.0.post0/PyOptik/data/test.yml +0 -14
  15. pyoptik-1.3.0.post0/developments/testing.py +0 -12
  16. pyoptik-1.3.0.post0/tests/test_extra.py +0 -12
  17. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/.github/dependabot.yml +0 -0
  18. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/.github/workflows/coverage.yml +0 -0
  19. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/.github/workflows/deploy_workflow.yml +0 -0
  20. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/.readthedocs.yml +0 -0
  21. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/LICENSE +0 -0
  22. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/__init__.py +0 -0
  23. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/base_class.py +0 -0
  24. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/__init__.py +0 -0
  25. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/sellmeier/BAK1.yml +0 -0
  26. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/sellmeier/BK7.yml +0 -0
  27. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/sellmeier/SF5.yml +0 -0
  28. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/sellmeier/ZBLAN.yml +0 -0
  29. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/sellmeier/__init__.py +0 -0
  30. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/sellmeier/argon.yml +0 -0
  31. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/sellmeier/crown.yml +0 -0
  32. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/sellmeier/default.py +0 -0
  33. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/sellmeier/flint.yml +0 -0
  34. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/sellmeier/fluorine_doped_silica_1%.yml +0 -0
  35. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/sellmeier/fluorine_doped_silica_2%.yml +0 -0
  36. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/sellmeier/fused_silica.yml +0 -0
  37. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/sellmeier/germanium.yml +0 -0
  38. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/sellmeier/lithium_niobate.yml +0 -0
  39. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/sellmeier/polystyren.yml +0 -0
  40. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/sellmeier/silica.yml +0 -0
  41. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/sellmeier/silicon.yml +0 -0
  42. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/sellmeier/soda_lime_glass.yml +0 -0
  43. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/sellmeier/water.yml +0 -0
  44. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/tabulated/__init__.py +0 -0
  45. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/tabulated/aluminium.yml +0 -0
  46. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/tabulated/calcium.yml +0 -0
  47. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/tabulated/copper.yml +0 -0
  48. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/tabulated/default.py +0 -0
  49. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/tabulated/gold.yml +0 -0
  50. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/tabulated/iron.yml +0 -0
  51. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/tabulated/nickel.yml +0 -0
  52. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/tabulated/silver.yml +0 -0
  53. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/tabulated/sodium.yml +0 -0
  54. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/data/tabulated/zinc.yml +0 -0
  55. {pyoptik-1.3.0.post0/PyOptik/data/sellmeier → pyoptik-1.3.1.post0/PyOptik/data}/test.yml +0 -0
  56. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/directories.py +0 -0
  57. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/download.py +0 -0
  58. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik/material.py +0 -0
  59. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik.egg-info/dependency_links.txt +0 -0
  60. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik.egg-info/requires.txt +0 -0
  61. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/PyOptik.egg-info/top_level.txt +0 -0
  62. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/Makefile +0 -0
  63. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/deprecated/experiment_material.py +0 -0
  64. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/examples/README.rst +0 -0
  65. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/examples/plot_bk7.py +0 -0
  66. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/examples/plot_sf5.py +0 -0
  67. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/examples/plot_silica.py +0 -0
  68. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/examples/plot_silver.py +0 -0
  69. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/examples/plot_water.py +0 -0
  70. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/images/logo.png +0 -0
  71. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/make.bat +0 -0
  72. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/_static/default.css +0 -0
  73. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/code.rst +0 -0
  74. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/conf.py +0 -0
  75. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/gallery/add_material.ipynb +0 -0
  76. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/gallery/add_material.py +0 -0
  77. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/gallery/add_material.rst +0 -0
  78. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/gallery/add_material_codeobj.pickle +0 -0
  79. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/gallery/get_values.ipynb +0 -0
  80. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/gallery/get_values.py +0 -0
  81. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/gallery/get_values.rst +0 -0
  82. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/gallery/get_values_codeobj.pickle +0 -0
  83. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/gallery/images/sphx_glr_plot_sellmeier_0_001.png +0 -0
  84. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/gallery/images/sphx_glr_plot_sellmeier_1_001.png +0 -0
  85. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/gallery/images/thumb/sphx_glr_add_material_thumb.png +0 -0
  86. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/gallery/images/thumb/sphx_glr_get_values_thumb.png +0 -0
  87. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/gallery/images/thumb/sphx_glr_plot_sellmeier_0_thumb.png +0 -0
  88. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/gallery/images/thumb/sphx_glr_plot_sellmeier_1_thumb.png +0 -0
  89. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/gallery/index.rst +0 -0
  90. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/gallery/plot_sellmeier_0.ipynb +0 -0
  91. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/gallery/plot_sellmeier_0.py +0 -0
  92. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/gallery/plot_sellmeier_0.py.md5 +0 -0
  93. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/gallery/plot_sellmeier_0.rst +0 -0
  94. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/gallery/plot_sellmeier_0_codeobj.pickle +0 -0
  95. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/gallery/plot_sellmeier_1.ipynb +0 -0
  96. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/gallery/plot_sellmeier_1.py +0 -0
  97. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/gallery/plot_sellmeier_1.py.md5 +0 -0
  98. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/gallery/plot_sellmeier_1.rst +0 -0
  99. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/gallery/plot_sellmeier_1_codeobj.pickle +0 -0
  100. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/gallery/sg_execution_times.rst +0 -0
  101. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/index.rst +0 -0
  102. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/docs/source/references.rst +0 -0
  103. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/pyproject.toml +0 -0
  104. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/setup.cfg +0 -0
  105. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/tests/__init__.py +0 -0
  106. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/tests/test_tabulated.py +0 -0
  107. {pyoptik-1.3.0.post0 → pyoptik-1.3.1.post0}/tests/test_usual_material.py +0 -0
@@ -5,6 +5,7 @@
5
5
  *.pytest_cache
6
6
  *htmlcov
7
7
  *.coverage
8
+ developments/*
8
9
 
9
10
  dist
10
11
  build
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyOptik
3
- Version: 1.3.0.post0
3
+ Version: 1.3.1.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
@@ -60,24 +60,6 @@ Requires-Dist: sphinx-gallery==0.15.0; extra == "documentation"
60
60
  Requires-Dist: sphinx-rtd-theme==2.0.0; extra == "documentation"
61
61
  Requires-Dist: pydata-sphinx-theme==0.14.1; extra == "documentation"
62
62
 
63
- .. |python| image:: https://img.shields.io/pypi/pyversions/pyoptik.svg
64
- :target: https://www.python.org/
65
-
66
- .. |Logo| image:: https://github.com/MartinPdeS/PyOptik/raw/master/docs/images/logo.png
67
-
68
- .. |docs| image:: https://readthedocs.org/projects/pyoptik/badge/?version=latest
69
- :target: https://pyoptik.readthedocs.io/en/latest/
70
-
71
- .. |PyPi| image:: https://badge.fury.io/py/pyoptik.svg
72
- :target: https://badge.fury.io/py/pyoptik
73
-
74
- .. |PyPi_download| image:: https://img.shields.io/pypi/dm/pyoptik.svg
75
- :target: https://pypistats.org/packages/pyoptik
76
-
77
- .. |coverage| image:: https://raw.githubusercontent.com/MartinPdeS/PyOptik/python-coverage-comment-action-data/badge.svg
78
- :alt: Unittest coverage
79
- :target: https://htmlpreview.github.io/?https://github.com/MartinPdeS/PyOptik/blob/python-coverage-comment-action-data/htmlcov/index.html
80
-
81
63
  PyOptik
82
64
  =======
83
65
 
@@ -117,13 +99,11 @@ After installing PyOptik, you can easily access material properties:
117
99
  n = bk7.compute_refractive_index(0.55e-6)
118
100
  print(f"Refractive index at 0.55 µm: {n}")
119
101
 
120
- # Accessing and plotting material properties
121
- bk7.plot(wavelength_range=[0.3e-6, 2.5e-6])
122
102
 
123
103
  Example
124
104
  *******
125
105
 
126
- Here’s a quick example demonstrating how to use PyOptik to retrieve and plot the refractive index of a material:
106
+ Here is a quick example demonstrating how to use PyOptik to retrieve and plot the refractive index of a material:
127
107
 
128
108
  .. code:: python
129
109
 
@@ -138,7 +118,34 @@ Here’s a quick example demonstrating how to use PyOptik to retrieve and plot t
138
118
  n_values = bk7.compute_refractive_index(wavelengths)
139
119
 
140
120
  # Plot the results
141
- bk7.plot(wavelength_range=wavelengths)
121
+ bk7.plot()
122
+
123
+ This code produces the following figure:
124
+
125
+ |example_bk7|
126
+
127
+
128
+ You can also add a custom element to your library providing a URL from `refractiveindex.info <https://refractiveindex.info>`_ website.
129
+
130
+ .. code:: python
131
+
132
+ from PyOptik.utils import download_yml_file
133
+ from PyOptik.directories import sellmeier_data_path # or tabulated_data_path for tabulated elements
134
+
135
+ download_yml_file(
136
+ filename='test',
137
+ url='https://refractiveindex.info/database/data-nk/main/H2O/Daimon-19.0C.yml',
138
+ location=tabulated_data_path
139
+ )
140
+
141
+ Evidently, you can also remove element from the library using as follows:
142
+
143
+
144
+ .. code:: python
145
+
146
+ from PyOptik.utils import remove_element
147
+
148
+ remove_element(filename='test', location='any') # location can be "any", "sellmeier" or "tabulated"
142
149
 
143
150
  Testing
144
151
  *******
@@ -168,3 +175,22 @@ As of 2024, PyOptik is still under development. If you would like to collaborate
168
175
 
169
176
 
170
177
 
178
+ .. |python| image:: https://img.shields.io/pypi/pyversions/pyoptik.svg
179
+ :target: https://www.python.org/
180
+
181
+ .. |Logo| image:: https://github.com/MartinPdeS/PyOptik/raw/master/docs/images/logo.png
182
+
183
+ .. |example_bk7| image:: https://github.com/MartinPdeS/PyOptik/blob/master/docs/images/example_bk7.png
184
+
185
+ .. |docs| image:: https://readthedocs.org/projects/pyoptik/badge/?version=latest
186
+ :target: https://pyoptik.readthedocs.io/en/latest/
187
+
188
+ .. |PyPi| image:: https://badge.fury.io/py/pyoptik.svg
189
+ :target: https://badge.fury.io/py/pyoptik
190
+
191
+ .. |PyPi_download| image:: https://img.shields.io/pypi/dm/pyoptik.svg
192
+ :target: https://pypistats.org/packages/pyoptik
193
+
194
+ .. |coverage| image:: https://raw.githubusercontent.com/MartinPdeS/PyOptik/python-coverage-comment-action-data/badge.svg
195
+ :alt: Unittest coverage
196
+ :target: https://htmlpreview.github.io/?https://github.com/MartinPdeS/PyOptik/blob/python-coverage-comment-action-data/htmlcov/index.html
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '1.3.0.post0'
16
- __version_tuple__ = version_tuple = (1, 3, 0)
15
+ __version__ = version = '1.3.1.post0'
16
+ __version_tuple__ = version_tuple = (1, 3, 1)
@@ -10,7 +10,7 @@ from PyOptik.directories import sellmeier_data_path
10
10
  import itertools
11
11
  import warnings
12
12
  from PyOptik.base_class import Material
13
-
13
+ from MPSPlots.styles import mps
14
14
 
15
15
  @dataclass
16
16
  class SellmeierMaterial(Material):
@@ -136,26 +136,27 @@ class SellmeierMaterial(Material):
136
136
  Args:
137
137
  wavelength_range (Union[List[float], numpy.ndarray]): The range of wavelengths to plot, in meters.
138
138
  """
139
- if wavelength is None:
140
- wavelength = numpy.linspace(*self.wavelength_range, 100) * 1e-6
141
-
142
- wavelength = numpy.asarray(wavelength)
143
-
144
- if wavelength.ndim != 1:
145
- raise ValueError("wavelength must be a 1D array or list of float values.")
146
-
147
- # Calculate the refractive index over the wavelength range
148
- refractive_index = self.compute_refractive_index(wavelength)
149
-
150
- # Plotting
151
- fig, ax = plt.subplots()
152
- ax.set_xlabel('Wavelength [m]')
153
- ax.set_ylabel('Refractive Index')
154
- ax.plot(wavelength, refractive_index.real, linewidth=2, label='Real Part')
155
- ax.legend()
156
- ax.grid(True)
157
- plt.tight_layout()
158
- plt.show()
139
+ with plt.style.context(mps):
140
+ if wavelength is None:
141
+ wavelength = numpy.linspace(*self.wavelength_range, 100) * 1e-6
142
+
143
+ wavelength = numpy.asarray(wavelength)
144
+
145
+ if wavelength.ndim != 1:
146
+ raise ValueError("wavelength must be a 1D array or list of float values.")
147
+
148
+ # Calculate the refractive index over the wavelength range
149
+ refractive_index = self.compute_refractive_index(wavelength)
150
+
151
+ # Plotting
152
+ fig, ax = plt.subplots()
153
+ ax.set_xlabel('Wavelength [m]')
154
+ ax.set_ylabel('Refractive Index')
155
+ ax.plot(wavelength, refractive_index.real, linewidth=2, label='Real Part')
156
+ ax.legend()
157
+ ax.grid(True)
158
+ plt.tight_layout()
159
+ plt.show()
159
160
 
160
161
  def print(self) -> str:
161
162
  """
@@ -1,3 +1,6 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
1
4
  import numpy
2
5
  from dataclasses import dataclass, field
3
6
  from typing import Optional, Tuple, Union, List
@@ -6,6 +9,8 @@ from scipy.interpolate import interp1d
6
9
  import warnings
7
10
  from PyOptik.directories import tabulated_data_path
8
11
  from PyOptik.base_class import Material
12
+ from MPSPlots.styles import mps
13
+ import matplotlib.pyplot as plt
9
14
 
10
15
  @dataclass
11
16
  class TabulatedMaterial(Material):
@@ -80,22 +85,21 @@ class TabulatedMaterial(Material):
80
85
  n_values = self.n_values
81
86
  k_values = self.k_values
82
87
 
83
- import matplotlib.pyplot as plt
84
-
85
- fig, ax1 = plt.subplots()
88
+ with plt.style.context(mps):
89
+ fig, ax1 = plt.subplots()
86
90
 
87
- ax1.set_xlabel('Wavelength [µm]')
88
- ax1.set_ylabel('Refractive Index (n)', color='tab:blue')
89
- ax1.plot(wavelength, n_values, 'o-', color='tab:blue', label='n')
90
- ax1.tick_params(axis='y', labelcolor='tab:blue')
91
+ ax1.set_xlabel('Wavelength [µm]')
92
+ ax1.set_ylabel('Refractive Index (n)', color='tab:blue')
93
+ ax1.plot(wavelength, n_values, 'o-', color='tab:blue', label='n')
94
+ ax1.tick_params(axis='y', labelcolor='tab:blue')
91
95
 
92
- ax2 = ax1.twinx() # instantiate a second axes that shares the same x-axis
93
- ax2.set_ylabel('Absorption (k)', color='tab:red') # we already handled the x-label with ax1
94
- ax2.plot(wavelength, k_values, 'o-', color='tab:red', label='k')
95
- ax2.tick_params(axis='y', labelcolor='tab:red')
96
+ ax2 = ax1.twinx() # instantiate a second axes that shares the same x-axis
97
+ ax2.set_ylabel('Absorption (k)', color='tab:red') # we already handled the x-label with ax1
98
+ ax2.plot(wavelength, k_values, 'o-', color='tab:red', label='k')
99
+ ax2.tick_params(axis='y', labelcolor='tab:red')
96
100
 
97
- fig.tight_layout() # to prevent the right y-label from being slightly clipped
98
- plt.show()
101
+ fig.tight_layout() # to prevent the right y-label from being slightly clipped
102
+ plt.show()
99
103
 
100
104
  def print(self) -> str:
101
105
  """
@@ -1,9 +1,12 @@
1
+
2
+ from typing import NoReturn
3
+ import os
1
4
  import requests
2
5
  from PyOptik.directories import sellmeier_data_path, tabulated_data_path
3
6
  from PyOptik.data.sellmeier.default import default_material as sellmeier_default
4
7
  from PyOptik.data.tabulated.default import default_material as tabulated_default
5
8
 
6
- def download_yml_file(url: str, filename: str, location: str) -> None:
9
+ def download_yml_file(url: str, filename: str, location: str) -> NoReturn:
7
10
  """
8
11
  Downloads a .yml file from a specified URL and saves it locally.
9
12
 
@@ -33,7 +36,7 @@ def download_yml_file(url: str, filename: str, location: str) -> None:
33
36
  except Exception as err:
34
37
  print(f"An error occurred: {err}")
35
38
 
36
- def build_default_library() -> None:
39
+ def build_default_library() -> NoReturn:
37
40
  """
38
41
  Downloads and saves the default materials from the specified URLs.
39
42
  """
@@ -45,3 +48,34 @@ def build_default_library() -> None:
45
48
  for name, url in tabulated_default.items():
46
49
  download_yml_file(url=url, filename=name, location=tabulated_data_path)
47
50
 
51
+
52
+ def remove_element(filename: str, location: str = 'any') -> None:
53
+ """
54
+ Remove a file associated with a given element name from the specified location.
55
+
56
+ Args:
57
+ filename (str): The name of the file to remove, without the '.yml' suffix.
58
+ location (str): The location to search for the file, either 'sellmeier', 'tabulated', or 'any' (default is 'any').
59
+
60
+ Raises:
61
+ FileNotFoundError: If the specified file does not exist.
62
+ ValueError: If an invalid location is provided.
63
+ """
64
+ location = location.lower()
65
+
66
+ if location not in ['any', 'sellmeier', 'tabulated']:
67
+ raise ValueError("Invalid location. Please choose 'sellmeier', 'tabulated', or 'any'.")
68
+
69
+ if location in ['any', 'sellmeier']:
70
+ sellmeier_file = sellmeier_data_path / f"{filename}.yml"
71
+ if sellmeier_file.exists():
72
+ sellmeier_file.unlink()
73
+
74
+ if location in ['any', 'tabulated']:
75
+ tabulated_file = tabulated_data_path / f"{filename}.yml"
76
+ if tabulated_file.exists():
77
+ tabulated_file.unlink()
78
+
79
+
80
+
81
+ remove_element('test')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyOptik
3
- Version: 1.3.0.post0
3
+ Version: 1.3.1.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
@@ -60,24 +60,6 @@ Requires-Dist: sphinx-gallery==0.15.0; extra == "documentation"
60
60
  Requires-Dist: sphinx-rtd-theme==2.0.0; extra == "documentation"
61
61
  Requires-Dist: pydata-sphinx-theme==0.14.1; extra == "documentation"
62
62
 
63
- .. |python| image:: https://img.shields.io/pypi/pyversions/pyoptik.svg
64
- :target: https://www.python.org/
65
-
66
- .. |Logo| image:: https://github.com/MartinPdeS/PyOptik/raw/master/docs/images/logo.png
67
-
68
- .. |docs| image:: https://readthedocs.org/projects/pyoptik/badge/?version=latest
69
- :target: https://pyoptik.readthedocs.io/en/latest/
70
-
71
- .. |PyPi| image:: https://badge.fury.io/py/pyoptik.svg
72
- :target: https://badge.fury.io/py/pyoptik
73
-
74
- .. |PyPi_download| image:: https://img.shields.io/pypi/dm/pyoptik.svg
75
- :target: https://pypistats.org/packages/pyoptik
76
-
77
- .. |coverage| image:: https://raw.githubusercontent.com/MartinPdeS/PyOptik/python-coverage-comment-action-data/badge.svg
78
- :alt: Unittest coverage
79
- :target: https://htmlpreview.github.io/?https://github.com/MartinPdeS/PyOptik/blob/python-coverage-comment-action-data/htmlcov/index.html
80
-
81
63
  PyOptik
82
64
  =======
83
65
 
@@ -117,13 +99,11 @@ After installing PyOptik, you can easily access material properties:
117
99
  n = bk7.compute_refractive_index(0.55e-6)
118
100
  print(f"Refractive index at 0.55 µm: {n}")
119
101
 
120
- # Accessing and plotting material properties
121
- bk7.plot(wavelength_range=[0.3e-6, 2.5e-6])
122
102
 
123
103
  Example
124
104
  *******
125
105
 
126
- Here’s a quick example demonstrating how to use PyOptik to retrieve and plot the refractive index of a material:
106
+ Here is a quick example demonstrating how to use PyOptik to retrieve and plot the refractive index of a material:
127
107
 
128
108
  .. code:: python
129
109
 
@@ -138,7 +118,34 @@ Here’s a quick example demonstrating how to use PyOptik to retrieve and plot t
138
118
  n_values = bk7.compute_refractive_index(wavelengths)
139
119
 
140
120
  # Plot the results
141
- bk7.plot(wavelength_range=wavelengths)
121
+ bk7.plot()
122
+
123
+ This code produces the following figure:
124
+
125
+ |example_bk7|
126
+
127
+
128
+ You can also add a custom element to your library providing a URL from `refractiveindex.info <https://refractiveindex.info>`_ website.
129
+
130
+ .. code:: python
131
+
132
+ from PyOptik.utils import download_yml_file
133
+ from PyOptik.directories import sellmeier_data_path # or tabulated_data_path for tabulated elements
134
+
135
+ download_yml_file(
136
+ filename='test',
137
+ url='https://refractiveindex.info/database/data-nk/main/H2O/Daimon-19.0C.yml',
138
+ location=tabulated_data_path
139
+ )
140
+
141
+ Evidently, you can also remove element from the library using as follows:
142
+
143
+
144
+ .. code:: python
145
+
146
+ from PyOptik.utils import remove_element
147
+
148
+ remove_element(filename='test', location='any') # location can be "any", "sellmeier" or "tabulated"
142
149
 
143
150
  Testing
144
151
  *******
@@ -168,3 +175,22 @@ As of 2024, PyOptik is still under development. If you would like to collaborate
168
175
 
169
176
 
170
177
 
178
+ .. |python| image:: https://img.shields.io/pypi/pyversions/pyoptik.svg
179
+ :target: https://www.python.org/
180
+
181
+ .. |Logo| image:: https://github.com/MartinPdeS/PyOptik/raw/master/docs/images/logo.png
182
+
183
+ .. |example_bk7| image:: https://github.com/MartinPdeS/PyOptik/blob/master/docs/images/example_bk7.png
184
+
185
+ .. |docs| image:: https://readthedocs.org/projects/pyoptik/badge/?version=latest
186
+ :target: https://pyoptik.readthedocs.io/en/latest/
187
+
188
+ .. |PyPi| image:: https://badge.fury.io/py/pyoptik.svg
189
+ :target: https://badge.fury.io/py/pyoptik
190
+
191
+ .. |PyPi_download| image:: https://img.shields.io/pypi/dm/pyoptik.svg
192
+ :target: https://pypistats.org/packages/pyoptik
193
+
194
+ .. |coverage| image:: https://raw.githubusercontent.com/MartinPdeS/PyOptik/python-coverage-comment-action-data/badge.svg
195
+ :alt: Unittest coverage
196
+ :target: https://htmlpreview.github.io/?https://github.com/MartinPdeS/PyOptik/blob/python-coverage-comment-action-data/htmlcov/index.html
@@ -40,7 +40,6 @@ PyOptik/data/sellmeier/polystyren.yml
40
40
  PyOptik/data/sellmeier/silica.yml
41
41
  PyOptik/data/sellmeier/silicon.yml
42
42
  PyOptik/data/sellmeier/soda_lime_glass.yml
43
- PyOptik/data/sellmeier/test.yml
44
43
  PyOptik/data/sellmeier/water.yml
45
44
  PyOptik/data/tabulated/__init__.py
46
45
  PyOptik/data/tabulated/aluminium.yml
@@ -52,9 +51,7 @@ PyOptik/data/tabulated/iron.yml
52
51
  PyOptik/data/tabulated/nickel.yml
53
52
  PyOptik/data/tabulated/silver.yml
54
53
  PyOptik/data/tabulated/sodium.yml
55
- PyOptik/data/tabulated/test.yml
56
54
  PyOptik/data/tabulated/zinc.yml
57
- developments/testing.py
58
55
  docs/Makefile
59
56
  docs/make.bat
60
57
  docs/deprecated/experiment_material.py
@@ -64,6 +61,7 @@ docs/examples/plot_sf5.py
64
61
  docs/examples/plot_silica.py
65
62
  docs/examples/plot_silver.py
66
63
  docs/examples/plot_water.py
64
+ docs/images/example_bk7.png
67
65
  docs/images/logo.png
68
66
  docs/source/code.rst
69
67
  docs/source/conf.py
@@ -97,7 +95,7 @@ docs/source/gallery/images/thumb/sphx_glr_get_values_thumb.png
97
95
  docs/source/gallery/images/thumb/sphx_glr_plot_sellmeier_0_thumb.png
98
96
  docs/source/gallery/images/thumb/sphx_glr_plot_sellmeier_1_thumb.png
99
97
  tests/__init__.py
100
- tests/test_extra.py
101
98
  tests/test_sellmeier.py
102
99
  tests/test_tabulated.py
103
- tests/test_usual_material.py
100
+ tests/test_usual_material.py
101
+ tests/test_utils.py
@@ -1,21 +1,3 @@
1
- .. |python| image:: https://img.shields.io/pypi/pyversions/pyoptik.svg
2
- :target: https://www.python.org/
3
-
4
- .. |Logo| image:: https://github.com/MartinPdeS/PyOptik/raw/master/docs/images/logo.png
5
-
6
- .. |docs| image:: https://readthedocs.org/projects/pyoptik/badge/?version=latest
7
- :target: https://pyoptik.readthedocs.io/en/latest/
8
-
9
- .. |PyPi| image:: https://badge.fury.io/py/pyoptik.svg
10
- :target: https://badge.fury.io/py/pyoptik
11
-
12
- .. |PyPi_download| image:: https://img.shields.io/pypi/dm/pyoptik.svg
13
- :target: https://pypistats.org/packages/pyoptik
14
-
15
- .. |coverage| image:: https://raw.githubusercontent.com/MartinPdeS/PyOptik/python-coverage-comment-action-data/badge.svg
16
- :alt: Unittest coverage
17
- :target: https://htmlpreview.github.io/?https://github.com/MartinPdeS/PyOptik/blob/python-coverage-comment-action-data/htmlcov/index.html
18
-
19
1
  PyOptik
20
2
  =======
21
3
 
@@ -55,13 +37,11 @@ After installing PyOptik, you can easily access material properties:
55
37
  n = bk7.compute_refractive_index(0.55e-6)
56
38
  print(f"Refractive index at 0.55 µm: {n}")
57
39
 
58
- # Accessing and plotting material properties
59
- bk7.plot(wavelength_range=[0.3e-6, 2.5e-6])
60
40
 
61
41
  Example
62
42
  *******
63
43
 
64
- Here’s a quick example demonstrating how to use PyOptik to retrieve and plot the refractive index of a material:
44
+ Here is a quick example demonstrating how to use PyOptik to retrieve and plot the refractive index of a material:
65
45
 
66
46
  .. code:: python
67
47
 
@@ -76,7 +56,34 @@ Here’s a quick example demonstrating how to use PyOptik to retrieve and plot t
76
56
  n_values = bk7.compute_refractive_index(wavelengths)
77
57
 
78
58
  # Plot the results
79
- bk7.plot(wavelength_range=wavelengths)
59
+ bk7.plot()
60
+
61
+ This code produces the following figure:
62
+
63
+ |example_bk7|
64
+
65
+
66
+ You can also add a custom element to your library providing a URL from `refractiveindex.info <https://refractiveindex.info>`_ website.
67
+
68
+ .. code:: python
69
+
70
+ from PyOptik.utils import download_yml_file
71
+ from PyOptik.directories import sellmeier_data_path # or tabulated_data_path for tabulated elements
72
+
73
+ download_yml_file(
74
+ filename='test',
75
+ url='https://refractiveindex.info/database/data-nk/main/H2O/Daimon-19.0C.yml',
76
+ location=tabulated_data_path
77
+ )
78
+
79
+ Evidently, you can also remove element from the library using as follows:
80
+
81
+
82
+ .. code:: python
83
+
84
+ from PyOptik.utils import remove_element
85
+
86
+ remove_element(filename='test', location='any') # location can be "any", "sellmeier" or "tabulated"
80
87
 
81
88
  Testing
82
89
  *******
@@ -106,3 +113,22 @@ As of 2024, PyOptik is still under development. If you would like to collaborate
106
113
 
107
114
 
108
115
 
116
+ .. |python| image:: https://img.shields.io/pypi/pyversions/pyoptik.svg
117
+ :target: https://www.python.org/
118
+
119
+ .. |Logo| image:: https://github.com/MartinPdeS/PyOptik/raw/master/docs/images/logo.png
120
+
121
+ .. |example_bk7| image:: https://github.com/MartinPdeS/PyOptik/blob/master/docs/images/example_bk7.png
122
+
123
+ .. |docs| image:: https://readthedocs.org/projects/pyoptik/badge/?version=latest
124
+ :target: https://pyoptik.readthedocs.io/en/latest/
125
+
126
+ .. |PyPi| image:: https://badge.fury.io/py/pyoptik.svg
127
+ :target: https://badge.fury.io/py/pyoptik
128
+
129
+ .. |PyPi_download| image:: https://img.shields.io/pypi/dm/pyoptik.svg
130
+ :target: https://pypistats.org/packages/pyoptik
131
+
132
+ .. |coverage| image:: https://raw.githubusercontent.com/MartinPdeS/PyOptik/python-coverage-comment-action-data/badge.svg
133
+ :alt: Unittest coverage
134
+ :target: https://htmlpreview.github.io/?https://github.com/MartinPdeS/PyOptik/blob/python-coverage-comment-action-data/htmlcov/index.html
@@ -5,8 +5,6 @@ from unittest.mock import patch
5
5
  import pytest
6
6
  from PyOptik.material import SellmeierMaterial as Material
7
7
  from PyOptik.data.sellmeier import material_list
8
- from PyOptik.utils import download_yml_file
9
- from PyOptik.directories import tabulated_data_path
10
8
  import matplotlib.pyplot as plt
11
9
 
12
10
 
@@ -31,13 +29,6 @@ def test_material_plot(mock_show, material: str):
31
29
  plt.close()
32
30
 
33
31
 
34
- def test_download_yml():
35
- download_yml_file(
36
- filename='test',
37
- url='https://refractiveindex.info/database/data-nk/main/H2O/Daimon-19.0C.yml',
38
- location=tabulated_data_path
39
- )
40
-
41
32
  if __name__ == "__main__":
42
33
  pytest.main([__file__])
43
34
 
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ import pytest
5
+ from PyOptik.utils import build_default_library, remove_element, download_yml_file
6
+ from PyOptik.directories import tabulated_data_path, sellmeier_data_path
7
+
8
+ def test_download_yml():
9
+ download_yml_file(
10
+ filename='test',
11
+ url='https://refractiveindex.info/database/data-nk/main/H2O/Daimon-19.0C.yml',
12
+ location=tabulated_data_path
13
+ )
14
+
15
+ download_yml_file(
16
+ filename='test',
17
+ url='https://refractiveindex.info/database/data-nk/main/H2O/Daimon-19.0C.yml',
18
+ location=sellmeier_data_path
19
+ )
20
+
21
+ def test_build_default_library():
22
+ build_default_library()
23
+
24
+ def test_remove_element():
25
+ remove_element(filename='test', location='any')
26
+
27
+ if __name__ == "__main__":
28
+ pytest.main([__file__])
@@ -1,14 +0,0 @@
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: "M. Daimon and A. Masumura. Measurement of the refractive index of distilled water from the near-infrared region to the ultraviolet region, <a href=\"https://doi.org/10.1364/AO.46.003811\"><i>Appl. Opt.</i> <b>46</b>, 3811-3820 (2007)</a>"
6
- COMMENTS: "High performance liquid chromatography (HPLC) distilled water at 19.0 °C."
7
- DATA:
8
- - type: formula 2
9
- wavelength_range: 0.182 1.129
10
- coefficients: 0 5.672526103E-1 5.085550461E-3 1.736581125E-1 1.814938654E-2 2.121531502E-2 2.617260739E-2 1.138493213E-1 1.073888649E1
11
- SPECS:
12
- n_is_absolute: true
13
- wavelength_is_vacuum: true
14
- temperature: 19.0 °C
@@ -1,14 +0,0 @@
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: "M. Daimon and A. Masumura. Measurement of the refractive index of distilled water from the near-infrared region to the ultraviolet region, <a href=\"https://doi.org/10.1364/AO.46.003811\"><i>Appl. Opt.</i> <b>46</b>, 3811-3820 (2007)</a>"
6
- COMMENTS: "High performance liquid chromatography (HPLC) distilled water at 19.0 °C."
7
- DATA:
8
- - type: formula 2
9
- wavelength_range: 0.182 1.129
10
- coefficients: 0 5.672526103E-1 5.085550461E-3 1.736581125E-1 1.814938654E-2 2.121531502E-2 2.617260739E-2 1.138493213E-1 1.073888649E1
11
- SPECS:
12
- n_is_absolute: true
13
- wavelength_is_vacuum: true
14
- temperature: 19.0 °C
@@ -1,12 +0,0 @@
1
- import numpy as np
2
- from PyOptik import UsualMaterial
3
-
4
- # Define wavelength range
5
- wavelengths = np.linspace(0.3e-6, 2.5e-6, 100)
6
-
7
- # Retrieve refractive index for BK7 glass
8
- bk7 = UsualMaterial.BK7
9
- n_values = bk7.compute_refractive_index(wavelengths)
10
-
11
- # Plot the results
12
- bk7.plot(wavelength_range=wavelengths)
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
-
4
- import pytest
5
- from unittest.mock import patch
6
- from PyOptik.utils import build_default_library
7
-
8
- def test_build_default_library():
9
- build_default_library()
10
-
11
- if __name__ == "__main__":
12
- pytest.main([__file__])
File without changes
File without changes