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.

Files changed (94) hide show
  1. build/lib/pyTEMlib/__init__.py +33 -0
  2. build/lib/pyTEMlib/animation.py +640 -0
  3. build/lib/pyTEMlib/atom_tools.py +238 -0
  4. build/lib/pyTEMlib/config_dir.py +31 -0
  5. build/lib/pyTEMlib/crystal_tools.py +1219 -0
  6. build/lib/pyTEMlib/diffraction_plot.py +756 -0
  7. build/lib/pyTEMlib/dynamic_scattering.py +293 -0
  8. build/lib/pyTEMlib/eds_tools.py +826 -0
  9. build/lib/pyTEMlib/eds_xsections.py +432 -0
  10. build/lib/pyTEMlib/eels_tools/__init__.py +44 -0
  11. build/lib/pyTEMlib/eels_tools/core_loss_tools.py +751 -0
  12. build/lib/pyTEMlib/eels_tools/eels_database.py +134 -0
  13. build/lib/pyTEMlib/eels_tools/low_loss_tools.py +655 -0
  14. build/lib/pyTEMlib/eels_tools/peak_fit_tools.py +175 -0
  15. build/lib/pyTEMlib/eels_tools/zero_loss_tools.py +264 -0
  16. build/lib/pyTEMlib/file_reader.py +274 -0
  17. build/lib/pyTEMlib/file_tools.py +811 -0
  18. build/lib/pyTEMlib/get_bote_salvat.py +69 -0
  19. build/lib/pyTEMlib/graph_tools.py +1153 -0
  20. build/lib/pyTEMlib/graph_viz.py +599 -0
  21. build/lib/pyTEMlib/image/__init__.py +37 -0
  22. build/lib/pyTEMlib/image/image_atoms.py +270 -0
  23. build/lib/pyTEMlib/image/image_clean.py +197 -0
  24. build/lib/pyTEMlib/image/image_distortion.py +299 -0
  25. build/lib/pyTEMlib/image/image_fft.py +277 -0
  26. build/lib/pyTEMlib/image/image_graph.py +926 -0
  27. build/lib/pyTEMlib/image/image_registration.py +316 -0
  28. build/lib/pyTEMlib/image/image_utilities.py +309 -0
  29. build/lib/pyTEMlib/image/image_window.py +421 -0
  30. build/lib/pyTEMlib/image_tools.py +699 -0
  31. build/lib/pyTEMlib/interactive_image.py +1 -0
  32. build/lib/pyTEMlib/kinematic_scattering.py +1196 -0
  33. build/lib/pyTEMlib/microscope.py +61 -0
  34. build/lib/pyTEMlib/probe_tools.py +906 -0
  35. build/lib/pyTEMlib/sidpy_tools.py +153 -0
  36. build/lib/pyTEMlib/simulation_tools.py +104 -0
  37. build/lib/pyTEMlib/test.py +437 -0
  38. build/lib/pyTEMlib/utilities.py +314 -0
  39. build/lib/pyTEMlib/version.py +5 -0
  40. build/lib/pyTEMlib/xrpa_x_sections.py +20976 -0
  41. pyTEMlib/__init__.py +25 -3
  42. pyTEMlib/animation.py +31 -22
  43. pyTEMlib/atom_tools.py +29 -34
  44. pyTEMlib/config_dir.py +2 -28
  45. pyTEMlib/crystal_tools.py +129 -165
  46. pyTEMlib/eds_tools.py +559 -342
  47. pyTEMlib/eds_xsections.py +432 -0
  48. pyTEMlib/eels_tools/__init__.py +44 -0
  49. pyTEMlib/eels_tools/core_loss_tools.py +751 -0
  50. pyTEMlib/eels_tools/eels_database.py +134 -0
  51. pyTEMlib/eels_tools/low_loss_tools.py +655 -0
  52. pyTEMlib/eels_tools/peak_fit_tools.py +175 -0
  53. pyTEMlib/eels_tools/zero_loss_tools.py +264 -0
  54. pyTEMlib/file_reader.py +274 -0
  55. pyTEMlib/file_tools.py +260 -1130
  56. pyTEMlib/get_bote_salvat.py +69 -0
  57. pyTEMlib/graph_tools.py +101 -174
  58. pyTEMlib/graph_viz.py +150 -0
  59. pyTEMlib/image/__init__.py +37 -0
  60. pyTEMlib/image/image_atoms.py +270 -0
  61. pyTEMlib/image/image_clean.py +197 -0
  62. pyTEMlib/image/image_distortion.py +299 -0
  63. pyTEMlib/image/image_fft.py +277 -0
  64. pyTEMlib/image/image_graph.py +926 -0
  65. pyTEMlib/image/image_registration.py +316 -0
  66. pyTEMlib/image/image_utilities.py +309 -0
  67. pyTEMlib/image/image_window.py +421 -0
  68. pyTEMlib/image_tools.py +154 -928
  69. pyTEMlib/kinematic_scattering.py +1 -1
  70. pyTEMlib/probe_tools.py +1 -1
  71. pyTEMlib/test.py +437 -0
  72. pyTEMlib/utilities.py +314 -0
  73. pyTEMlib/version.py +2 -3
  74. pyTEMlib/xrpa_x_sections.py +14 -10
  75. {pytemlib-0.2025.4.2.dist-info → pytemlib-0.2025.9.1.dist-info}/METADATA +13 -16
  76. pytemlib-0.2025.9.1.dist-info/RECORD +86 -0
  77. {pytemlib-0.2025.4.2.dist-info → pytemlib-0.2025.9.1.dist-info}/WHEEL +1 -1
  78. pytemlib-0.2025.9.1.dist-info/top_level.txt +6 -0
  79. pyTEMlib/core_loss_widget.py +0 -721
  80. pyTEMlib/eels_dialog.py +0 -754
  81. pyTEMlib/eels_dialog_utilities.py +0 -1199
  82. pyTEMlib/eels_tools.py +0 -2359
  83. pyTEMlib/file_tools_qt.py +0 -193
  84. pyTEMlib/image_dialog.py +0 -158
  85. pyTEMlib/image_dlg.py +0 -146
  86. pyTEMlib/info_widget.py +0 -1086
  87. pyTEMlib/info_widget3.py +0 -1120
  88. pyTEMlib/low_loss_widget.py +0 -479
  89. pyTEMlib/peak_dialog.py +0 -1129
  90. pyTEMlib/peak_dlg.py +0 -286
  91. pytemlib-0.2025.4.2.dist-info/RECORD +0 -38
  92. pytemlib-0.2025.4.2.dist-info/top_level.txt +0 -1
  93. {pytemlib-0.2025.4.2.dist-info → pytemlib-0.2025.9.1.dist-info}/entry_points.txt +0 -0
  94. {pytemlib-0.2025.4.2.dist-info → pytemlib-0.2025.9.1.dist-info}/licenses/LICENSE +0 -0
