pyTEMlib 0.2024.2.1__tar.gz → 0.2024.2.2__tar.gz

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 (42) hide show
  1. {pyTEMlib-0.2024.2.1/pyTEMlib.egg-info → pyTEMlib-0.2024.2.2}/PKG-INFO +1 -1
  2. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib/file_tools.py +5 -4
  3. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib/image_tools.py +73 -13
  4. pyTEMlib-0.2024.2.2/pyTEMlib/version.py +6 -0
  5. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2/pyTEMlib.egg-info}/PKG-INFO +1 -1
  6. pyTEMlib-0.2024.2.1/pyTEMlib/version.py +0 -6
  7. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/LICENSE +0 -0
  8. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/MANIFEST.in +0 -0
  9. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/README.rst +0 -0
  10. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib/__init__.py +0 -0
  11. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib/animation.py +0 -0
  12. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib/atom_tools.py +0 -0
  13. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib/config_dir.py +0 -0
  14. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib/crystal_tools.py +0 -0
  15. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib/diffraction_plot.py +0 -0
  16. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib/dynamic_scattering.py +0 -0
  17. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib/eds_tools.py +0 -0
  18. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib/eels_dialog.py +0 -0
  19. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib/eels_dialog_utilities.py +0 -0
  20. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib/eels_tools.py +0 -0
  21. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib/file_tools_qt.py +0 -0
  22. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib/graph_tools.py +0 -0
  23. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib/graph_viz.py +0 -0
  24. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib/image_dialog.py +0 -0
  25. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib/image_dlg.py +0 -0
  26. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib/info_widget.py +0 -0
  27. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib/interactive_image.py +0 -0
  28. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib/kinematic_scattering.py +0 -0
  29. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib/microscope.py +0 -0
  30. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib/peak_dialog.py +0 -0
  31. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib/peak_dlg.py +0 -0
  32. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib/probe_tools.py +0 -0
  33. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib/sidpy_tools.py +0 -0
  34. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib/simulation_tools.py +0 -0
  35. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib/xrpa_x_sections.py +0 -0
  36. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib.egg-info/SOURCES.txt +0 -0
  37. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib.egg-info/dependency_links.txt +0 -0
  38. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib.egg-info/entry_points.txt +0 -0
  39. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib.egg-info/requires.txt +0 -0
  40. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/pyTEMlib.egg-info/top_level.txt +0 -0
  41. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/setup.cfg +0 -0
  42. {pyTEMlib-0.2024.2.1 → pyTEMlib-0.2024.2.2}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyTEMlib
3
- Version: 0.2024.2.1
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
@@ -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:
@@ -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
- profile = np.zeros([xv.shape[1], 2, len(spectral_axis)])
757
- data =np.array(dataset)
758
-
759
- for index_x in range(xv.shape[1]):
760
- for index_y in range(xv.shape[0]):
761
- x = xv[index_y, index_x]
762
- y = yv[index_y, index_x]
763
- profile[index_x, 0] +=data[int(x),int(y)]
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.linspace(xv[0,0], xv[-1,-1], profile_dataset.shape[0]),
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"""
@@ -0,0 +1,6 @@
1
+ """
2
+ version
3
+ """
4
+ _version = '0.2024.02.2'
5
+ __version__ = _version
6
+ _time = '2024-02-26 19:58:26'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyTEMlib
3
- Version: 0.2024.2.1
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
@@ -1,6 +0,0 @@
1
- """
2
- version
3
- """
4
- _version = '0.2024.02.1'
5
- __version__ = _version
6
- _time = '2024-02-18 19:58:26'
File without changes
File without changes
File without changes
File without changes
File without changes