pyTEMlib 0.2025.4.2__py3-none-any.whl → 0.2025.9.1__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.
Potentially problematic release.
This version of pyTEMlib might be problematic. Click here for more details.
- build/lib/pyTEMlib/__init__.py +33 -0
- build/lib/pyTEMlib/animation.py +640 -0
- build/lib/pyTEMlib/atom_tools.py +238 -0
- build/lib/pyTEMlib/config_dir.py +31 -0
- build/lib/pyTEMlib/crystal_tools.py +1219 -0
- build/lib/pyTEMlib/diffraction_plot.py +756 -0
- build/lib/pyTEMlib/dynamic_scattering.py +293 -0
- build/lib/pyTEMlib/eds_tools.py +826 -0
- build/lib/pyTEMlib/eds_xsections.py +432 -0
- build/lib/pyTEMlib/eels_tools/__init__.py +44 -0
- build/lib/pyTEMlib/eels_tools/core_loss_tools.py +751 -0
- build/lib/pyTEMlib/eels_tools/eels_database.py +134 -0
- build/lib/pyTEMlib/eels_tools/low_loss_tools.py +655 -0
- build/lib/pyTEMlib/eels_tools/peak_fit_tools.py +175 -0
- build/lib/pyTEMlib/eels_tools/zero_loss_tools.py +264 -0
- build/lib/pyTEMlib/file_reader.py +274 -0
- build/lib/pyTEMlib/file_tools.py +811 -0
- build/lib/pyTEMlib/get_bote_salvat.py +69 -0
- build/lib/pyTEMlib/graph_tools.py +1153 -0
- build/lib/pyTEMlib/graph_viz.py +599 -0
- build/lib/pyTEMlib/image/__init__.py +37 -0
- build/lib/pyTEMlib/image/image_atoms.py +270 -0
- build/lib/pyTEMlib/image/image_clean.py +197 -0
- build/lib/pyTEMlib/image/image_distortion.py +299 -0
- build/lib/pyTEMlib/image/image_fft.py +277 -0
- build/lib/pyTEMlib/image/image_graph.py +926 -0
- build/lib/pyTEMlib/image/image_registration.py +316 -0
- build/lib/pyTEMlib/image/image_utilities.py +309 -0
- build/lib/pyTEMlib/image/image_window.py +421 -0
- build/lib/pyTEMlib/image_tools.py +699 -0
- build/lib/pyTEMlib/interactive_image.py +1 -0
- build/lib/pyTEMlib/kinematic_scattering.py +1196 -0
- build/lib/pyTEMlib/microscope.py +61 -0
- build/lib/pyTEMlib/probe_tools.py +906 -0
- build/lib/pyTEMlib/sidpy_tools.py +153 -0
- build/lib/pyTEMlib/simulation_tools.py +104 -0
- build/lib/pyTEMlib/test.py +437 -0
- build/lib/pyTEMlib/utilities.py +314 -0
- build/lib/pyTEMlib/version.py +5 -0
- build/lib/pyTEMlib/xrpa_x_sections.py +20976 -0
- pyTEMlib/__init__.py +25 -3
- pyTEMlib/animation.py +31 -22
- pyTEMlib/atom_tools.py +29 -34
- pyTEMlib/config_dir.py +2 -28
- pyTEMlib/crystal_tools.py +129 -165
- pyTEMlib/eds_tools.py +559 -342
- pyTEMlib/eds_xsections.py +432 -0
- pyTEMlib/eels_tools/__init__.py +44 -0
- pyTEMlib/eels_tools/core_loss_tools.py +751 -0
- pyTEMlib/eels_tools/eels_database.py +134 -0
- pyTEMlib/eels_tools/low_loss_tools.py +655 -0
- pyTEMlib/eels_tools/peak_fit_tools.py +175 -0
- pyTEMlib/eels_tools/zero_loss_tools.py +264 -0
- pyTEMlib/file_reader.py +274 -0
- pyTEMlib/file_tools.py +260 -1130
- pyTEMlib/get_bote_salvat.py +69 -0
- pyTEMlib/graph_tools.py +101 -174
- pyTEMlib/graph_viz.py +150 -0
- pyTEMlib/image/__init__.py +37 -0
- pyTEMlib/image/image_atoms.py +270 -0
- pyTEMlib/image/image_clean.py +197 -0
- pyTEMlib/image/image_distortion.py +299 -0
- pyTEMlib/image/image_fft.py +277 -0
- pyTEMlib/image/image_graph.py +926 -0
- pyTEMlib/image/image_registration.py +316 -0
- pyTEMlib/image/image_utilities.py +309 -0
- pyTEMlib/image/image_window.py +421 -0
- pyTEMlib/image_tools.py +154 -928
- pyTEMlib/kinematic_scattering.py +1 -1
- pyTEMlib/probe_tools.py +1 -1
- pyTEMlib/test.py +437 -0
- pyTEMlib/utilities.py +314 -0
- pyTEMlib/version.py +2 -3
- pyTEMlib/xrpa_x_sections.py +14 -10
- {pytemlib-0.2025.4.2.dist-info → pytemlib-0.2025.9.1.dist-info}/METADATA +13 -16
- pytemlib-0.2025.9.1.dist-info/RECORD +86 -0
- {pytemlib-0.2025.4.2.dist-info → pytemlib-0.2025.9.1.dist-info}/WHEEL +1 -1
- pytemlib-0.2025.9.1.dist-info/top_level.txt +6 -0
- pyTEMlib/core_loss_widget.py +0 -721
- pyTEMlib/eels_dialog.py +0 -754
- pyTEMlib/eels_dialog_utilities.py +0 -1199
- pyTEMlib/eels_tools.py +0 -2359
- pyTEMlib/file_tools_qt.py +0 -193
- pyTEMlib/image_dialog.py +0 -158
- pyTEMlib/image_dlg.py +0 -146
- pyTEMlib/info_widget.py +0 -1086
- pyTEMlib/info_widget3.py +0 -1120
- pyTEMlib/low_loss_widget.py +0 -479
- pyTEMlib/peak_dialog.py +0 -1129
- pyTEMlib/peak_dlg.py +0 -286
- pytemlib-0.2025.4.2.dist-info/RECORD +0 -38
- pytemlib-0.2025.4.2.dist-info/top_level.txt +0 -1
- {pytemlib-0.2025.4.2.dist-info → pytemlib-0.2025.9.1.dist-info}/entry_points.txt +0 -0
- {pytemlib-0.2025.4.2.dist-info → pytemlib-0.2025.9.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"""
|
|
2
|
+
eels_tools
|
|
3
|
+
Model based quantification of electron energy-loss data
|
|
4
|
+
Copyright by Gerd Duscher
|
|
5
|
+
|
|
6
|
+
"""
|
|
7
|
+
import numpy as np
|
|
8
|
+
import requests
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
##########################
|
|
13
|
+
# EELS Database
|
|
14
|
+
##########################
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def read_msa(msa_string):
|
|
18
|
+
"""read msa formated file"""
|
|
19
|
+
parameters = {}
|
|
20
|
+
y = []
|
|
21
|
+
x = []
|
|
22
|
+
# Read the keywords
|
|
23
|
+
data_section = False
|
|
24
|
+
msa_lines = msa_string.split('\n')
|
|
25
|
+
|
|
26
|
+
for line in msa_lines:
|
|
27
|
+
if data_section is False:
|
|
28
|
+
if len(line) > 0:
|
|
29
|
+
if line[0] == "#":
|
|
30
|
+
try:
|
|
31
|
+
key, value = line.split(': ')
|
|
32
|
+
value = value.strip()
|
|
33
|
+
except ValueError:
|
|
34
|
+
key = line
|
|
35
|
+
value = None
|
|
36
|
+
key = key.strip('#').strip()
|
|
37
|
+
|
|
38
|
+
if key != 'SPECTRUM':
|
|
39
|
+
parameters[key] = value
|
|
40
|
+
else:
|
|
41
|
+
data_section = True
|
|
42
|
+
else:
|
|
43
|
+
# Read the data
|
|
44
|
+
|
|
45
|
+
if len(line) > 0 and line[0] != "#" and line.strip():
|
|
46
|
+
if parameters['DATATYPE'] == 'XY':
|
|
47
|
+
xy = line.replace(',', ' ').strip().split()
|
|
48
|
+
y.append(float(xy[1]))
|
|
49
|
+
x.append(float(xy[0]))
|
|
50
|
+
elif parameters['DATATYPE'] == 'Y':
|
|
51
|
+
print('y')
|
|
52
|
+
data = [
|
|
53
|
+
float(i) for i in line.replace(',', ' ').strip().split()]
|
|
54
|
+
y.extend(data)
|
|
55
|
+
parameters['data'] = np.array(y)
|
|
56
|
+
if 'XPERCHAN' in parameters:
|
|
57
|
+
parameters['XPERCHAN'] = str(parameters['XPERCHAN']).split(' ', maxsplit=1)[0]
|
|
58
|
+
parameters['OFFSET'] = str(parameters['OFFSET']).split(' ', maxsplit=1)[0]
|
|
59
|
+
dispersion = float(parameters['XPERCHAN']) # eV per channel
|
|
60
|
+
offset = float(parameters['OFFSET']) # eV offset
|
|
61
|
+
parameters['energy_scale'] = np.arange(len(y)) * dispersion + offset
|
|
62
|
+
return parameters
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def get_spectrum_eels_db(formula=None, edge=None, title=None, element=None):
|
|
66
|
+
"""
|
|
67
|
+
get spectra from EELS database
|
|
68
|
+
chemical formula and edge is accepted.
|
|
69
|
+
Could expose more of the search parameters
|
|
70
|
+
"""
|
|
71
|
+
valid_edges = ['K', 'L1', 'L2,3', 'M2,3', 'M4,5', 'N2,3', 'N4,5', 'O2,3', 'O4,5']
|
|
72
|
+
if edge is not None and edge not in valid_edges:
|
|
73
|
+
print('edge should be a in ', valid_edges)
|
|
74
|
+
|
|
75
|
+
spectrum_type = None
|
|
76
|
+
author = None
|
|
77
|
+
min_energy = None
|
|
78
|
+
max_energy = None
|
|
79
|
+
resolution = None
|
|
80
|
+
min_energy_compare = "gt"
|
|
81
|
+
max_energy_compare = "lt"
|
|
82
|
+
resolution_compare = "lt"
|
|
83
|
+
max_n = -1
|
|
84
|
+
monochromated = None
|
|
85
|
+
order = None
|
|
86
|
+
order_direction = "ASC"
|
|
87
|
+
verify_certificate = True
|
|
88
|
+
# Verify arguments
|
|
89
|
+
|
|
90
|
+
if spectrum_type is not None and spectrum_type not in {'coreloss', 'lowloss', 'zeroloss', 'xrayabs'}:
|
|
91
|
+
raise ValueError("spectrum_type must be one of \'coreloss\', \'lowloss\', "
|
|
92
|
+
"\'zeroloss\', \'xrayabs\'.")
|
|
93
|
+
# valid_edges = ['K', 'L1', 'L2,3', 'M2,3', 'M4,5', 'N2,3', 'N4,5', 'O2,3', 'O4,5']
|
|
94
|
+
|
|
95
|
+
params = {
|
|
96
|
+
"type": spectrum_type,
|
|
97
|
+
"title": title,
|
|
98
|
+
"author": author,
|
|
99
|
+
"edge": edge,
|
|
100
|
+
"min_energy": min_energy,
|
|
101
|
+
"max_energy": max_energy,
|
|
102
|
+
"resolution": resolution,
|
|
103
|
+
"resolution_compare": resolution_compare,
|
|
104
|
+
"monochromated": monochromated,
|
|
105
|
+
"formula": formula,
|
|
106
|
+
'element': element,
|
|
107
|
+
"min_energy_compare": min_energy_compare,
|
|
108
|
+
"max_energy_compare": max_energy_compare,
|
|
109
|
+
"per_page": max_n,
|
|
110
|
+
"order": order,
|
|
111
|
+
"order_direction": order_direction,
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
request = requests.get('http://api.eelsdb.eu/spectra', params=params, verify=True, timeout=10)
|
|
115
|
+
# spectra = []
|
|
116
|
+
jsons = request.json()
|
|
117
|
+
if "message" in jsons:
|
|
118
|
+
# Invalid query, EELSdb raises error.
|
|
119
|
+
raise IOError(
|
|
120
|
+
f"Please report the following error to the HyperSpy developers: ",
|
|
121
|
+
f"{jsons['message']}")
|
|
122
|
+
reference_spectra = {}
|
|
123
|
+
for json_spectrum in jsons:
|
|
124
|
+
download_link = json_spectrum['download_link']
|
|
125
|
+
# print(download_link)
|
|
126
|
+
msa_string = requests.get(download_link, verify=verify_certificate, timeout=10).text
|
|
127
|
+
# print(msa_string[:100])
|
|
128
|
+
parameters = read_msa(msa_string)
|
|
129
|
+
if 'XPERCHAN' in parameters:
|
|
130
|
+
reference_spectra[parameters['TITLE']] = parameters
|
|
131
|
+
print(parameters['TITLE'])
|
|
132
|
+
print(f'found {len(reference_spectra.keys())} spectra in EELS database)')
|
|
133
|
+
|
|
134
|
+
return reference_spectra
|