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.

Files changed (59) hide show
  1. pyTEMlib/__init__.py +11 -11
  2. pyTEMlib/animation.py +631 -0
  3. pyTEMlib/atom_tools.py +240 -222
  4. pyTEMlib/config_dir.py +57 -29
  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 -486
  11. pyTEMlib/{interactive_eels.py → eels_dialog_utilities.py} +1199 -1524
  12. pyTEMlib/eels_tools.py +2031 -1731
  13. pyTEMlib/file_tools.py +1276 -491
  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 -0
  19. pyTEMlib/image_tools.py +1399 -956
  20. pyTEMlib/info_widget.py +933 -0
  21. pyTEMlib/interactive_image.py +1 -0
  22. pyTEMlib/kinematic_scattering.py +1196 -0
  23. pyTEMlib/low_loss_widget.py +176 -0
  24. pyTEMlib/microscope.py +61 -78
  25. pyTEMlib/peak_dialog.py +1047 -350
  26. pyTEMlib/peak_dlg.py +286 -248
  27. pyTEMlib/probe_tools.py +653 -202
  28. pyTEMlib/sidpy_tools.py +153 -129
  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.0.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.0.dist-info → pyTEMlib-0.2024.8.4.dist-info}/WHEEL +6 -5
  36. {pyTEMlib-0.2020.11.0.dist-info → pyTEMlib-0.2024.8.4.dist-info}/entry_points.txt +0 -1
  37. pyTEMlib/KinsCat.py +0 -2685
  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 -86
  47. pyTEMlib/dm3_reader.py +0 -609
  48. pyTEMlib/edges_db.py +0 -76
  49. pyTEMlib/eels_dlg.py +0 -240
  50. pyTEMlib/hdf_utils.py +0 -481
  51. pyTEMlib/image_tools1.py +0 -2194
  52. pyTEMlib/info_dialog.py +0 -227
  53. pyTEMlib/info_dlg.py +0 -205
  54. pyTEMlib/nion_reader.py +0 -293
  55. pyTEMlib/nsi_reader.py +0 -165
  56. pyTEMlib/structure_tools.py +0 -316
  57. pyTEMlib-0.2020.11.0.dist-info/METADATA +0 -20
  58. pyTEMlib-0.2020.11.0.dist-info/RECORD +0 -42
  59. {pyTEMlib-0.2020.11.0.dist-info → pyTEMlib-0.2024.8.4.dist-info}/top_level.txt +0 -0
