pyTEMlib 0.2020.11.1__py3-none-any.whl → 0.2024.8.4__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.

Files changed (60) hide show
  1. pyTEMlib/__init__.py +11 -11
  2. pyTEMlib/animation.py +631 -0
  3. pyTEMlib/atom_tools.py +240 -245
  4. pyTEMlib/config_dir.py +57 -33
  5. pyTEMlib/core_loss_widget.py +658 -0
  6. pyTEMlib/crystal_tools.py +1255 -0
  7. pyTEMlib/diffraction_plot.py +756 -0
  8. pyTEMlib/dynamic_scattering.py +293 -0
  9. pyTEMlib/eds_tools.py +609 -0
  10. pyTEMlib/eels_dialog.py +749 -491
  11. pyTEMlib/{interactive_eels.py → eels_dialog_utilities.py} +1199 -1177
  12. pyTEMlib/eels_tools.py +2031 -1698
  13. pyTEMlib/file_tools.py +1276 -560
  14. pyTEMlib/file_tools_qt.py +193 -0
  15. pyTEMlib/graph_tools.py +1166 -450
  16. pyTEMlib/graph_viz.py +449 -0
  17. pyTEMlib/image_dialog.py +158 -0
  18. pyTEMlib/image_dlg.py +146 -232
  19. pyTEMlib/image_tools.py +1399 -1028
  20. pyTEMlib/info_widget.py +933 -0
  21. pyTEMlib/interactive_image.py +1 -226
  22. pyTEMlib/kinematic_scattering.py +1196 -0
  23. pyTEMlib/low_loss_widget.py +176 -0
  24. pyTEMlib/microscope.py +61 -81
  25. pyTEMlib/peak_dialog.py +1047 -410
  26. pyTEMlib/peak_dlg.py +286 -242
  27. pyTEMlib/probe_tools.py +653 -207
  28. pyTEMlib/sidpy_tools.py +153 -136
  29. pyTEMlib/simulation_tools.py +104 -87
  30. pyTEMlib/version.py +6 -3
  31. pyTEMlib/xrpa_x_sections.py +20972 -0
  32. {pyTEMlib-0.2020.11.1.dist-info → pyTEMlib-0.2024.8.4.dist-info}/LICENSE +21 -21
  33. pyTEMlib-0.2024.8.4.dist-info/METADATA +93 -0
  34. pyTEMlib-0.2024.8.4.dist-info/RECORD +37 -0
  35. {pyTEMlib-0.2020.11.1.dist-info → pyTEMlib-0.2024.8.4.dist-info}/WHEEL +6 -5
  36. {pyTEMlib-0.2020.11.1.dist-info → pyTEMlib-0.2024.8.4.dist-info}/entry_points.txt +0 -1
  37. pyTEMlib/KinsCat.py +0 -2758
  38. pyTEMlib/__version__.py +0 -2
  39. pyTEMlib/data/TEMlibrc +0 -68
  40. pyTEMlib/data/edges_db.csv +0 -189
  41. pyTEMlib/data/edges_db.pkl +0 -0
  42. pyTEMlib/data/fparam.txt +0 -103
  43. pyTEMlib/data/microscopes.csv +0 -7
  44. pyTEMlib/data/microscopes.xml +0 -167
  45. pyTEMlib/data/path.txt +0 -1
  46. pyTEMlib/defaults_parser.py +0 -90
  47. pyTEMlib/dm3_reader.py +0 -613
  48. pyTEMlib/edges_db.py +0 -76
  49. pyTEMlib/eels_dlg.py +0 -224
  50. pyTEMlib/hdf_utils.py +0 -483
  51. pyTEMlib/image_tools1.py +0 -2194
  52. pyTEMlib/info_dialog.py +0 -237
  53. pyTEMlib/info_dlg.py +0 -202
  54. pyTEMlib/nion_reader.py +0 -297
  55. pyTEMlib/nsi_reader.py +0 -170
  56. pyTEMlib/structure_tools.py +0 -316
  57. pyTEMlib/test.py +0 -2072
  58. pyTEMlib-0.2020.11.1.dist-info/METADATA +0 -20
  59. pyTEMlib-0.2020.11.1.dist-info/RECORD +0 -45
  60. {pyTEMlib-0.2020.11.1.dist-info → pyTEMlib-0.2024.8.4.dist-info}/top_level.txt +0 -0