pyTEMlib/__init__.py CHANGED
@@ -1,11 +1,33 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  """
3
+ PyTEMlib
4
+ --------
5
+ A Python package for analyzing and processing transmission electron microscopy (TEM) data.
6
+ This package provides tools for data quantification through a model-based approach,
7
+ including functionalities for imaging, spectra analysis, and data visualization.
8
+
9
+ The package is part of the pycrosccopy ecosystem and the dataformat is based on sidpy,
10
+ the fileformat is based on pyNSDI.
3
11
  Created on Sat Jan 19 10:07:35 2019
12
+ Update on Sun Jul 20 2025
4
13
 
5
14
  @author: gduscher
6
15
  """
7
- from .version import _version as __version__
16
+ from .version import __version__
8
17
 
9
- __all__ = ['__version__']
18
+ from . import file_tools
19
+ from . import image_tools
20
+ from .image import image_atoms as atom_tools
21
+ from . import graph_tools
22
+ from . import probe_tools
23
+ from . import eels_tools
24
+ from . import eds_tools
25
+ from . import crystal_tools
26
+ from . import kinematic_scattering
27
+ from . import dynamic_scattering
28
+ from .config_dir import config_path
10
29
 
11
- name = "pyTEMlib"
30
+ __all__ = ['__version__', 'file_tools', 'image_tools', 'atom_tools',
31
+ 'graph_tools', 'probe_tools', 'eels_tools', 'eds_tools',
32
+ 'crystal_tools', 'kinematic_scattering', 'dynamic_scattering', 'config_path']
33
+ __author__ = 'Gerd Duscher'
pyTEMlib/animation.py CHANGED
@@ -8,7 +8,7 @@ revision: 01/11/2021
8
8
 
