pyTEMlib 0.2020.11.0__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.
- pyTEMlib/__init__.py +11 -11
- pyTEMlib/animation.py +631 -0
- pyTEMlib/atom_tools.py +240 -222
- pyTEMlib/config_dir.py +57 -29
- pyTEMlib/core_loss_widget.py +658 -0
- pyTEMlib/crystal_tools.py +1255 -0
- pyTEMlib/diffraction_plot.py +756 -0
- pyTEMlib/dynamic_scattering.py +293 -0
- pyTEMlib/eds_tools.py +609 -0
- pyTEMlib/eels_dialog.py +749 -486
- pyTEMlib/{interactive_eels.py → eels_dialog_utilities.py} +1199 -1524
- pyTEMlib/eels_tools.py +2031 -1731
- pyTEMlib/file_tools.py +1276 -491
- pyTEMlib/file_tools_qt.py +193 -0
- pyTEMlib/graph_tools.py +1166 -450
- pyTEMlib/graph_viz.py +449 -0
- pyTEMlib/image_dialog.py +158 -0
- pyTEMlib/image_dlg.py +146 -0
- pyTEMlib/image_tools.py +1399 -956
- pyTEMlib/info_widget.py +933 -0
- pyTEMlib/interactive_image.py +1 -0
- pyTEMlib/kinematic_scattering.py +1196 -0
- pyTEMlib/low_loss_widget.py +176 -0
- pyTEMlib/microscope.py +61 -78
- pyTEMlib/peak_dialog.py +1047 -350
- pyTEMlib/peak_dlg.py +286 -248
- pyTEMlib/probe_tools.py +653 -202
- pyTEMlib/sidpy_tools.py +153 -129
- pyTEMlib/simulation_tools.py +104 -87
- pyTEMlib/version.py +6 -3
- pyTEMlib/xrpa_x_sections.py +20972 -0
- {pyTEMlib-0.2020.11.0.dist-info → pyTEMlib-0.2024.8.4.dist-info}/LICENSE +21 -21
- pyTEMlib-0.2024.8.4.dist-info/METADATA +93 -0
- pyTEMlib-0.2024.8.4.dist-info/RECORD +37 -0
- {pyTEMlib-0.2020.11.0.dist-info → pyTEMlib-0.2024.8.4.dist-info}/WHEEL +6 -5
- {pyTEMlib-0.2020.11.0.dist-info → pyTEMlib-0.2024.8.4.dist-info}/entry_points.txt +0 -1
- pyTEMlib/KinsCat.py +0 -2685
- pyTEMlib/__version__.py +0 -2
- pyTEMlib/data/TEMlibrc +0 -68
- pyTEMlib/data/edges_db.csv +0 -189
- pyTEMlib/data/edges_db.pkl +0 -0
- pyTEMlib/data/fparam.txt +0 -103
- pyTEMlib/data/microscopes.csv +0 -7
- pyTEMlib/data/microscopes.xml +0 -167
- pyTEMlib/data/path.txt +0 -1
- pyTEMlib/defaults_parser.py +0 -86
- pyTEMlib/dm3_reader.py +0 -609
- pyTEMlib/edges_db.py +0 -76
- pyTEMlib/eels_dlg.py +0 -240
- pyTEMlib/hdf_utils.py +0 -481
- pyTEMlib/image_tools1.py +0 -2194
- pyTEMlib/info_dialog.py +0 -227
- pyTEMlib/info_dlg.py +0 -205
- pyTEMlib/nion_reader.py +0 -293
- pyTEMlib/nsi_reader.py +0 -165
- pyTEMlib/structure_tools.py +0 -316
- pyTEMlib-0.2020.11.0.dist-info/METADATA +0 -20
- pyTEMlib-0.2020.11.0.dist-info/RECORD +0 -42
- {pyTEMlib-0.2020.11.0.dist-info → pyTEMlib-0.2024.8.4.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,193 @@
|
|
|
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])
|