@@ -1,226 +1 @@
1
- """
2
- Interactive EELS provides dialogs for input
3
- """
4
- import numpy as np
5
-
6
- from PyQt5 import QtWidgets, QtCore, QtGui
7
- import sidpy
8
- import matplotlib.patches as patches
9
- from matplotlib.widgets import SpanSelector
10
-
11
- import matplotlib.pyplot as plt
12
-
13
- from IPython.display import display
14
- import ipywidgets as widgets
15
- from skimage import exposure
16
-
17
- from pyTEMlib import image_dlg
18
- import pyTEMlib.file_tools as ft
19
- import pyTEMlib.image_tools as it
20
- from pyTEMlib.microscope import microscope
21
-
22
- ###
23
-
24
- from matplotlib.figure import Figure
25
- from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as Canvas
26
-
27
-
28
- class ImageDialog(QtWidgets.QWidget):
29
- def __init__(self, dataset, parent=None):
30
- super(ImageDialog, self).__init__(parent, QtCore.Qt.WindowStaysOnTopHint)
31
-
32
- if dataset is None:
33
- # make a dummy dataset for testing
34
- dataset = ft.make_dummy_dataset(sidpy.DataTypes.IMAGE)
35
- if not isinstance(dataset, sidpy.Dataset):
36
- raise TypeError('dataset has to be a sidpy dataset')
37
-
38
- self.image_dims = ft.get_dimensions_by_type([sidpy.DimensionTypes.RECIPROCAL, sidpy.DimensionTypes.SPATIAL],
39
- dataset)
40
- if len(self.image_dims) != 2:
41
- raise TypeError('We need exactly two SPATIAL or RECIPROCAL dimensions')
42
- self.dim_x = self.image_dims[0][1]
43
- self.dim_y = self.image_dims[1][1]
44
- self.fov_x = 0.
45
- self.fov_y = 0.
46
- self.v_min = np.array(dataset).min()
47
- self.v_max = np.array(dataset).max()
48
-
49
- self.parent = parent
50
-
51
- self.ui = image_dlg.UiDialog(self)
52
-
53
- self.set_action()
54
-
55
- self.dataset = dataset
56
- self.image = np.array(self.dataset)
57
-
58
- self.experiment = {}
59
- self.set_dataset()
60
-
61
- self.dataset.plot()
62
- if hasattr(self.dataset.view, 'axes'):
63
- self.axis = self.dataset.view.axes[-1]
64
- elif hasattr(self.dataset.view, 'axis'):
65
- self.axis = self.dataset.view.axis
66
-
67
- self.figure = self.axis.figure
68
- self.plot()
69
- self.histogram()
70
-
71
- self.update()
72
-
73
- self.spatial_dlg = None
74
- self.histogram()
75
- self.cid = self.ui.histogram.axes.figure.canvas.mpl_connect('button_press_event', self.onclick)
76
-
77
- self.show()
78
-
79
- def histogram(self, bins=256):
80
- ax_hist = self.ui.histogram.axes
81
- ax_hist.clear()
82
-
83
- hist, bin_edges = np.histogram(self.image, bins=bins, range=[self.v_min, self.v_max], density=True)
84
- ax_hist.plot(np.array(bin_edges)[:-1], np.array(hist))
85
-
86
- ax_hist.set_yticks([])
87
- self.span = SpanSelector(self.ui.histogram.axes, self.on_select, 'horizontal', useblit=False,
88
- button=1,
89
- rectprops=dict(alpha=0.5, facecolor='blue'))
90
-
91
- image = self.image * 1.0
92
- image[image < self.v_min] = self.v_min
93
- image[image > self.v_max] = self.v_max
94
-
95
- img_cdf, bins = exposure.cumulative_distribution(np.array(image), bins)
96
- ax_hist.plot(bins, img_cdf * hist.max(), 'r')
97
- ax_hist.figure.canvas.draw()
98
-
99
- self.plot()
100
-
101
- def onclick(self, event):
102
- if event.dblclick:
103
- self.v_min = np.array(self.image).min()
104
- self.v_max = np.array(self.image).max()
105
- self.histogram()
106
-
107
- def on_select(self, v_min, v_max):
108
- self.v_min = v_min
109
- self.v_max = v_max
110
- # self.setWindowTitle(f'{v_min:.1f}, {v_max:.1f}')
111
- self.histogram()
112
-
113
- def plot(self):
114
- ax = self.dataset.view.axis
115
- img = self.dataset.view.img
116
- img.set_data(self.image)
117
- img.set_clim(vmin=self.v_min, vmax=self.v_max)
118
- self.dataset.view.axis.figure.canvas.draw()
119
-
120
- def update(self):
121
- self.ui.fovXEdit.setText(f'{self.fov_x:.2f}')
122
- self.ui.fovYEdit.setText(f'{self.fov_y:.2f}')
123
- self.ui.timeEdit.setText(f"{self.experiment['exposure_time'] :.2f}")
124
- self.ui.E0Edit.setText(f"{self.experiment['acceleration_voltage']/1000.:.2f}")
125
- self.ui.collEdit.setText(f"{self.experiment['collection_angle']:.2f}")
126
- self.ui.convEdit.setText(f"{self.experiment['convergence_angle']:.2f}")
127
- self.ui.fluxEdit.setText(f"{self.experiment['flux']:.2f}")
128
-
129
- def set_dataset(self):
130
- extent = self.dataset.get_extent([self.image_dims[0][0], self.image_dims[1][0]])
131
- self.fov_x = extent[1]-extent[0]
132
- self.fov_y = extent[2]-extent[3]
133
-
134
- self.ui.fovXUnit.setText(self.dim_x.units)
135
- self.ui.fovYUnit.setText(self.dim_y.units)
136
-
137
- minimum_info = {'FOV_x': self.fov_x,
138
- 'FOV_y': self.fov_y,
139
- 'exposure_time': 0.0,
140
- 'convergence_angle': 0.0, 'collection_angle': 0.0,
141
- 'acceleration_voltage': 0.0,
142
- 'flux': 0.0}
143
-
144
- if 'experiment' not in self.dataset.metadata:
145
- self.dataset.metadata['experiment'] = {}
146
- if 'DM' in self.dataset.original_metadata:
147
- self.dataset.metadata['experiment'].update(it.read_dm3_image_info(self.dataset.original_metadata))
148
-
149
- self.experiment = self.dataset.metadata['experiment']
150
- for key, value in minimum_info.items():
151
- if key not in self.experiment:
152
- self.experiment[key] = value
153
- def on_enter(self):
154
- sender = self.sender()
155
- if sender == self.ui.E0Edit:
156
- self.experiment['acceleration_voltage'] = float(self.ui.E0Edit.displayText())
157
- elif sender == self.ui.collEdit:
158
- self.experiment['collection_angle'] = float(self.ui.collEdit.displayText())
159
- elif sender == self.ui.convEdit:
160
- self.experiment['convergence_angle'] = float(self.ui.convEdit.displayText())
161
- elif sender == self.ui.timeEdit:
162
- self.experiment['exposure_time'] = float(self.ui.timeEdit.displayText())
163
- elif sender == self.ui.fovXEdit:
164
- self.experiment['FOV_x'] = float(self.ui.fovXEdit.displayText())
165
- elif sender == self.ui.fovYEdit:
166
- self.experiment['FOV_y'] = float(self.ui.fovYEdit.displayText())
167
- elif sender == self.ui.fluxEdit:
168
- self.experiment['flux'] = float(self.ui.fluxEdit.displayText())
169
- self.update()
170
-
171
- def on_list_enter(self):
172
- sender = self.sender()
173
- if sender == self.ui.TEMList:
174
- microscope.set_microscope(self.ui.TEMList.currentText())
175
- self.experiment['microscope'] = microscope.name
176
- self.experiment['convergence_angle'] = microscope.alpha
177
- self.experiment['collection_angle'] = microscope.beta
178
- self.experiment['acceleration_voltage'] = microscope.E0
179
- self.update()
180
-
181
-
182
- def on_check_enter(self):
183
- sender = self.sender()
184
- if sender == self.ui.logCheck:
185
- if self.ui.logCheck.isChecked():
186
- self.ui.gammaCheck.setChecked(False)
187
- self.log_gamma = 1.0
188
- self.ui.gammaEdit.setText(f'{self.log_gamma:.2f}')
189
- self.image = np.log(1.0+np.array(self.dataset-self.dataset.min()+1e-12))
190
- self.image = np.nan_to_num(self.image)
191
- self.v_min = self.image.min()
192
- self.v_max = self.image.max()
193
- else:
194
- self.image = np.array(self.dataset-self.dataset.min())
195
- self.v_min = self.image.min()
196
- self.v_max = self.image.max()
197
- self.histogram()
198
-
199
- elif sender == self.ui.gammaCheck:
200
- if self.ui.gammaCheck.isChecked():
201
- self.ui.logCheck.setChecked(False)
202
- self.gamma = 0.8
203
- self.ui.gammaEdit.setText(f'{self.gamma:.2f}')
204
- self.image = np.array(self.dataset)**self.gamma
205
- self.v_min = self.image.min()
206
- self.v_max = self.image.max()
207
- else:
208
- self.image = np.array(self.dataset)
209
- self.v_min = self.image.min()
210
- self.v_max = self.image.max()
211
- self.histogram()
212
-
213
- def set_action(self):
214
- self.ui.fovXEdit.editingFinished.connect(self.on_enter)
215
- self.ui.fovYEdit.editingFinished.connect(self.on_enter)
216
-
217
- self.ui.timeEdit.editingFinished.connect(self.on_enter)
218
- self.ui.E0Edit.editingFinished.connect(self.on_enter)
219
- self.ui.collEdit.editingFinished.connect(self.on_enter)
220
- self.ui.convEdit.editingFinished.connect(self.on_enter)
221
- self.ui.fluxEdit.editingFinished.connect(self.on_enter)
222
-
223
- self.ui.TEMList.activated[str].connect(self.on_list_enter)
224
-
225
- self.ui.logCheck.clicked.connect(self.on_check_enter)
226
- self.ui.gammaCheck.clicked.connect(self.on_check_enter)
1
+ from pyTEMlib import image_dialog