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
pyTEMlib/file_tools_qt.py
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import numpy as np
|
|
3
|
-
import h5py
|
|
4
|
-
|
|
5
|
-
Qt_available = True
|
|
6
|
-
try:
|
|
7
|
-
from PyQt5 import QtCore, QtWidgets, QtGui
|
|
8
|
-
except:
|
|
9
|
-
print('Qt dialogs are not available')
|
|
10
|
-
Qt_available = False
|
|
11
|
-
|
|
12
|
-
from PIL import Image, ImageQt
|
|
13
|
-
import matplotlib.pyplot as plt
|
|
14
|
-
import warnings
|
|
15
|
-
warnings.filterwarnings('ignore')
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if Qt_available:
|
|
19
|
-
import pyTEMlib.file_tools as ft
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class FileIconDialog(QtWidgets.QDialog):
|
|
23
|
-
"""Qt5 Dialog to select directories or files from a list of Thumbnails
|
|
24
|
-
|
|
25
|
-
The dialog converts the name of the nion file to the one in Nion's swift software,
|
|
26
|
-
The dialog converts the name of the nion file to the one in Nion's swift software,
|
|
27
|
-
because it is otherwise incomprehensible. Any Icon in a hf5 file will be displayed.
|
|
28
|
-
|
|
29
|
-
Attributes
|
|
30
|
-
----------
|
|
31
|
-
dir_name: str
|
|
32
|
-
name of starting directory
|
|
33
|
-
extension: list of str
|
|
34
|
-
extensions of files to be listed in widget
|
|
35
|
-
|
|
36
|
-
Methods
|
|
37
|
-
-------
|
|
38
|
-
set_icon
|
|
39
|
-
set_all_icons
|
|
40
|
-
select
|
|
41
|
-
get_directory
|
|
42
|
-
update
|
|
43
|
-
|
|
44
|
-
Example
|
|
45
|
-
-------
|
|
46
|
-
>>file_view = pyTEMlib.file_tools_qt.FileIconDialog('.')
|
|
47
|
-
>>dataset = pyTEMlib.file_tools.open_file(file_view.file_name)
|
|
48
|
-
>>view=dataset.plot()
|
|
49
|
-
|
|
50
|
-
"""
|
|
51
|
-
|
|
52
|
-
def __init__(self, dir_name=None, extension=None):
|
|
53
|
-
super().__init__(None, QtCore.Qt.WindowStaysOnTopHint)
|
|
54
|
-
self.setModal(True)
|
|
55
|
-
|
|
56
|
-
self.save_path = False
|
|
57
|
-
self.dir_dictionary = {}
|
|
58
|
-
self.dir_list = ['.', '..']
|
|
59
|
-
self.display_list = ['.', '..']
|
|
60
|
-
self.icon_size = 100
|
|
61
|
-
self.file_name = None
|
|
62
|
-
|
|
63
|
-
self.dir_name = '.'
|
|
64
|
-
if dir_name is None:
|
|
65
|
-
self.dir_name = ft.get_last_path()
|
|
66
|
-
self.save_path = True
|
|
67
|
-
elif os.path.isdir(dir_name):
|
|
68
|
-
self.dir_name = dir_name
|
|
69
|
-
|
|
70
|
-
self.get_directory()
|
|
71
|
-
|
|
72
|
-
# setting geometry
|
|
73
|
-
self.setGeometry(100, 100, 500, 400)
|
|
74
|
-
|
|
75
|
-
# creating a QListWidget
|
|
76
|
-
self.list_widget = QtWidgets.QListWidget(self)
|
|
77
|
-
self.list_widget.setIconSize(QtCore.QSize(self.icon_size, self.icon_size))
|
|
78
|
-
self.layout = QtWidgets.QVBoxLayout()
|
|
79
|
-
self.layout.addWidget(self.list_widget)
|
|
80
|
-
|
|
81
|
-
self.update()
|
|
82
|
-
|
|
83
|
-
button_layout = QtWidgets.QHBoxLayout()
|
|
84
|
-
|
|
85
|
-
button_select = QtWidgets.QPushButton('Select')
|
|
86
|
-
button_layout.addWidget(button_select)
|
|
87
|
-
button_get_icon = QtWidgets.QPushButton('Get Icon')
|
|
88
|
-
button_layout.addWidget(button_get_icon)
|
|
89
|
-
button_get_all_icons = QtWidgets.QPushButton('Get All Icons')
|
|
90
|
-
button_layout.addWidget(button_get_all_icons)
|
|
91
|
-
|
|
92
|
-
self.layout.addLayout(button_layout)
|
|
93
|
-
self.setLayout(self.layout)
|
|
94
|
-
|
|
95
|
-
self.list_widget.itemDoubleClicked.connect(self.select)
|
|
96
|
-
button_select.clicked.connect(self.select)
|
|
97
|
-
button_get_icon.clicked.connect(self.set_icon)
|
|
98
|
-
button_get_all_icons.clicked.connect(self.set_all_icons)
|
|
99
|
-
|
|
100
|
-
# showing all the widgets
|
|
101
|
-
self.exec_()
|
|
102
|
-
|
|
103
|
-
def set_icon(self):
|
|
104
|
-
plt.ioff()
|
|
105
|
-
figure = plt.figure(figsize=(1, 1))
|
|
106
|
-
item = self.list_widget.currentItem().text()
|
|
107
|
-
index = self.display_list.index(item)
|
|
108
|
-
file_name = os.path.abspath(os.path.join(self.dir_name, self.dir_list[index]))
|
|
109
|
-
dataset = ft.open_file(file_name)
|
|
110
|
-
dataset.set_thumbnail(figure=figure)
|
|
111
|
-
plt.close()
|
|
112
|
-
plt.ion()
|
|
113
|
-
self.update()
|
|
114
|
-
|
|
115
|
-
def set_all_icons(self):
|
|
116
|
-
|
|
117
|
-
plt.ioff()
|
|
118
|
-
figure = plt.figure(figsize=(1, 1))
|
|
119
|
-
for item in self.dir_list:
|
|
120
|
-
file_name = os.path.join(self.dir_name, item)
|
|
121
|
-
if os.path.isfile(file_name):
|
|
122
|
-
base_name, extension = os.path.splitext(file_name)
|
|
123
|
-
if extension in ['.hf5', '.dm3', '.dm4', '.ndata', '.hf5']:
|
|
124
|
-
try:
|
|
125
|
-
dataset = ft.open_file(file_name)
|
|
126
|
-
dataset.set_thumbnail(figure=figure)
|
|
127
|
-
dataset.h5_dataset.file.close()
|
|
128
|
-
except:
|
|
129
|
-
pass
|
|
130
|
-
plt.close()
|
|
131
|
-
plt.ion()
|
|
132
|
-
self.update()
|
|
133
|
-
|
|
134
|
-
def select(self):
|
|
135
|
-
item = self.list_widget.currentItem().text()
|
|
136
|
-
index = self.display_list.index(item)
|
|
137
|
-
item = os.path.abspath(os.path.join(self.dir_name, self.dir_list[index]))
|
|
138
|
-
self.setWindowTitle(" Chooser " + os.path.abspath(self.dir_name))
|
|
139
|
-
if os.path.isdir(item):
|
|
140
|
-
self.dir_name = item
|
|
141
|
-
self.update()
|
|
142
|
-
|
|
143
|
-
elif os.path.isfile(os.path.join(self.dir_name, item)):
|
|
144
|
-
self.setWindowTitle(f" Selected File: {item}")
|
|
145
|
-
self.file_name = item
|
|
146
|
-
self.close()
|
|
147
|
-
|
|
148
|
-
def get_directory(self):
|
|
149
|
-
|
|
150
|
-
dir_list = os.listdir(self.dir_name)
|
|
151
|
-
file_dict = ft.update_directory_list(self.dir_name)
|
|
152
|
-
|
|
153
|
-
sort = np.argsort(file_dict['directory_list'])
|
|
154
|
-
self.dir_list = ['.', '..']
|
|
155
|
-
self.display_list = ['.', '..']
|
|
156
|
-
for j in sort:
|
|
157
|
-
self.display_list.append(f"{file_dict['directory_list'][j]}")
|
|
158
|
-
self.dir_list.append(file_dict['directory_list'][j])
|
|
159
|
-
|
|
160
|
-
sort = np.argsort(file_dict['display_file_list'])
|
|
161
|
-
|
|
162
|
-
for i, j in enumerate(sort):
|
|
163
|
-
if '--' in dir_list[j]:
|
|
164
|
-
self.display_list.append(f"{file_dict['display_file_list'][j]}")
|
|
165
|
-
else:
|
|
166
|
-
self.display_list.append(f"{file_dict['display_file_list'][j]}")
|
|
167
|
-
self.dir_list.append(file_dict['file_list'][j])
|
|
168
|
-
|
|
169
|
-
def update(self):
|
|
170
|
-
self.get_directory()
|
|
171
|
-
self.setWindowTitle("File Chooser " + os.path.abspath(self.dir_name))
|
|
172
|
-
# creating a QListWidget
|
|
173
|
-
default_icons = QtWidgets.QFileIconProvider()
|
|
174
|
-
self.list_widget.clear()
|
|
175
|
-
|
|
176
|
-
item_list = []
|
|
177
|
-
for index, item_text in enumerate(self.dir_list):
|
|
178
|
-
if os.path.isdir(os.path.join(self.dir_name, item_text)):
|
|
179
|
-
icon = default_icons.icon(QtWidgets.QFileIconProvider.Folder)
|
|
180
|
-
elif item_text[-4:] == '.hf5':
|
|
181
|
-
try:
|
|
182
|
-
f = h5py.File(os.path.join(self.dir_name, item_text), 'r')
|
|
183
|
-
if 'Thumbnail' in f:
|
|
184
|
-
picture = ImageQt.ImageQt(Image.fromarray(f['Thumbnail/Thumbnail'][()]))
|
|
185
|
-
icon = QtGui.QIcon(QtGui.QPixmap.fromImage(picture))
|
|
186
|
-
else:
|
|
187
|
-
icon = default_icons.icon(QtWidgets.QFileIconProvider.File)
|
|
188
|
-
except:
|
|
189
|
-
icon = default_icons.icon(QtWidgets.QFileIconProvider.File)
|
|
190
|
-
else:
|
|
191
|
-
icon = default_icons.icon(QtWidgets.QFileIconProvider.File)
|
|
192
|
-
item_list.append(QtWidgets.QListWidgetItem(icon, self.display_list[index]))
|
|
193
|
-
self.list_widget.addItem(item_list[-1])
|
pyTEMlib/image_dialog.py
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Input Dialog for Image Analysis
|
|
3
|
-
|
|
4
|
-
Author: Gerd Duscher
|
|
5
|
-
|
|
6
|
-
"""
|
|
7
|
-
# -*- coding: utf-8 -*-
|
|
8
|
-
|
|
9
|
-
import numpy as np
|
|
10
|
-
import sidpy
|
|
11
|
-
|
|
12
|
-
Qt_available = True
|
|
13
|
-
try:
|
|
14
|
-
from PyQt5 import QtCore, QtWidgets
|
|
15
|
-
except:
|
|
16
|
-
Qt_available = False
|
|
17
|
-
# print('Qt dialogs are not available')
|
|
18
|
-
|
|
19
|
-
from matplotlib.widgets import SpanSelector
|
|
20
|
-
from skimage import exposure
|
|
21
|
-
|
|
22
|
-
from pyTEMlib.image_dlg import *
|
|
23
|
-
from pyTEMlib.microscope import microscope
|
|
24
|
-
|
|
25
|
-
_version = 000
|
|
26
|
-
|
|
27
|
-
if Qt_available:
|
|
28
|
-
class ImageDialog(QtWidgets.QDialog):
|
|
29
|
-
"""
|
|
30
|
-
Input Dialog for Image Analysis
|
|
31
|
-
|
|
32
|
-
Opens a PyQt5 GUi Dialog that allows to set the experimental parameter necessary for a Quantification.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
The dialog operates on a sidpy dataset
|
|
36
|
-
"""
|
|
37
|
-
|
|
38
|
-
def __init__(self, dataset, parent=None):
|
|
39
|
-
super(ImageDialog, self).__init__(parent)
|
|
40
|
-
if not isinstance(dataset, sidpy.Dataset):
|
|
41
|
-
raise TypeError("we need a sidpy.Dataset")
|
|
42
|
-
self.parent = parent
|
|
43
|
-
self.debug = 0
|
|
44
|
-
self.dataset = dataset
|
|
45
|
-
self.image = np.array(self.dataset)
|
|
46
|
-
self.v_min = np.array(dataset).min()
|
|
47
|
-
self.v_max = np.array(dataset).max()
|
|
48
|
-
|
|
49
|
-
self.ui = UiDialog(self)
|
|
50
|
-
self.setWindowTitle('Image Info')
|
|
51
|
-
|
|
52
|
-
self.dataset.plot()
|
|
53
|
-
self.histogram()
|
|
54
|
-
self.cid = self.ui.histogram.axes.figure.canvas.mpl_connect('button_press_event', self.onclick)
|
|
55
|
-
|
|
56
|
-
self.span = SpanSelector(self.ui.histogram.axes, self.on_select, 'horizontal', useblit=False,
|
|
57
|
-
button=1, minspan=5,
|
|
58
|
-
rectprops=dict(alpha=0.3, facecolor='blue'))
|
|
59
|
-
minimum_info = {'size': self.dataset.shape,
|
|
60
|
-
'exposure_time': 0.0,
|
|
61
|
-
'convergence_angle': 0.0,
|
|
62
|
-
'acceleration_voltage': 100.0,
|
|
63
|
-
'binning': 1, 'conversion': 1.0,
|
|
64
|
-
'flux': 1.0, 'current': 1.0}
|
|
65
|
-
|
|
66
|
-
if 'experiment' not in self.dataset.metadata:
|
|
67
|
-
self.dataset.metadata['experiment'] = {}
|
|
68
|
-
for key, value in minimum_info.items():
|
|
69
|
-
if key not in self.dataset.metadata['experiment']:
|
|
70
|
-
self.dataset.metadata['experiment'][key] = value
|
|
71
|
-
self.experiment = self.dataset.metadata['experiment']
|
|
72
|
-
self.set_action()
|
|
73
|
-
self.update()
|
|
74
|
-
|
|
75
|
-
def histogram(self, bins=256):
|
|
76
|
-
ax_hist = self.ui.histogram.axes
|
|
77
|
-
ax_hist.clear()
|
|
78
|
-
|
|
79
|
-
hist, bin_edges = np.histogram(np.array(self.image), range=[self.v_min, self.v_max], bins=bins, density=True)
|
|
80
|
-
ax_hist.plot(np.array(bin_edges)[:-1], np.array(hist))
|
|
81
|
-
|
|
82
|
-
image = self.image * 1.0
|
|
83
|
-
image[image < self.v_min] = self.v_min
|
|
84
|
-
image[image > self.v_max] = self.v_max
|
|
85
|
-
|
|
86
|
-
img_cdf, bins = exposure.cumulative_distribution(np.array(image), bins)
|
|
87
|
-
ax_hist.plot(bins, img_cdf * hist.max(), 'r')
|
|
88
|
-
ax_hist.figure.canvas.draw()
|
|
89
|
-
self.span = SpanSelector(self.ui.histogram.axes, self.on_select, 'horizontal', useblit=False,
|
|
90
|
-
button=1, minspan=5,
|
|
91
|
-
rectprops=dict(alpha=0.3, facecolor='blue'))
|
|
92
|
-
self.plot()
|
|
93
|
-
|
|
94
|
-
def onclick(self, event):
|
|
95
|
-
if event.dblclick:
|
|
96
|
-
self.v_min = np.array(self.dataset).min()
|
|
97
|
-
self.v_max = np.array(self.dataset).max()
|
|
98
|
-
self.histogram()
|
|
99
|
-
|
|
100
|
-
def on_select(self, v_min, v_max):
|
|
101
|
-
self.v_min = v_min
|
|
102
|
-
self.v_max = v_max
|
|
103
|
-
self.histogram()
|
|
104
|
-
|
|
105
|
-
def plot(self):
|
|
106
|
-
ax = self.dataset.view.axis
|
|
107
|
-
img = self.dataset.view.img
|
|
108
|
-
img.set_data(self.image)
|
|
109
|
-
img.set_clim(vmin=self.v_min, vmax=self.v_max)
|
|
110
|
-
ax.figure.canvas.draw()
|
|
111
|
-
|
|
112
|
-
def on_enter(self):
|
|
113
|
-
sender = self.sender()
|
|
114
|
-
if sender == self.ui.timeEdit:
|
|
115
|
-
value = float(str(sender.displayText()).strip())
|
|
116
|
-
self.experiment['exposure_time'] = value
|
|
117
|
-
sender.setText(f"{value:.2f}")
|
|
118
|
-
elif sender == self.ui.convEdit:
|
|
119
|
-
value = float(str(sender.displayText()).strip())
|
|
120
|
-
self.experiment['convergence_angle'] = value
|
|
121
|
-
sender.setText(f"{value:.2f}")
|
|
122
|
-
elif sender == self.ui.E0Edit:
|
|
123
|
-
value = float(str(sender.displayText()).strip())
|
|
124
|
-
self.experiment['acceleration_voltage'] = value * 1000.0
|
|
125
|
-
sender.setText(f"{value:.2f}")
|
|
126
|
-
|
|
127
|
-
def on_list_enter(self):
|
|
128
|
-
sender = self.sender()
|
|
129
|
-
if sender == self.ui.TEMList:
|
|
130
|
-
microscope.set_microscope(self.ui.TEMList.currentText())
|
|
131
|
-
self.setWindowTitle(microscope.name)
|
|
132
|
-
|
|
133
|
-
self.experiment['microscope'] = microscope.name
|
|
134
|
-
self.experiment['convergence_angle'] = microscope.alpha
|
|
135
|
-
self.experiment['acceleration_voltage'] = microscope.E0
|
|
136
|
-
self.update()
|
|
137
|
-
|
|
138
|
-
def update(self):
|
|
139
|
-
self.ui.convEdit.setText(f"{self.experiment['convergence_angle']:.2f}")
|
|
140
|
-
self.ui.E0Edit.setText(f"{self.experiment['acceleration_voltage']/1000.:.2f}")
|
|
141
|
-
|
|
142
|
-
self.ui.timeEdit.setText(f"{self.experiment['exposure_time']:.6f}")
|
|
143
|
-
size_text = f'{self.dataset.shape[0]}'
|
|
144
|
-
for size in self.dataset.shape[1:]:
|
|
145
|
-
size_text = size_text + f' x {size}'
|
|
146
|
-
self.ui.sizeEdit.setText(size_text)
|
|
147
|
-
|
|
148
|
-
# self.ui.binningEdit.setText(f"{self.experiment['binning']}")
|
|
149
|
-
# self.ui.conversionEdit.setText(f"{self.experiment['conversion']:.2f}")
|
|
150
|
-
# self.ui.fluxEdit.setText(f"{self.experiment['flux']:.2f}")
|
|
151
|
-
# self.ui.VOAEdit.setText(f"{self.experiment['current']:.2f}")
|
|
152
|
-
|
|
153
|
-
def set_action(self):
|
|
154
|
-
self.ui.timeEdit.editingFinished.connect(self.on_enter)
|
|
155
|
-
self.ui.TEMList.activated[str].connect(self.on_list_enter)
|
|
156
|
-
|
|
157
|
-
self.ui.convEdit.editingFinished.connect(self.on_enter)
|
|
158
|
-
self.ui.E0Edit.editingFinished.connect(self.on_enter)
|
pyTEMlib/image_dlg.py
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Gui for image_dialog
|
|
3
|
-
|
|
4
|
-
Author: Gerd Duscher
|
|
5
|
-
|
|
6
|
-
"""
|
|
7
|
-
# -*- coding: utf-8 -*-
|
|
8
|
-
Qt_available = True
|
|
9
|
-
try:
|
|
10
|
-
from PyQt5 import QtCore, QtGui, QtWidgets
|
|
11
|
-
except:
|
|
12
|
-
Qt_available = False
|
|
13
|
-
# print('Qt dialogs are not available')
|
|
14
|
-
|
|
15
|
-
from matplotlib.figure import Figure
|
|
16
|
-
|
|
17
|
-
from pyTEMlib.microscope import microscope
|
|
18
|
-
|
|
19
|
-
if Qt_available:
|
|
20
|
-
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as Canvas
|
|
21
|
-
|
|
22
|
-
class MySICanvas(Canvas):
|
|
23
|
-
def __init__(self, parent, width=10, height=10, dpi=100):
|
|
24
|
-
self.figure = Figure(figsize=(width, height), dpi=dpi)
|
|
25
|
-
self.figure.subplots_adjust(bottom=.2)
|
|
26
|
-
Canvas.__init__(self, self.figure)
|
|
27
|
-
self.setParent(parent)
|
|
28
|
-
|
|
29
|
-
Canvas.setSizePolicy(self, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
|
|
30
|
-
|
|
31
|
-
Canvas.updateGeometry(self)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class UiDialog(object):
|
|
35
|
-
def __init__(self, dialog, parent=None):
|
|
36
|
-
dialog.setObjectName('Image Info')
|
|
37
|
-
dialog.resize(371, 184)
|
|
38
|
-
|
|
39
|
-
valid_float = QtGui.QDoubleValidator()
|
|
40
|
-
# valid_int = QtGui.QIntValidator()
|
|
41
|
-
self.histogram = MySICanvas(parent, width=10, height=10, dpi=70)
|
|
42
|
-
|
|
43
|
-
# Defining a plot instance (axes) and assigning a variable to it
|
|
44
|
-
self.histogram.axes = self.histogram.figure.add_subplot(1, 1, 1)
|
|
45
|
-
|
|
46
|
-
self.TEM = []
|
|
47
|
-
self.TEM = microscope.get_available_microscope_names()
|
|
48
|
-
|
|
49
|
-
plot_layout = QtWidgets.QGridLayout()
|
|
50
|
-
|
|
51
|
-
# Adding histogram
|
|
52
|
-
plot_layout.addWidget(self.histogram, 0, 0)
|
|
53
|
-
|
|
54
|
-
# making a single widget out of histogram
|
|
55
|
-
histogram_plot = QtWidgets.QWidget()
|
|
56
|
-
histogram_plot.setLayout(plot_layout)
|
|
57
|
-
|
|
58
|
-
layout = self.layout = QtWidgets.QGridLayout()
|
|
59
|
-
self.layout.setVerticalSpacing(2)
|
|
60
|
-
|
|
61
|
-
self.separator1 = QtWidgets.QLabel()
|
|
62
|
-
self.separator1.setAutoFillBackground(True)
|
|
63
|
-
palette = self.separator1.palette()
|
|
64
|
-
palette.setColor(self.separator1.backgroundRole(), QtCore.Qt.blue)
|
|
65
|
-
palette.setColor(self.separator1.foregroundRole(), QtCore.Qt.white)
|
|
66
|
-
self.separator1.setAlignment(QtCore.Qt.AlignCenter)
|
|
67
|
-
self.separator1.setMaximumHeight(50)
|
|
68
|
-
|
|
69
|
-
self.separator1.setPalette(palette)
|
|
70
|
-
######################################################################
|
|
71
|
-
self.separator1.setText("Microscope")
|
|
72
|
-
layout.addWidget(self.separator1, 0, 0, 1, 3)
|
|
73
|
-
row = 0
|
|
74
|
-
layout.addWidget(self.separator1, row, 0, 1, 4)
|
|
75
|
-
|
|
76
|
-
row += 1
|
|
77
|
-
self.TEMList = QtWidgets.QComboBox()
|
|
78
|
-
self.TEMList.setEditable(False)
|
|
79
|
-
self.TEMList.addItems(self.TEM)
|
|
80
|
-
|
|
81
|
-
self.layout.addWidget(self.TEMList, row, 1)
|
|
82
|
-
|
|
83
|
-
row += 1
|
|
84
|
-
self.convLabel = QtWidgets.QLabel("Conv. Angle")
|
|
85
|
-
self.convEdit = QtWidgets.QLineEdit(" 100.0")
|
|
86
|
-
self.convEdit.setValidator(valid_float)
|
|
87
|
-
self.convUnit = QtWidgets.QLabel("mrad")
|
|
88
|
-
self.layout.addWidget(self.convLabel, row, 0)
|
|
89
|
-
self.layout.addWidget(self.convEdit, row, 1)
|
|
90
|
-
self.layout.addWidget(self.convUnit, row, 2)
|
|
91
|
-
|
|
92
|
-
row += 1
|
|
93
|
-
self.E0Label = QtWidgets.QLabel("Acc. Voltage")
|
|
94
|
-
self.E0Edit = QtWidgets.QLineEdit(" 100.0")
|
|
95
|
-
self.E0Edit.setValidator(valid_float)
|
|
96
|
-
self.E0Unit = QtWidgets.QLabel("kV")
|
|
97
|
-
self.layout.addWidget(self.E0Label, row, 0)
|
|
98
|
-
self.layout.addWidget(self.E0Edit, row, 1)
|
|
99
|
-
self.layout.addWidget(self.E0Unit, row, 2)
|
|
100
|
-
|
|
101
|
-
self.separator2 = QtWidgets.QLabel()
|
|
102
|
-
self.separator2.setAutoFillBackground(True)
|
|
103
|
-
self.separator2.setAlignment(QtCore.Qt.AlignCenter)
|
|
104
|
-
self.separator2.setMaximumHeight(50)
|
|
105
|
-
self.separator2.setPalette(palette)
|
|
106
|
-
|
|
107
|
-
row += 1
|
|
108
|
-
######################################################################
|
|
109
|
-
self.separator2.setText("Image")
|
|
110
|
-
layout.addWidget(self.separator2, row, 0, 1, 4)
|
|
111
|
-
######################################################################
|
|
112
|
-
row += 1
|
|
113
|
-
self.sizeLabel = QtWidgets.QLabel("Size")
|
|
114
|
-
self.sizeEdit = QtWidgets.QLineEdit(" 1 x 1")
|
|
115
|
-
self.sizeEdit.setValidator(valid_float)
|
|
116
|
-
self.sizeUnit = QtWidgets.QLabel("px")
|
|
117
|
-
|
|
118
|
-
self.layout.addWidget(self.sizeLabel, row, 0)
|
|
119
|
-
self.layout.addWidget(self.sizeEdit, row, 1)
|
|
120
|
-
self.layout.addWidget(self.sizeUnit, row, 2)
|
|
121
|
-
|
|
122
|
-
row += 1
|
|
123
|
-
self.timeLabel = QtWidgets.QLabel("Exp. Time")
|
|
124
|
-
self.timeEdit = QtWidgets.QLineEdit(" 100.0")
|
|
125
|
-
self.timeEdit.setValidator(valid_float)
|
|
126
|
-
self.timeUnit = QtWidgets.QLabel("s")
|
|
127
|
-
|
|
128
|
-
self.layout.addWidget(self.timeLabel, row, 0)
|
|
129
|
-
self.layout.addWidget(self.timeEdit, row, 1)
|
|
130
|
-
self.layout.addWidget(self.timeUnit, row, 2)
|
|
131
|
-
|
|
132
|
-
self.separator3 = QtWidgets.QLabel(dialog)
|
|
133
|
-
self.separator3.setAutoFillBackground(True)
|
|
134
|
-
self.separator3.setAlignment(QtCore.Qt.AlignCenter)
|
|
135
|
-
self.separator3.setMaximumHeight(50)
|
|
136
|
-
self.separator3.setPalette(palette)
|
|
137
|
-
|
|
138
|
-
row += 1
|
|
139
|
-
######################################################################
|
|
140
|
-
self.separator3.setText("Histogram")
|
|
141
|
-
self.layout.addWidget(self.separator3, row, 0, 1, 4)
|
|
142
|
-
######################################################################
|
|
143
|
-
|
|
144
|
-
row += 1
|
|
145
|
-
layout.addWidget(histogram_plot, row, 0, 1, 3)
|
|
146
|
-
dialog.setLayout(layout)
|