pymodaq_utils 0.0.2__py3-none-any.whl
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.
- pymodaq_utils/__init__.py +35 -0
- pymodaq_utils/abstract.py +48 -0
- pymodaq_utils/array_manipulation.py +386 -0
- pymodaq_utils/config.py +379 -0
- pymodaq_utils/enums.py +72 -0
- pymodaq_utils/factory.py +82 -0
- pymodaq_utils/icon.ico +0 -0
- pymodaq_utils/logger.py +78 -0
- pymodaq_utils/math_utils.py +584 -0
- pymodaq_utils/resources/__init__.py +0 -0
- pymodaq_utils/resources/config_template.toml +96 -0
- pymodaq_utils/resources/hatch_build_plugins.py +41 -0
- pymodaq_utils/splash.png +0 -0
- pymodaq_utils/units.py +216 -0
- pymodaq_utils/utils.py +649 -0
- pymodaq_utils/warnings.py +10 -0
- pymodaq_utils-0.0.2.dist-info/METADATA +152 -0
- pymodaq_utils-0.0.2.dist-info/RECORD +20 -0
- pymodaq_utils-0.0.2.dist-info/WHEEL +4 -0
- pymodaq_utils-0.0.2.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from hatchling.metadata.plugin.interface import MetadataHookInterface
|
|
3
|
+
import toml
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class PluginInfoTomlHook(MetadataHookInterface):
|
|
7
|
+
def update_custom(self, metadata: dict, here: Path) -> None:
|
|
8
|
+
src_file = here.joinpath('plugin_info.toml')
|
|
9
|
+
src_dict = toml.load(src_file)
|
|
10
|
+
|
|
11
|
+
SHORT_PLUGIN_NAME: str = src_dict['plugin-info']['SHORT_PLUGIN_NAME']
|
|
12
|
+
PLUGIN_NAME = f"pymodaq_plugins_{SHORT_PLUGIN_NAME}"
|
|
13
|
+
|
|
14
|
+
metadata['authors'] = [{'name': src_dict['plugin-info']['author'],
|
|
15
|
+
'email': src_dict['plugin-info']['author-email']}]
|
|
16
|
+
metadata['name'] = PLUGIN_NAME
|
|
17
|
+
metadata['dependencies'] = src_dict['plugin-install']['packages-required']
|
|
18
|
+
metadata['description'] = src_dict['plugin-info']['description']
|
|
19
|
+
metadata['urls'] = {}
|
|
20
|
+
metadata['urls']['Homepage'] = src_dict['plugin-info']['package-url']
|
|
21
|
+
metadata['urls']['Documentation '] = src_dict['plugin-info']['package-url']
|
|
22
|
+
metadata['urls']['Repository '] = src_dict['plugin-info']['package-url']
|
|
23
|
+
|
|
24
|
+
entrypoints = {}
|
|
25
|
+
if 'features' in src_dict:
|
|
26
|
+
if src_dict['features'].get('instruments', False):
|
|
27
|
+
entrypoints['pymodaq.instruments'] = {SHORT_PLUGIN_NAME: PLUGIN_NAME}
|
|
28
|
+
if src_dict['features'].get('extensions', False):
|
|
29
|
+
entrypoints['pymodaq.extensions'] = {SHORT_PLUGIN_NAME: PLUGIN_NAME}
|
|
30
|
+
if src_dict['features'].get('pid_models', False):
|
|
31
|
+
entrypoints['pymodaq.pid_models'] = {SHORT_PLUGIN_NAME: PLUGIN_NAME}
|
|
32
|
+
if src_dict['features'].get('h5exporters', False):
|
|
33
|
+
entrypoints['pymodaq.h5exporters'] = {SHORT_PLUGIN_NAME: PLUGIN_NAME}
|
|
34
|
+
if src_dict['features'].get('scanners', False):
|
|
35
|
+
entrypoints['pymodaq.scanners'] = {SHORT_PLUGIN_NAME: PLUGIN_NAME}
|
|
36
|
+
else:
|
|
37
|
+
entrypoints['pymodaq.instruments'] = {SHORT_PLUGIN_NAME: PLUGIN_NAME}
|
|
38
|
+
|
|
39
|
+
entrypoints['pymodaq.plugins'] = {SHORT_PLUGIN_NAME: PLUGIN_NAME}
|
|
40
|
+
# generic plugin, usefull for the plugin manager
|
|
41
|
+
metadata['entry-points'] = entrypoints
|
pymodaq_utils/splash.png
ADDED
|
Binary file
|
pymodaq_utils/units.py
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Created the 27/10/2022
|
|
4
|
+
|
|
5
|
+
@author: Sebastien Weber
|
|
6
|
+
"""
|
|
7
|
+
import numpy as np
|
|
8
|
+
|
|
9
|
+
Cb = 1.602176e-19 # coulomb
|
|
10
|
+
h = 6.626068e-34 # J.s
|
|
11
|
+
c = 2.997924586e8 # m.s-1
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def Enm2cmrel(E_nm, ref_wavelength=515):
|
|
15
|
+
"""Converts energy in nm to cm-1 relative to a ref wavelength
|
|
16
|
+
|
|
17
|
+
Parameters
|
|
18
|
+
----------
|
|
19
|
+
E_nm: float
|
|
20
|
+
photon energy in wavelength (nm)
|
|
21
|
+
ref_wavelength: float
|
|
22
|
+
reference wavelength in nm from which calculate the photon relative energy
|
|
23
|
+
|
|
24
|
+
Returns
|
|
25
|
+
-------
|
|
26
|
+
float
|
|
27
|
+
photon energy in cm-1 relative to the ref wavelength
|
|
28
|
+
|
|
29
|
+
Examples
|
|
30
|
+
--------
|
|
31
|
+
>>> Enm2cmrel(530, 515)
|
|
32
|
+
549.551199853453
|
|
33
|
+
"""
|
|
34
|
+
return 1 / (ref_wavelength * 1e-7) - 1 / (E_nm * 1e-7)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def Ecmrel2Enm(Ecmrel, ref_wavelength=515):
|
|
38
|
+
"""Converts energy from cm-1 relative to a ref wavelength to an energy in wavelength (nm)
|
|
39
|
+
|
|
40
|
+
Parameters
|
|
41
|
+
----------
|
|
42
|
+
Ecmrel: float
|
|
43
|
+
photon energy in cm-1
|
|
44
|
+
ref_wavelength: float
|
|
45
|
+
reference wavelength in nm from which calculate the photon relative energy
|
|
46
|
+
|
|
47
|
+
Returns
|
|
48
|
+
-------
|
|
49
|
+
float
|
|
50
|
+
photon energy in nm
|
|
51
|
+
|
|
52
|
+
Examples
|
|
53
|
+
--------
|
|
54
|
+
>>> Ecmrel2Enm(500, 515)
|
|
55
|
+
528.6117526302285
|
|
56
|
+
"""
|
|
57
|
+
Ecm = 1 / (ref_wavelength * 1e-7) - Ecmrel
|
|
58
|
+
return 1 / (Ecm * 1e-7)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def eV2nm(E_eV):
|
|
62
|
+
"""Converts photon energy from electronvolt to wavelength in nm
|
|
63
|
+
|
|
64
|
+
Parameters
|
|
65
|
+
----------
|
|
66
|
+
E_eV: float
|
|
67
|
+
Photon energy in eV
|
|
68
|
+
|
|
69
|
+
Returns
|
|
70
|
+
-------
|
|
71
|
+
float
|
|
72
|
+
photon energy in nm
|
|
73
|
+
|
|
74
|
+
Examples
|
|
75
|
+
--------
|
|
76
|
+
>>> eV2nm(1.55)
|
|
77
|
+
799.898112990037
|
|
78
|
+
"""
|
|
79
|
+
E_J = E_eV * Cb
|
|
80
|
+
E_freq = E_J / h
|
|
81
|
+
E_nm = c / E_freq * 1e9
|
|
82
|
+
return E_nm
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def nm2eV(E_nm):
|
|
86
|
+
"""Converts photon energy from wavelength in nm to electronvolt
|
|
87
|
+
|
|
88
|
+
Parameters
|
|
89
|
+
----------
|
|
90
|
+
E_nm: float
|
|
91
|
+
Photon energy in nm
|
|
92
|
+
|
|
93
|
+
Returns
|
|
94
|
+
-------
|
|
95
|
+
float
|
|
96
|
+
photon energy in eV
|
|
97
|
+
|
|
98
|
+
Examples
|
|
99
|
+
--------
|
|
100
|
+
>>> nm2eV(800)
|
|
101
|
+
1.549802593918197
|
|
102
|
+
"""
|
|
103
|
+
E_freq = c / E_nm * 1e9
|
|
104
|
+
E_J = E_freq * h
|
|
105
|
+
E_eV = E_J / Cb
|
|
106
|
+
return E_eV
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def E_J2eV(E_J):
|
|
110
|
+
E_eV = E_J / Cb
|
|
111
|
+
return E_eV
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def eV2cm(E_eV):
|
|
115
|
+
"""Converts photon energy from electronvolt to absolute cm-1
|
|
116
|
+
|
|
117
|
+
Parameters
|
|
118
|
+
----------
|
|
119
|
+
E_eV: float
|
|
120
|
+
Photon energy in eV
|
|
121
|
+
|
|
122
|
+
Returns
|
|
123
|
+
-------
|
|
124
|
+
float
|
|
125
|
+
photon energy in cm-1
|
|
126
|
+
|
|
127
|
+
Examples
|
|
128
|
+
--------
|
|
129
|
+
>>> eV2cm(0.07)
|
|
130
|
+
564.5880342655984
|
|
131
|
+
"""
|
|
132
|
+
E_nm = eV2nm(E_eV)
|
|
133
|
+
E_cm = 1 / (E_nm * 1e-7)
|
|
134
|
+
return E_cm
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def nm2cm(E_nm):
|
|
138
|
+
"""Converts photon energy from wavelength to absolute cm-1
|
|
139
|
+
|
|
140
|
+
Parameters
|
|
141
|
+
----------
|
|
142
|
+
E_nm: float
|
|
143
|
+
Photon energy in nm
|
|
144
|
+
|
|
145
|
+
Returns
|
|
146
|
+
-------
|
|
147
|
+
float
|
|
148
|
+
photon energy in cm-1
|
|
149
|
+
|
|
150
|
+
Examples
|
|
151
|
+
--------
|
|
152
|
+
>>> nm2cm(0.04)
|
|
153
|
+
0.000025
|
|
154
|
+
"""
|
|
155
|
+
return 1 / (E_nm * 1e7)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def cm2nm(E_cm):
|
|
159
|
+
"""Converts photon energy from absolute cm-1 to wavelength
|
|
160
|
+
|
|
161
|
+
Parameters
|
|
162
|
+
----------
|
|
163
|
+
E_cm: float
|
|
164
|
+
photon energy in cm-1
|
|
165
|
+
|
|
166
|
+
Returns
|
|
167
|
+
-------
|
|
168
|
+
float
|
|
169
|
+
Photon energy in nm
|
|
170
|
+
|
|
171
|
+
Examples
|
|
172
|
+
--------
|
|
173
|
+
>>> cm2nm(1e5)
|
|
174
|
+
100
|
|
175
|
+
"""
|
|
176
|
+
return 1 / (E_cm * 1e-7)
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def eV2E_J(E_eV):
|
|
180
|
+
E_J = E_eV * Cb
|
|
181
|
+
return E_J
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def eV2radfs(E_eV):
|
|
185
|
+
E_J = E_eV * Cb
|
|
186
|
+
E_freq = E_J / h
|
|
187
|
+
E_radfs = E_freq * 2 * np.pi / 1e15
|
|
188
|
+
return E_radfs
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def l2w(x, speedlight=300):
|
|
192
|
+
"""Converts photon energy in rad/fs to nm (and vice-versa)
|
|
193
|
+
|
|
194
|
+
Parameters
|
|
195
|
+
----------
|
|
196
|
+
x: float
|
|
197
|
+
photon energy in wavelength or rad/fs
|
|
198
|
+
speedlight: float, optional
|
|
199
|
+
the speed of light, by default 300 nm/fs
|
|
200
|
+
|
|
201
|
+
Returns
|
|
202
|
+
-------
|
|
203
|
+
float
|
|
204
|
+
|
|
205
|
+
Examples
|
|
206
|
+
--------
|
|
207
|
+
>>> l2w(800)
|
|
208
|
+
2.356194490192345
|
|
209
|
+
>>> l2w(800,3e8)
|
|
210
|
+
2356194.490192345
|
|
211
|
+
"""
|
|
212
|
+
y = 2 * np.pi * speedlight / x
|
|
213
|
+
return y
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|