9
9
  import numpy as np
10
10
  import matplotlib.pyplot as plt
11
- import matplotlib.patches as patches
11
+ from matplotlib import patches
12
12
 
13
13
  from ipywidgets import widgets
14
14
  from IPython.display import display
@@ -50,8 +50,8 @@ def geometric_ray_diagram(focal_length=1., magnification=False):
50
50
  ax.add_patch(ellipse)
51
51
  ax.plot([1.5, -1.5], [0, 0], '--', color='black')
52
52
  ax.plot([0, 0], [u, -v], '--', color='black')
53
- single_prop = dict(arrowstyle="->", shrinkA=0, shrinkB=0)
54
- double_prop = dict(arrowstyle="<->", shrinkA=0, shrinkB=0)
53
+ single_prop = {"arrowstyle": '->', "shrinkA": 0, "shrinkB": 0}
54
+ double_prop = {"arrowstyle": "<->", "shrinkA": 0, "shrinkB": 0}
55
55
 
56
56
  if magnification:
57
57
  ax.annotate("", xy=(-x, u), xytext=(x, u), arrowprops=single_prop)
@@ -120,14 +120,16 @@ def add_lens(z, f, diam, lens_labels):
120
120
  def add_aperture(z, diam, radius, lens_labels):
121
121
  """add aperture to propagate beam plot"""
122
122
 
123
- ww, tw, rad = diam / 10.0, diam / 3.0, diam / 2.0
123
+ # ww, tw, rad = diam / 10.0, diam / 3.0, diam / 2.0
124
+ rad = diam / 2
124
125
  radius = radius / 2
125
126
  plt.plot([z, z], [-rad, -radius], 'k', linewidth=2)
126
127
  plt.plot([z, z], [rad, radius], 'k', linewidth=2)
127
128
  plt.text(z, -rad - 2.0, lens_labels, fontsize=12)
128
129
 
129
130
 