pyTEMlib/atom_tools.py CHANGED
@@ -1,222 +1,240 @@
1
- #
2
- # All atom detection is done here
3
- # Everything is in unit of pixel!!
4
- #
5
-
6
- import numpy as np
7
- import sys
8
-
9
- from skimage.feature import peak_local_max
10
- from sklearn.cluster import KMeans
11
- from scipy.spatial import cKDTree
12
- import scipy.optimize as optimization
13
-
14
- from .probe_tools import *
15
- from .file_tools import *
16
-
17
-
18
- def find_atoms(image, tags):
19
- """
20
- ######################################
21
- # Find atoms
22
- ######################################
23
- """
24
- image = image - image.min()
25
- image = image / image.max()
26
-
27
- if 'sigma_min' not in tags:
28
- tags['sigma_min'] = 0.1
29
- if 'resolution' not in tags:
30
- tags['resolution'] = 0.1
31
-
32
- if 'ROIsize' not in tags:
33
- tags['ROIsize'] = 100.
34
-
35
- res = tags['resolution'] / tags['pixel_size'] # * tags['ROIsize']/100.
36
- print('res', res)
37
- coordinates = peak_local_max(image, min_distance=int(res / 2), threshold_rel=tags['sigma_min'], exclude_border=True)
38
- print('coor', len(coordinates))
39
- """
40
- peak_local_max(image, min_distance=10, threshold_abs=0, threshold_rel=0.1,
41
- exclude_border=True, indices=True, num_peaks=np.inf,
42
- footprint=None, labels=None):
43
-
44
- Find peaks in an image, and return them as coordinates or a boolean array.
45
- Peaks are the local maxima in a region of `2 * min_distance + 1
46
-
47
- (i.e. peaks are separated by at least `min_distance`).
48
- NOTE: If peaks are flat (i.e. multiple adjacent pixels have identical
49
- intensities), the coordinates of all such pixels are returned.
50
- """
51
-
52
- # We calculate the radius in pixel of a round area in which atoms are evaluated
53
- sc = tags['pixel_size']
54
- r = tags['resolution'] / sc * tags['ROIsize'] / 100. / 2.
55
- tags['radius'] = r
56
-
57
- #######################################
58
- # Now we determine intensity #
59
- #######################################
60
-
61
- ###############
62
- # Make a circular mask for integration of atom intensity
63
- ################
64
- rr = int(r + 0.5)
65
- mask = np.zeros((2 * rr + 1, 2 * rr + 1))
66
-
67
- for i in range(2 * rr + 1):
68
- for j in range(2 * rr + 1):
69
- if (i - rr) ** 2 + (j - rr) ** 2 < rr ** 2 + 0.1:
70
- mask[i, j] = 1
71
-
72
- ###
73
- # Determine pixel position and intensity of all atoms
74
- ###
75
- atoms = []
76
- for i in range(len(coordinates)):
77
- x, y = coordinates[i]
78
-
79
- if rr < x < image.shape[1] - rr and rr < y < image.shape[0] - rr:
80
- area = image[x - rr:x + rr + 1, y - rr:y + rr + 1]
81
- arr = area * mask
82
- atoms.append((x, y, rr, arr.sum(), arr.max()))
83
-
84
- print(' Detected ', len(atoms), ' atoms')
85
- atoms.sort()
86
- return atoms
87
-
88
-
89
- def atoms_clustering(atoms, mid_atoms, number_of_clusters=3, nearest_neighbours=7):
90
- # get distances
91
- nn_tree = cKDTree(np.array(atoms)[:, 0:2])
92
-
93
- distances, indices = nn_tree.query(np.array(mid_atoms)[:, 0:2], nearest_neighbours)
94
-
95
- # Clustering
96
- k_means = KMeans(n_clusters=number_of_clusters, random_state=0) # Fixing the RNG in kmeans
97
- k_means.fit(distances)
98
- clusters = k_means.predict(distances)
99
- return clusters, distances, indices
100
-
101
-
102
- def gauss_difference(params, area):
103
- gauss = make_gauss(area.shape[0], area.shape[1], width=params[0], x0=params[1], y0=params[2], intensity=params[3])
104
- return (area - gauss).flatten()
105
-
106
-
107
- def atom_refine(image, atoms, radius, max_int=0, min_int=0, max_dist=4):
108
- """
109
- fits a Gaussian in a blob
110
- """
111
- rr = int(radius + 0.5) # atom radius
112
- print('using radius ', rr, 'pixels')
113
-
114
- pixels = np.linspace(0, 2 * rr, 2 * rr + 1) - rr
115
- x, y = np.meshgrid(pixels, pixels)
116
- mask = (x ** 2 + y ** 2) < rr ** 2
117
-
118
- guess = [rr * 2, 0.0, 0.0, 1]
119
-
120
- sym = {'number_of_atoms': len(atoms)}
121
-
122
- volume = []
123
- position = []
124
- intensities = []
125
- maximum_area = []
126
- new_atoms = []
127
- gauss_width = []
128
- gauss_amplitude = []
129
- gauss_intensity = []
130
- if QT_available:
131
- progress = QtWidgets.QProgressDialog("Refine Atom Positions", "Abort", 0, len(atoms))
132
- progress.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
133
- # progress.setWindowModality(Qt.WindowModal);
134
- progress.show()
135
-
136
- done = 0
137
- for i in range(len(atoms)):
138
- if QT_available:
139
- progress.setValue(i)
140
- progress.processEvents()
141
- else:
142
- if done < int((i + 1) / len(atoms) * 50):
143
- done = int((i + 1) / len(atoms) * 50)
144
- sys.stdout.write('\r')
145
- # progress output :
146
- sys.stdout.write("[%-50s] %d%%" % ('=' * done, 2 * done))
147
- sys.stdout.flush()
148
-
149
- x, y = atoms[i][0:2]
150
- x = int(x)
151
- y = int(y)
152
-
153
- area = image[x - rr:x + rr + 1, y - rr:y + rr + 1]
154
-
155
- append = False
156
-
157
- if (x - rr) < 0 or y - rr < 0 or x + rr + 1 > image.shape[0] or y + rr + 1 > image.shape[1]:
158
- position.append(-1)
159
- intensities.append(0)
160
- maximum_area.append(0)
161
- else:
162
- position.append(1)
163
- intensities.append((area * mask).sum())
164
- maximum_area.append((area * mask).max())
165
-
166
- if max_int > 0:
167
- if area.sum() < max_int:
168
- if area.sum() > min_int:
169
- append = True
170
- elif area.sum() > min_int:
171
- append = True
172
-
173
- pout = [0, 0, 0, 0]
174
- if append:
175
- if (x - rr) < 0 or y - rr < 0 or x + rr + 1 > image.shape[0] or y + rr + 1 > image.shape[1]:
176
- pass
177
- else:
178
- [pout, _] = optimization.leastsq(gauss_difference, guess, args=(area, area))
179
-
180
- if (abs(pout[1]) > max_dist) or (abs(pout[2]) > max_dist):
181
- pout = [0, 0, 0, 0]
182
-
183
- volume.append(2 * np.pi * pout[3] * pout[0] * pout[0])
184
-
185
- new_atoms.append([x + pout[1], y + pout[2]]) # ,pout[0], volume)) #,pout[3]))
186
- if all(v == 0 for v in pout):
187
- gauss_intensity.append(0.)
188
- else:
189
- gauss = make_gauss(area.shape[0], area.shape[1], width=pout[0], x0=pout[1], y0=pout[2], intensity=pout[3])
190
- gauss_intensity.append((gauss * mask).sum())
191
- gauss_width.append(pout[0])
192
- gauss_amplitude.append(pout[3])
193
-
194
- sym['inside'] = position
195
- sym['intensity_area'] = intensities
196
- sym['maximum_area'] = maximum_area
197
- sym['atoms'] = new_atoms
198
- sym['gauss_width'] = gauss_width
199
- sym['gauss_amplitude'] = gauss_amplitude
200
- sym['gauss_intensity'] = gauss_intensity
201
- sym['gauss_volume'] = volume
202
-
203
- return sym
204
-
205
-
206
- def intensity_area(image, atoms, radius):
207
- rr = int(radius + 0.5) # atom radius
208
- print('using radius ', rr, 'pixels')
209
-
210
- pixels = np.linspace(0, 2 * rr, 2 * rr + 1) - rr
211
- x, y = np.meshgrid(pixels, pixels)
212
- mask = (x ** 2 + y ** 2) < rr ** 2
213
- intensities = []
214
- for i in range(len(atoms)):
215
- x = int(atoms[i][1])
216
- y = int(atoms[i][0])
217
- area = image[x - rr:x + rr + 1, y - rr:y + rr + 1]
218
- if area.shape == mask.shape:
219
- intensities.append((area * mask).sum())
220
- else:
221
- intensities.append(-1)
222
- return intensities
1
+ """ Atom detection
2
+
3
+ All atom detection is done here
4
+ Everything is in unit of pixel!!
5
+
6
+ Author: Gerd Duscher
7
+
8
+ part of pyTEMlib
9
+
10
+ a pycroscopy package
11
+ """
12
+
13
+ import numpy as np
14
+ import sys
15
+
16
+ # from skimage.feature import peak_local_max
17
+ from skimage.feature import blob_log
18
+
19
+ from sklearn.cluster import KMeans
20
+ from scipy.spatial import cKDTree
21
+ import scipy.optimize as optimization
22
+
23
+ import pyTEMlib.probe_tools as probe_tools
24
+ import pyTEMlib.file_tools as ft
25
+ import sidpy
26
+ from tqdm.auto import trange
27
+
28
+
29
+ def find_atoms(image, atom_size=0.1, threshold=0.):
30
+ """ Find atoms is a simple wrapper for blob_log in skimage.feature
31
+
32
+ Parameters
33
+ ----------
34
+ image: sidpy.Dataset
35
+ the image to find atoms
36
+ atom_size: float
37
+ visible size of atom blob diameter in nm gives minimal distance between found blobs
38
+ threshold: float
39
+ threshold for blob finder; (usually between 0.001 and 1.0) for threshold <= 0 we use the RMS contrast
40
+
41
+ Returns
42
+ -------
43
+ atoms: numpy array(Nx3)
44
+ atoms positions and radius of blob
45
+ """
46
+
47
+ if not isinstance(image, sidpy.Dataset):
48
+ raise TypeError('We need a sidpy.Dataset')
49
+ if image.data_type.name != 'IMAGE':
50
+ raise TypeError('We need sidpy.Dataset of sidpy.Datatype: IMAGE')
51
+ if not isinstance(atom_size, (float, int)):
52
+ raise TypeError('atom_size parameter has to be a number')
53
+ if not isinstance(threshold, float):
54
+ raise TypeError('threshold parameter has to be a float number')
55
+
56
+ scale_x = ft.get_slope(image.dim_0)
57
+ im = np.array(image-image.min())
58
+ im = im/im.max()
59
+ if threshold <= 0.:
60
+ threshold = np.std(im)
61
+ atoms = blob_log(im, max_sigma=atom_size/scale_x, threshold=threshold)
62
+
63
+ return atoms
64
+
65
+
66
+ def atoms_clustering(atoms, mid_atoms, number_of_clusters=3, nearest_neighbours=7):
67
+ """ A wrapper for sklearn.cluster kmeans clustering of atoms.
68
+
69
+ Parameters
70
+ ----------
71
+ atoms: list or np.array (Nx2)
72
+ list of all atoms
73
+ mid_atoms: list or np.array (Nx2)
74
+ atoms to be evaluated
75
+ number_of_clusters: int
76
+ number of clusters to sort (ini=3)
77
+ nearest_neighbours: int
78
+ number of nearest neighbours evaluated
79
+
80
+ Returns
81
+ -------
82
+ clusters, distances, indices: numpy arrays
83
+ """
84
+
85
+ # get distances
86
+ nn_tree = cKDTree(np.array(atoms)[:, 0:2])
87
+
88
+ distances, indices = nn_tree.query(np.array(mid_atoms)[:, 0:2], nearest_neighbours)
89
+
90
+ # Clustering
91
+ k_means = KMeans(n_clusters=number_of_clusters, random_state=0) # Fixing the RNG in kmeans
92
+ k_means.fit(distances)
93
+ clusters = k_means.predict(distances)
94
+
95
+ return clusters, distances, indices
96
+
97
+
98
+ def gauss_difference(params, area):
99
+ """
100
+ Difference between part of an image and a Gaussian
101
+ This function is used int he atom refine function of pyTEMlib
102
+
103
+ Parameters
104
+ ----------
105
+ params: list
106
+ list of Gaussian parameters [width, position_x, position_y, intensity]
107
+ area: numpy array
108
+ 2D matrix = part of an image
109
+
110
+ Returns
111
+ -------
112
+ numpy array: flattened array of difference
113
+
114
+ """
115
+ gauss = probe_tools.make_gauss(area.shape[0], area.shape[1], width=params[0], x0=params[1], y0=params[2],
116
+ intensity=params[3])
117
+ return (area - gauss).flatten()
118
+
119
+
120
+ def atom_refine(image, atoms, radius, max_int=0, min_int=0, max_dist=4):
121
+ """Fits a Gaussian in a blob of an image
122
+
123
+ Parameters
124
+ ----------
125
+ image: np.array or sidpy Dataset
126
+ atoms: list or np.array
127
+ positions of atoms
128
+ radius: float
129
+ radius of circular mask to define fitting of Gaussian
130
+ max_int: float
131
+ optional - maximum intensity to be considered for fitting (to exclude contaminated areas for example)
132
+ min_int: float
133
+ optional - minimum intensity to be considered for fitting (to exclude contaminated holes for example)
134
+ max_dist: float
135
+ optional - maximum distance of movement of Gaussian during fitting
136
+
137
+ Returns
138
+ -------
139
+ sym: dict
140
+ dictionary containing new atom positions and other output such as intensity of the fitted Gaussian
141
+ """
142
+ rr = int(radius + 0.5) # atom radius
143
+ print('using radius ', rr, 'pixels')
144
+
145
+ pixels = np.linspace(0, 2 * rr, 2 * rr + 1) - rr
146
+ x, y = np.meshgrid(pixels, pixels)
147
+ mask = (x ** 2 + y ** 2) < rr ** 2
148
+
149
+ guess = [rr * 2, 0.0, 0.0, 1]
150
+
151
+ sym = {'number_of_atoms': len(atoms)}
152
+
153
+ volume = []
154
+ position = []
155
+ intensities = []
156
+ maximum_area = []
157
+ new_atoms = []
158
+ gauss_width = []
159
+ gauss_amplitude = []
160
+ gauss_intensity = []
161
+
162
+ for i in trange(len(atoms)):
163
+ x, y = atoms[i][0:2]
164
+ x = int(x)
165
+ y = int(y)
166
+
167
+ area = image[x - rr:x + rr + 1, y - rr:y + rr + 1]
168
+
169
+ append = False
170
+
171
+ if (x - rr) < 0 or y - rr < 0 or x + rr + 1 > image.shape[0] or y + rr + 1 > image.shape[1]: # atom not found
172
+ position.append(-1)
173
+ intensities.append(-1.)
174
+ maximum_area.append(-1.)
175
+ else: # atom found
176
+ position.append(1)
177
+ intensities.append((area * mask).sum())
178
+ maximum_area.append((area * mask).max())
179
+
180
+ if max_int > 0:
181
+ if area.sum() < max_int:
182
+ if area.sum() > min_int:
183
+ append = True
184
+ elif area.sum() > min_int:
185
+ append = True
186
+
187
+ pout = [0, 0, 0, 0]
188
+ if append:
189
+ if (x - rr) < 0 or y - rr < 0 or x + rr + 1 > image.shape[0] or y + rr + 1 > image.shape[1]:
190
+ pass
191
+ else:
192
+ [pout, _] = optimization.leastsq(gauss_difference, guess, args=area)
193
+
194
+ if (abs(pout[1]) > max_dist) or (abs(pout[2]) > max_dist):
195
+ pout = [0, 0, 0, 0]
196
+
197
+ volume.append(2 * np.pi * pout[3] * pout[0] * pout[0])
198
+
199
+ new_atoms.append([x + pout[1], y + pout[2]]) # ,pout[0], volume)) #,pout[3]))
200
+ if all(v == 0 for v in pout):
201
+ gauss_intensity.append(0.)
202
+ else:
203
+ gauss = probe_tools.make_gauss(area.shape[0], area.shape[1], width=pout[0], x0=pout[1], y0=pout[2],
204
+ intensity=pout[3])
205
+ gauss_intensity.append((gauss * mask).sum())
206
+ gauss_width.append(pout[0])
207
+ gauss_amplitude.append(pout[3])
208
+
209
+ sym['inside'] = position
210
+ sym['intensity_area'] = intensities
211
+ sym['maximum_area'] = maximum_area
212
+ sym['atoms'] = new_atoms
213
+ sym['gauss_width'] = gauss_width
214
+ sym['gauss_amplitude'] = gauss_amplitude
215
+ sym['gauss_intensity'] = gauss_intensity
216
+ sym['gauss_volume'] = volume
217
+
218
+ return sym
219
+
220
+
221
+ def intensity_area(image, atoms, radius):
222
+ """
223
+ integrated intensity of atoms in an image with a mask around each atom of radius radius
224
+ """
225
+ rr = int(radius + 0.5) # atom radius
226
+ print('using radius ', rr, 'pixels')
227
+
228
+ pixels = np.linspace(0, 2 * rr, 2 * rr + 1) - rr
229
+ x, y = np.meshgrid(pixels, pixels)
230
+ mask = np.array((x ** 2 + y ** 2) < rr ** 2)
231
+ intensities = []
232
+ for i in range(len(atoms)):
233
+ x = int(atoms[i][1])
234
+ y = int(atoms[i][0])
235
+ area = image[x - rr:x + rr + 1, y - rr:y + rr + 1]
236
+ if area.shape == mask.shape:
237
+ intensities.append((area * mask).sum())
238
+ else:
239
+ intensities.append(-1)
240
+ return intensities
pyTEMlib/config_dir.py CHANGED
@@ -1,29 +1,57 @@
1
- # -*- coding: utf-8 -*-
2
- # Gleaned from
3
- # Copyright © 2007 Francisco Javier de la Peña
4
- # file of EELSLab.
5
- #
6
-
7
- import os
8
- import shutil
9
-
10
- config_files = ['TEMlibrc', 'microscopes.csv', 'edges_db.csv', 'edges_db.pkl', 'fparam.txt']
11
- data_path = os.sep.join([os.path.dirname(__file__), 'data'])
12
-
13
- if os.name == 'posix':
14
- config_path = os.path.join(os.path.expanduser('~'), '.TEMlib')
15
- os_name = 'posix'
16
- elif os.name in ['nt', 'dos']:
17
- config_path = os.path.join(os.path.expanduser('~'), '.TEMlib')
18
- os_name = 'windows'
19
- else:
20
- config_path = '.'
21
- if os.path.isdir(config_path) is False:
22
- # messages.information("Creating config directory: %s" % config_path)
23
- os.mkdir(config_path)
24
-
25
- for file in config_files:
26
- templates_file = os.path.join(data_path, file)
27
- config_file = os.path.join(config_path, file)
28
- if os.path.isfile(config_file) is False:
29
- shutil.copy(templates_file, config_file)
1
+ # -*- coding: utf-8 -*-
2
+ # part of pyTEMlib
3
+ # 2022/08 Changed this to be hopefully compatible with conda-forge
4
+ #
5
+ #
6
+ """
7
+ config_dir: setup of directory ~/.pyTEMlib for custom sources and database
8
+ """
9
+ import os
10
+
11
+ # import wget
12
+ if os.name == 'posix':
13
+ config_path = os.path.join(os.path.expanduser('~'), '.pyTEMlib')
14
+ os_name = 'posix'
15
+ elif os.name in ['nt', 'dos']:
16
+ config_path = os.path.join(os.path.expanduser('~'), '.pyTEMlib')
17
+ os_name = 'windows'
18
+ else:
19
+ config_path = '.'
20
+
21
+ if os.path.isdir(config_path) is False:
22
+ # messages.information("Creating config directory: %s" % config_path)
23
+ os.mkdir(config_path)
24
+
25
+ lines = ['Microscope,E0,alpha,beta,pppc,correlation_factor,VOA_conv,EELS_b1,EELS_b2,EELS_b100,MADF_offset,MADF_slope,'
26
+ 'HADF_offset,HADF_slope,BF_offset,BF_slope',
27
+ 'Libra 200,2.00E+05,10,15,1,1,6241509.647,0.0634,0.0634,0.0634,0,0,0,0,0,0',
28
+ 'UltraSTEM 60,6.00E+04,30,50,1,1,1.79E+07,0.2,0.45,0.9,0.001383,4.04E-06,0,0,0,0',
29
+ 'UltraSTEM 100,1.00E+05,30,50,1,1,6.24E+06,0.45,1,2,0,0,0,0,0,0',
30
+ 'UltraSTEM 200,2.00E+05,30,50,1,1,6.24E+06,0.45,1,2,0,0,0,0,0,0']
31
+
32
+ config_file = os.path.join(config_path, 'microscopes.csv')
33
+ if os.path.isfile(config_file) is False: # Do not overwrite users microscopy files
34
+ with open(config_file, 'w') as f:
35
+ f.write('\n'.join(lines))
36
+
37
+ """
38
+ import pickle
39
+ from pkg_resources import resource_filename
40
+
41
+ data_path = resource_filename(__name__, 'data')
42
+ pkl_file = open(data_path + '/old/edges_db.pkl', 'rb')
43
+ x_sections = pickle.load(pkl_file)
44
+ pkl_file.close()
45
+ for key in range(80, 83):
46
+ print(f'\'{key}\': ', x_sections[str(key)], ',')
47
+
48
+ # config_file = os.path.join(config_path, 'edges_db.pkl')
49
+ ref = importlib_resources.files('pyTEMlib') / 'data/edges_db.pkl'
50
+ with importlib_resources.as_file(ref) as templates_file:
51
+ if os.path.isfile(config_file) is False:
52
+ try:
53
+ shutil.copy(templates_file, config_file)
54
+ except FileNotFoundError:
55
+ pass
56
+ # wget('https://github.com/pycroscopy/pyTEMlib/tree/main/pyTEMlib/data/'+file)
57
+ """