pyTEMlib 0.2024.2.0__py2.py3-none-any.whl → 0.2024.2.2__py2.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/file_tools.py +5 -4
- pyTEMlib/image_tools.py +73 -13
- pyTEMlib/version.py +2 -2
- {pyTEMlib-0.2024.2.0.dist-info → pyTEMlib-0.2024.2.2.dist-info}/METADATA +3 -2
- {pyTEMlib-0.2024.2.0.dist-info → pyTEMlib-0.2024.2.2.dist-info}/RECORD +9 -9
- {pyTEMlib-0.2024.2.0.dist-info → pyTEMlib-0.2024.2.2.dist-info}/LICENSE +0 -0
- {pyTEMlib-0.2024.2.0.dist-info → pyTEMlib-0.2024.2.2.dist-info}/WHEEL +0 -0
- {pyTEMlib-0.2024.2.0.dist-info → pyTEMlib-0.2024.2.2.dist-info}/entry_points.txt +0 -0
- {pyTEMlib-0.2024.2.0.dist-info → pyTEMlib-0.2024.2.2.dist-info}/top_level.txt +0 -0
pyTEMlib/file_tools.py
CHANGED
|
@@ -82,11 +82,12 @@ class FileWidget(ipywidgets.DOMWidget):
|
|
|
82
82
|
|
|
83
83
|
"""
|
|
84
84
|
|
|
85
|
-
def __init__(self, dir_name=None, extension=['*']):
|
|
85
|
+
def __init__(self, dir_name=None, extension=['*'], sum_frames=False):
|
|
86
86
|
self.save_path = False
|
|
87
87
|
self.dir_dictionary = {}
|
|
88
88
|
self.dir_list = ['.', '..']
|
|
89
89
|
self.display_list = ['.', '..']
|
|
90
|
+
self.sum_frames = sum_frames
|
|
90
91
|
|
|
91
92
|
self.dir_name = '.'
|
|
92
93
|
if dir_name is None:
|
|
@@ -148,7 +149,7 @@ class FileWidget(ipywidgets.DOMWidget):
|
|
|
148
149
|
self.datasets = {}
|
|
149
150
|
#self.loaded_datasets.value = self.dataset_list[0]
|
|
150
151
|
self.dataset_list = []
|
|
151
|
-
self.datasets = open_file(self.file_name)
|
|
152
|
+
self.datasets = open_file(self.file_name, sum_frames=self.sum_frames)
|
|
152
153
|
self.dataset_list = []
|
|
153
154
|
for key in self.datasets.keys():
|
|
154
155
|
self.dataset_list.append(f'{key}: {self.datasets[key].title}')
|
|
@@ -593,7 +594,7 @@ def h5_group_to_dict(group, group_dict={}):
|
|
|
593
594
|
return group_dict
|
|
594
595
|
|
|
595
596
|
|
|
596
|
-
def open_file(filename=None, h5_group=None, write_hdf_file=False): # save_file=False,
|
|
597
|
+
def open_file(filename=None, h5_group=None, write_hdf_file=False, sum_frames=False): # save_file=False,
|
|
597
598
|
"""Opens a file if the extension is .hf5, .ndata, .dm3 or .dm4
|
|
598
599
|
|
|
599
600
|
If no filename is provided the QT open_file windows opens (if QT_available==True)
|
|
@@ -680,7 +681,7 @@ def open_file(filename=None, h5_group=None, write_hdf_file=False): # save_file
|
|
|
680
681
|
print('This file type needs hyperspy to be installed to be able to be read')
|
|
681
682
|
return
|
|
682
683
|
elif extension == '.emd':
|
|
683
|
-
reader = SciFiReaders.EMDReader(filename)
|
|
684
|
+
reader = SciFiReaders.EMDReader(filename, sum_frames=sum_frames)
|
|
684
685
|
|
|
685
686
|
elif 'edax' in extension.lower():
|
|
686
687
|
if 'h5' in extension:
|
pyTEMlib/image_tools.py
CHANGED
|
@@ -731,15 +731,27 @@ class LineSelector(matplotlib.widgets.PolygonSelector):
|
|
|
731
731
|
self.line_verts[moved_point] = self.new_point
|
|
732
732
|
self.set_linewidth()
|
|
733
733
|
|
|
734
|
-
def get_profile(dataset, line):
|
|
734
|
+
def get_profile(dataset, line, spline_order=-1):
|
|
735
|
+
"""
|
|
736
|
+
This function extracts a line profile from a given dataset. The line profile is a representation of the data values
|
|
737
|
+
along a specified line in the dataset. This function works for both image and spectral image data types.
|
|
738
|
+
|
|
739
|
+
Args:
|
|
740
|
+
dataset (sidpy.Dataset): The input dataset from which to extract the line profile.
|
|
741
|
+
line (list): A list specifying the line along which the profile should be extracted.
|
|
742
|
+
spline_order (int, optional): The order of the spline interpolation to use. Default is -1, which means no interpolation.
|
|
743
|
+
|
|
744
|
+
Returns:
|
|
745
|
+
profile_dataset (sidpy.Dataset): A new sidpy.Dataset containing the line profile.
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
"""
|
|
735
749
|
xv, yv = get_line_selection_points(line)
|
|
736
|
-
|
|
737
|
-
|
|
738
750
|
if dataset.data_type.name == 'IMAGE':
|
|
739
751
|
dataset.get_image_dims()
|
|
740
752
|
xv /= (dataset.x[1] - dataset.x[0])
|
|
741
753
|
yv /= (dataset.y[1] - dataset.y[0])
|
|
742
|
-
profile = scipy.ndimage.map_coordinates(np.array(dataset), [xv,yv])
|
|
754
|
+
profile = scipy.ndimage.map_coordinates(np.array(dataset), [xv, yv])
|
|
743
755
|
|
|
744
756
|
profile_dataset = sidpy.Dataset.from_array(profile.sum(axis=0))
|
|
745
757
|
profile_dataset.data_type='spectrum'
|
|
@@ -753,19 +765,21 @@ def get_profile(dataset, line):
|
|
|
753
765
|
|
|
754
766
|
if dataset.data_type.name == 'SPECTRAL_IMAGE':
|
|
755
767
|
spectral_axis = dataset.get_spectral_dims(return_axis=True)[0]
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
768
|
+
if spline_order > -1:
|
|
769
|
+
xv, yv, zv = get_line_selection_points_interpolated(line, z_length=dataset.shape[2])
|
|
770
|
+
profile = scipy.ndimage.map_coordinates(np.array(dataset), [xv, yv, zv], order=spline_order)
|
|
771
|
+
profile = profile.sum(axis=0)
|
|
772
|
+
profile = np.stack([profile, profile], axis=1)
|
|
773
|
+
start = xv[0, 0, 0]
|
|
774
|
+
else:
|
|
775
|
+
profile = get_line_profile(np.array(dataset), xv, yv, len(spectral_axis))
|
|
776
|
+
start = xv[0, 0]
|
|
777
|
+
print(profile.shape)
|
|
764
778
|
profile_dataset = sidpy.Dataset.from_array(profile)
|
|
765
779
|
profile_dataset.data_type='spectral_image'
|
|
766
780
|
profile_dataset.units = dataset.units
|
|
767
781
|
profile_dataset.quantity = dataset.quantity
|
|
768
|
-
profile_dataset.set_dimension(0, sidpy.Dimension(np.
|
|
782
|
+
profile_dataset.set_dimension(0, sidpy.Dimension(np.arange(profile_dataset.shape[0])+start,
|
|
769
783
|
name='x', units=dataset.x.units, quantity=dataset.x.quantity,
|
|
770
784
|
dimension_type='spatial'))
|
|
771
785
|
profile_dataset.set_dimension(1, sidpy.Dimension([0, 1],
|
|
@@ -776,6 +790,42 @@ def get_profile(dataset, line):
|
|
|
776
790
|
return profile_dataset
|
|
777
791
|
|
|
778
792
|
|
|
793
|
+
|
|
794
|
+
def get_line_selection_points_interpolated(line, z_length=1):
|
|
795
|
+
|
|
796
|
+
start_point = line.line_verts[3]
|
|
797
|
+
right_point = line.line_verts[0]
|
|
798
|
+
low_point = line.line_verts[2]
|
|
799
|
+
|
|
800
|
+
if start_point[0] > right_point[0]:
|
|
801
|
+
start_point = line.line_verts[0]
|
|
802
|
+
right_point = line.line_verts[3]
|
|
803
|
+
low_point = line.line_verts[1]
|
|
804
|
+
m = (right_point[1] - start_point[1]) / (right_point[0] - start_point[0])
|
|
805
|
+
length_x = int(abs(start_point[0]-right_point[0]))
|
|
806
|
+
length_v = int(np.linalg.norm(start_point-right_point))
|
|
807
|
+
|
|
808
|
+
linewidth = int(abs(start_point[1]-low_point[1]))
|
|
809
|
+
x = np.linspace(0,length_x, length_v)
|
|
810
|
+
y = np.linspace(0,linewidth, line.line_width)
|
|
811
|
+
if z_length > 1:
|
|
812
|
+
z = np.linspace(0, z_length, z_length)
|
|
813
|
+
xv, yv, zv = np.meshgrid(x, y, np.arange(z_length))
|
|
814
|
+
x = np.atleast_2d(x).repeat(z_length, axis=0).T
|
|
815
|
+
y = np.atleast_2d(y).repeat(z_length, axis=0).T
|
|
816
|
+
else:
|
|
817
|
+
xv, yv = np.meshgrid(x, y)
|
|
818
|
+
|
|
819
|
+
|
|
820
|
+
yv = yv + x*m + start_point[1]
|
|
821
|
+
xv = (xv.swapaxes(0,1) -y*m ).swapaxes(0,1) + start_point[0]
|
|
822
|
+
|
|
823
|
+
if z_length > 1:
|
|
824
|
+
return xv, yv, zv
|
|
825
|
+
else:
|
|
826
|
+
return xv, yv
|
|
827
|
+
|
|
828
|
+
|
|
779
829
|
def get_line_selection_points(line):
|
|
780
830
|
|
|
781
831
|
start_point = line.line_verts[3]
|
|
@@ -801,6 +851,16 @@ def get_line_selection_points(line):
|
|
|
801
851
|
return xx, yy
|
|
802
852
|
|
|
803
853
|
|
|
854
|
+
def get_line_profile(data, xv, yv, z_length):
|
|
855
|
+
profile = np.zeros([len(xv[0]), 2, z_length])
|
|
856
|
+
for index_x in range(xv.shape[1]):
|
|
857
|
+
for index_y in range(xv.shape[0]):
|
|
858
|
+
x = int(xv[index_y, index_x])
|
|
859
|
+
y = int(yv[index_y, index_x])
|
|
860
|
+
if x< data.shape[0] and x>0 and y < data.shape[1] and y>0:
|
|
861
|
+
profile[index_x, 0] +=data[x, y]
|
|
862
|
+
return profile
|
|
863
|
+
|
|
804
864
|
|
|
805
865
|
def histogram_plot(image_tags):
|
|
806
866
|
"""interactive histogram"""
|
pyTEMlib/version.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pyTEMlib
|
|
3
|
-
Version: 0.2024.2.
|
|
3
|
+
Version: 0.2024.2.2
|
|
4
4
|
Summary: pyTEM: TEM Data Quantification library through a model-based approach
|
|
5
5
|
Home-page: https://pycroscopy.github.io/pyTEMlib/about.html
|
|
6
6
|
Author: Gerd Duscher
|
|
@@ -24,6 +24,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
24
24
|
Classifier: Programming Language :: Python :: 3.11
|
|
25
25
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
26
26
|
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
27
|
+
License-File: LICENSE
|
|
27
28
|
Requires-Dist: scipy
|
|
28
29
|
Requires-Dist: numpy
|
|
29
30
|
Requires-Dist: pillow
|
|
@@ -51,7 +52,7 @@ pyTEMlib
|
|
|
51
52
|
.. image:: https://img.shields.io/pypi/v/pyTEMlib.svg
|
|
52
53
|
:target: https://pypi.org/project/pyTEMlib/
|
|
53
54
|
:alt: PyPI
|
|
54
|
-
|
|
55
|
+
|
|
55
56
|
.. image:: https://img.shields.io/conda/vn/conda-forge/pyTEMlib.svg
|
|
56
57
|
:target: https://github.com/conda-forge/pyTEMlib-feedstock
|
|
57
58
|
:alt: conda-forge
|
|
@@ -9,13 +9,13 @@ pyTEMlib/eds_tools.py,sha256=34YYoix9rhq0aYnZrHVi0A8gQeu9XZ9fGGT0VxPQo8Y,24882
|
|
|
9
9
|
pyTEMlib/eels_dialog.py,sha256=x5AOe2SjL4R8aR6X92HOWdC9mL0M-jKtSiNfR-SHQr8,32327
|
|
10
10
|
pyTEMlib/eels_dialog_utilities.py,sha256=srkRvRDUWIzN38EWNGRWimsJLK4YXSnGEfL6Dd1V3IY,51778
|
|
11
11
|
pyTEMlib/eels_tools.py,sha256=pzsiMY-1ZXth5ZIrPaRNOs6R3gMAyZr8TVYf-Lxnn5Y,77781
|
|
12
|
-
pyTEMlib/file_tools.py,sha256=
|
|
12
|
+
pyTEMlib/file_tools.py,sha256=XbtKLWEK-zam4A4u5iS4lFhNw51Vcm8Syoa_133hFyo,46495
|
|
13
13
|
pyTEMlib/file_tools_qt.py,sha256=tLZACS4JyGH_AOzNR_SGAhjA01y4VJB261opPhGMlm8,7223
|
|
14
14
|
pyTEMlib/graph_tools.py,sha256=iu0Y2hIPU6CkQHQEh-dI1vKnUHnSNXx4-CXs2M-1Sr8,44097
|
|
15
15
|
pyTEMlib/graph_viz.py,sha256=m5PwSn6l2r0bsaLWBDSHc9IGR3_PneG2BrZgnEdi07I,13644
|
|
16
16
|
pyTEMlib/image_dialog.py,sha256=F-ZgKq7UnMtPPd1b9eqb7t8MXDfWN-8hVKwB2Il0x28,6235
|
|
17
17
|
pyTEMlib/image_dlg.py,sha256=n5gradDiYOFGEQ3k_Wlk9RUYYzl4bl_hKLzNVcYteNE,5694
|
|
18
|
-
pyTEMlib/image_tools.py,sha256=
|
|
18
|
+
pyTEMlib/image_tools.py,sha256=Z1ZClIl0nqqPbehJzpLeWd0C_-dMCgzegPFIiNjJDNM,45665
|
|
19
19
|
pyTEMlib/info_widget.py,sha256=G8MArXYI_xdvRY3cD7-3UxUjczEUWPjlrGJOj2BKU2Y,49903
|
|
20
20
|
pyTEMlib/interactive_image.py,sha256=5PwypcA1OjLAD-fi8bmWWFHuOjdIPVY9Dh59V24WuDA,34
|
|
21
21
|
pyTEMlib/kinematic_scattering.py,sha256=CUdJnclkok7d8qm_jDUF92MVHrmaTeMkKdvxxB6AqvA,43309
|
|
@@ -25,11 +25,11 @@ pyTEMlib/peak_dlg.py,sha256=qcjcnhwpGa4jBCeXzwQz9sCyX-tHsLLQ67ToqfKOiQY,11550
|
|
|
25
25
|
pyTEMlib/probe_tools.py,sha256=8tPQuANClLsGAKnZo6Vo4gNIGKfyDR6WUMO3dXcm_4k,27177
|
|
26
26
|
pyTEMlib/sidpy_tools.py,sha256=0oIx-qMtEmcZmLazQKW19dd-KoxyY3B15aIeMcyHA8E,4878
|
|
27
27
|
pyTEMlib/simulation_tools.py,sha256=RmegD5TpQMU68uASvzZWVplAqs7bM5KkF6bWDWLjyc0,2799
|
|
28
|
-
pyTEMlib/version.py,sha256=
|
|
28
|
+
pyTEMlib/version.py,sha256=_bRzJnpABIwsBmU7vcbAzkVQOcrs4FDhOj7NU--rmwI,94
|
|
29
29
|
pyTEMlib/xrpa_x_sections.py,sha256=peb2pozcH0T-3zlWITx-5rdyeoP2YhOfBpwsWD1-4T4,1813751
|
|
30
|
-
pyTEMlib-0.2024.2.
|
|
31
|
-
pyTEMlib-0.2024.2.
|
|
32
|
-
pyTEMlib-0.2024.2.
|
|
33
|
-
pyTEMlib-0.2024.2.
|
|
34
|
-
pyTEMlib-0.2024.2.
|
|
35
|
-
pyTEMlib-0.2024.2.
|
|
30
|
+
pyTEMlib-0.2024.2.2.dist-info/LICENSE,sha256=7HdBF6SXIBd38bHOKkQd4DYR1KV-OYm9mwB16fM-984,1062
|
|
31
|
+
pyTEMlib-0.2024.2.2.dist-info/METADATA,sha256=ysRSA7XOwpB9J7hwnDBzAHaD1GxOpCCyUQFqe0yGkFM,3306
|
|
32
|
+
pyTEMlib-0.2024.2.2.dist-info/WHEEL,sha256=-G_t0oGuE7UD0DrSpVZnq1hHMBV9DD2XkS5v7XpmTnk,110
|
|
33
|
+
pyTEMlib-0.2024.2.2.dist-info/entry_points.txt,sha256=qiIFPP3ffSz-gxj-TowzbA0Setq5Lo0RJTVtSrqD1IY,44
|
|
34
|
+
pyTEMlib-0.2024.2.2.dist-info/top_level.txt,sha256=rPLVH0UJxrPSPgSoKScTjL1K_X69JFzsYYnDnYTYIlU,9
|
|
35
|
+
pyTEMlib-0.2024.2.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|