130
- def propagate_beam(source_position, numerical_aperture, number_of_rays, lens_positions, focal_lengths,
131
+ def propagate_beam(source_position, numerical_aperture, number_of_rays,
132
+ lens_positions, focal_lengths,
131
133
  lens_labels='', color='b'):
132
134
  """geometrical propagation of light rays from given source
133
135
 
@@ -242,33 +244,35 @@ def deficient_holz_line(exact_bragg=False, shift=False, laue_zone=1, color='blac
242
244
  k_0[1] += shift_y
243
245
 
244
246
  # Ewald Sphere
245
- ewald_sphere = patches.Circle((k_0[0], k_0[1]), radius=np.linalg.norm(k_0), clip_on=False, zorder=10, linewidth=1,
247
+ ewald_sphere = patches.Circle((k_0[0], k_0[1]), radius=np.linalg.norm(k_0),
248
+ clip_on=False, zorder=10, linewidth=1,
246
249
  edgecolor=color, fill=False)
247
250
  plt.gca().add_artist(ewald_sphere)
248
251
 
249
- plt.gca().arrow(g[-1] + .1 / d / 4, 1 / d / 2, 0, 1 / d / 2, head_width=0.03, head_length=0.04, fc='k', ec='k',
250
- length_includes_head=True)
251
- plt.gca().arrow(g[-1] + .1 / d / 4, 1 / d / 2, 0, -1 / d / 2, head_width=0.03, head_length=0.04, fc='k', ec='k',
252
- length_includes_head=True)
253
- plt.gca().annotate("$|g_{HOLZ}|$", xytext=(g[-1] + .1 / d / 3, 1 / d / 3), xy=(g[-1] + 1 / d / 3, 1 / d / 3))
254
-
255
- # k_0
252
+ plt.gca().arrow(g[-1] + .1 / d / 4, 1 / d / 2, 0, 1 / d / 2, head_width=0.03,
253
+ head_length=0.04, fc='k', ec='k', length_includes_head=True)
254
+ plt.gca().arrow(g[-1] + .1 / d / 4, 1 / d / 2, 0, -1 / d / 2, head_width=0.03,
255
+ head_length=0.04, fc='k', ec='k', length_includes_head=True)
256
+ plt.gca().annotate("$|g_{HOLZ}|$", xytext=(g[-1] + .1 / d / 3, 1 / d / 3),
257
+ xy=(g[-1] + 1 / d / 3, 1 / d / 3))
256
258
  plt.scatter(k_0[0], k_0[1])
257
- plt.gca().arrow(k_0[0], k_0[1], -k_0[0] + shift_x, -k_0[1] + shift_y, head_width=0.03, head_length=0.04, fc=color,
258
- ec=color, length_includes_head=True)
259
+ plt.gca().arrow(k_0[0], k_0[1], -k_0[0] + shift_x, -k_0[1] + shift_y, head_width=0.03,
260
+ head_length=0.04, fc=color, ec=color, length_includes_head=True)
259
261
  plt.gca().annotate("K$_0$", xytext=(k_0[0] / 2, k_0[1] / 3), xy=(k_0[0] / 2, k_0[1] / 2))
260
262
 
261
263
  # K_d Bragg of HOLZ reflection
262
- plt.gca().arrow(k_0[0], k_0[1], -k_0[0] + g_d[0] + shift_x, -k_0[1] + g_d[1] + s_g + shift_y, head_width=0.03,
263
- head_length=0.04, fc=color,
264
- ec=color, length_includes_head=True)
265
- plt.gca().annotate("K$_d$", xytext=(k_0[0] + (g_d[0] - k_0[0]) / 2, k_0[1] / 2), xy=(6.5 / d / 2, k_0[1] / 2))
264
+ plt.gca().arrow(k_0[0], k_0[1], -k_0[0] + g_d[0] + shift_x, -k_0[1] + g_d[1] + s_g + shift_y,
265
+ head_width=0.03, head_length=0.04, fc=color, ec=color,
266
+ length_includes_head=True)
267
+ plt.gca().annotate("K$_d$", xytext=(k_0[0] + (g_d[0] - k_0[0]) / 2, k_0[1] / 2),
268
+ xy=(6.5 / d / 2, k_0[1] / 2))
266
269
 
267
270
  # s_g excitation Error of HOLZ reflection
268
271
  if s_g > 0:
269
272
  plt.gca().arrow(g_d[0], g_d[1], 0, s_g, head_width=0.03, head_length=0.04, fc='k',
270
273
  ec='k', length_includes_head=True)
271
- plt.gca().annotate("s$_g$", xytext=(g_d[0] * 1.01, g_d[1] + s_g / 3), xy=(g_d[0] * 1.01, g_d[1] + s_g / 3))
274
+ plt.gca().annotate("s$_g$", xytext=(g_d[0] * 1.01, g_d[1] + s_g / 3),
275
+ xy=(g_d[0] * 1.01, g_d[1] + s_g / 3))
272
276
 
273
277
  # Bragg angle
274
278
  g_sg = g_d
@@ -311,6 +315,7 @@ def deficient_holz_line(exact_bragg=False, shift=False, laue_zone=1, color='blac
311
315
 
312
316
 
313
317
  def deficient_kikuchi_line(s_g=0., color_b='black'):
318
+ """Draw the deficient Kikuchi line in the plot."""
314
319
  k_len = 1 / ks.get_wavelength(20)
315
320
  d = 2 # lattice parameter in nm
316
321
 
@@ -391,7 +396,7 @@ def deficient_kikuchi_line(s_g=0., color_b='black'):
391
396
  plt.gca().set_xlim(-.2, 1.03)
392
397
 
393
398
 
394
- class InteractiveAberration(object):
399
+ class InteractiveAberration():
395
400
  """
396
401
  ### Interactive explanation of aberrations
397
402
 
@@ -423,6 +428,7 @@ class InteractiveAberration(object):
423
428
  # self.cid = self.figure.canvas.mpl_connect('button_press_event', self.onclick)
424
429
 
425
430
  def on_button_clicked(self, b):
431
+ """Handle button click events to update the analysis options"""
426
432
  # print(b['owner'].description)
427
433
  selection = b['owner'].description
428
434
  if selection in self.analysis:
@@ -432,6 +438,7 @@ class InteractiveAberration(object):
432
438
  self.update()
433
439
 
434
440
  def update(self):
441
+ """Update the plot based on the selected analysis options"""
435
442
  ax = self.ax
436
443
  ax.clear()
437
444
  selection = self.analysis
@@ -519,7 +526,7 @@ class InteractiveAberration(object):
519
526
  plt.gca().add_patch(aberration2)
520
527
 
521
528
 
522
- class InteractiveRonchigramMagnification(object):
529
+ class InteractiveRonchigramMagnification():
523
530
  """
524
531
  ### Interactive explanation of magnification
525
532
 
@@ -551,6 +558,7 @@ class InteractiveRonchigramMagnification(object):
551
558
  # self.cid = self.figure.canvas.mpl_connect('button_press_event', self.onclick)
552
559
 
553
560
  def on_button_clicked(self, b):
561
+ """Handle button click events"""
554
562
  # print(b['owner'].description)
555
563
  selection = b['owner'].description
556
564
  if selection in self.analysis:
@@ -560,6 +568,7 @@ class InteractiveRonchigramMagnification(object):
560
568
  self.update()
561
569
 
562
570
  def update(self):
571
+ """Update the plot based on the selected analysis options"""
563
572
  ax = self.ax
564
573
  ax.clear()
565
574
  selection = self.analysis
pyTEMlib/atom_tools.py CHANGED
@@ -12,20 +12,16 @@ a pycroscopy package
12
12
  """
13
13
 
14
14
  import numpy as np
15
- import sys
16
15
 
17
- # from skimage.feature import peak_local_max
18
- from skimage.feature import blob_log
16
+ import skimage.feature
17
+ import sklearn.cluster
18
+ import scipy.spatial
19
+ import scipy.optimize
19
20
 
20
- from sklearn.cluster import KMeans
21
- from scipy.spatial import cKDTree
22
- import scipy.optimize as optimization
23
-
24
- import pyTEMlib.probe_tools as probe_tools
25
- import pyTEMlib.file_tools as ft
26
- import sidpy
27
21
  from tqdm.auto import trange
28
22
 
23
+ import sidpy
24
+ import pyTEMlib
29
25
 
30
26
  def find_atoms(image, atom_size=0.1, threshold=0.):
31
27
  """ Find atoms is a simple wrapper for blob_log in skimage.feature
@@ -37,7 +33,8 @@ def find_atoms(image, atom_size=0.1, threshold=0.):
37
33
  atom_size: float
38
34
  visible size of atom blob diameter in nm gives minimal distance between found blobs
39
35
  threshold: float
40
- threshold for blob finder; (usually between 0.001 and 1.0) for threshold <= 0 we use the RMS contrast
36
+ threshold for blob finder; (usually between 0.001 and 1.0)
37
+ for threshold <= 0 we use the RMS contrast
41
38
 
42
39
  Returns
43
40
  -------
@@ -59,10 +56,7 @@ def find_atoms(image, atom_size=0.1, threshold=0.):
59
56
  im = im/im.max()
60
57
  if threshold <= 0.:
61
58
  threshold = np.std(im)
62
- atoms = blob_log(im, max_sigma=atom_size/scale_x, threshold=threshold)
63
-
64
-
65
-
59
+ atoms = skimage.feature.blob_log(im, max_sigma=atom_size/scale_x, threshold=threshold)
66
60
  return atoms
67
61
 
68
62
 
@@ -86,12 +80,12 @@ def atoms_clustering(atoms, mid_atoms, number_of_clusters=3, nearest_neighbours=
86
80
  """
87
81
 
88
82
  # get distances
89
- nn_tree = cKDTree(np.array(atoms)[:, 0:2])
83
+ nn_tree = scipy.spatial.KDTree(np.array(atoms)[:, 0:2])
90
84
 
91
85
  distances, indices = nn_tree.query(np.array(mid_atoms)[:, 0:2], nearest_neighbours)
92
86
 
93
- # Clustering
94
- k_means = KMeans(n_clusters=number_of_clusters, random_state=0) # Fixing the RNG in kmeans
87
+ # Clustering with fixed RNG in kmeans
88
+ k_means = sklearn.cluster.KMeans(n_clusters=number_of_clusters, random_state=0)
95
89
  k_means.fit(distances)
96
90
  clusters = k_means.predict(distances)
97
91
 
@@ -115,8 +109,9 @@ def gauss_difference(params, area):
115
109
  numpy array: flattened array of difference
116
110
 
117
111
  """
118
- gauss = probe_tools.make_gauss(area.shape[0], area.shape[1], width=params[0], x0=params[1], y0=params[2],
119
- intensity=params[3])
112
+ gauss = pyTEMlib.probe_tools.make_gauss(area.shape[0], area.shape[1],
113
+ width=params[0], x0=params[1],
114
+ y0=params[2], intensity=params[3])
120
115
  return (area - gauss).flatten()
121
116
 
122
117
 
@@ -131,19 +126,20 @@ def atom_refine(image, atoms, radius, max_int=0, min_int=0, max_dist=4):
131
126
  radius: float
132
127
  radius of circular mask to define fitting of Gaussian
133
128
  max_int: float
134
- optional - maximum intensity to be considered for fitting (to exclude contaminated areas for example)
129
+ optional - maximum intensity to be considered for fitting
130
+ (to exclude contaminated areas for example)
135
131
  min_int: float
136
- optional - minimum intensity to be considered for fitting (to exclude contaminated holes for example)
132
+ optional - minimum intensity to be considered for fitting
133
+ (to exclude contaminated holes for example)
137
134
  max_dist: float
138
135
  optional - maximum distance of movement of Gaussian during fitting
139
136
 
140
137
  Returns
141
138
  -------
142
139
  sym: dict
143
- dictionary containing new atom positions and other output such as intensity of the fitted Gaussian
140
+ dictionary containing new atom positions and other output
144
141
  """
145
142
  rr = int(radius + 0.5) # atom radius
146
- print('using radius ', rr, 'pixels')
147
143
 
148
144
  pixels = np.linspace(0, 2 * rr, 2 * rr + 1) - rr
149
145
  x, y = np.meshgrid(pixels, pixels)
@@ -162,7 +158,7 @@ def atom_refine(image, atoms, radius, max_int=0, min_int=0, max_dist=4):
162
158
  gauss_amplitude = []
163
159
  gauss_intensity = []
164
160
 
165
- for i in trange(len(atoms)):
161
+ for i in range(len(atoms)):
166
162
  x, y = atoms[i][0:2]
167
163
  x = int(x)
168
164
  y = int(y)
@@ -171,7 +167,7 @@ def atom_refine(image, atoms, radius, max_int=0, min_int=0, max_dist=4):
171
167
 
172
168
  append = False
173
169
 
174
- 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
170
+ if x-rr < 0 or y-rr < 0 or x+rr+1 > image.shape[0] or y+rr+1 > image.shape[1]:
175
171
  position.append(-1)
176
172
  intensities.append(-1.)
177
173
  maximum_area.append(-1.)
@@ -189,11 +185,10 @@ def atom_refine(image, atoms, radius, max_int=0, min_int=0, max_dist=4):
189
185
 
190
186
  pout = [0, 0, 0, 0]
191
187
  if append:
192
- if (x - rr) < 0 or y - rr < 0 or x + rr + 1 > image.shape[0] or y + rr + 1 > image.shape[1]:
188
+ if x-rr < 0 or y-rr < 0 or x+rr+1 > image.shape[0] or y+rr+1 > image.shape[1]:
193
189
  pass
194
190
  else:
195
- [pout, _] = optimization.leastsq(gauss_difference, guess, args=area)
196
-
191
+ [pout, _] = scipy.optimize.leastsq(gauss_difference, guess, args=area)
197
192
  if (abs(pout[1]) > max_dist) or (abs(pout[2]) > max_dist):
198
193
  pout = [0, 0, 0, 0]
199
194
 
@@ -203,8 +198,8 @@ def atom_refine(image, atoms, radius, max_int=0, min_int=0, max_dist=4):
203
198
  if all(v == 0 for v in pout):
204
199
  gauss_intensity.append(0.)
205
200
  else:
206
- gauss = probe_tools.make_gauss(area.shape[0], area.shape[1], width=pout[0], x0=pout[1], y0=pout[2],
207
- intensity=pout[3])
201
+ gauss = pyTEMlib.probe_tools.make_gauss(area.shape[0], area.shape[1], width=pout[0],
202
+ x0=pout[1], y0=pout[2], intensity=pout[3])
208
203
  gauss_intensity.append((gauss * mask).sum())
209
204
  gauss_width.append(pout[0])
210
205
  gauss_amplitude.append(pout[3])
@@ -232,9 +227,9 @@ def intensity_area(image, atoms, radius):
232
227
  x, y = np.meshgrid(pixels, pixels)
233
228
  mask = np.array((x ** 2 + y ** 2) < rr ** 2)
234
229
  intensities = []
235
- for i in range(len(atoms)):
236
- x = int(atoms[i][1])
237
- y = int(atoms[i][0])
230
+ for atom in atoms:
231
+ x = int(atom[1])
232
+ y = int(atom[0])
238
233
  area = image[x - rr:x + rr + 1, y - rr:y + rr + 1]
239
234
  if area.shape == mask.shape:
240
235
  intensities.append((area * mask).sum())
pyTEMlib/config_dir.py CHANGED
@@ -9,12 +9,8 @@ config_dir: setup of directory ~/.pyTEMlib for custom sources and database
9
9
  import os
10
10
 
11
11
  # import wget
12
- if os.name == 'posix':
12
+ if os.name in ['nt', 'dos', 'posix']:
13
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
14
  else:
19
15
  config_path = '.'
20
16
 
@@ -31,27 +27,5 @@ lines = ['Microscope,E0,alpha,beta,pppc,correlation_factor,VOA_conv,EELS_b1,EELS
31
27
 
32
28
  config_file = os.path.join(config_path, 'microscopes.csv')
33
29
  if os.path.isfile(config_file) is False: # Do not overwrite users microscopy files
34
- with open(config_file, 'w') as f:
30
+ with open(config_file, 'w', encoding='utf-8') as f:
35
31
  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
- """