nxs-analysis-tools 0.0.16__tar.gz → 0.0.18__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 nxs-analysis-tools might be problematic. Click here for more details.

Files changed (17) hide show
  1. {nxs-analysis-tools-0.0.16/src/nxs_analysis_tools.egg-info → nxs-analysis-tools-0.0.18}/PKG-INFO +1 -1
  2. {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/pyproject.toml +1 -1
  3. {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/src/_meta/__init__.py +1 -1
  4. {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/src/nxs_analysis_tools/chess.py +65 -20
  5. {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/src/nxs_analysis_tools/datareduction.py +14 -4
  6. {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18/src/nxs_analysis_tools.egg-info}/PKG-INFO +1 -1
  7. {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/LICENSE +0 -0
  8. {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/MANIFEST.in +0 -0
  9. {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/README.md +0 -0
  10. {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/setup.cfg +0 -0
  11. {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/setup.py +0 -0
  12. {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/src/nxs_analysis_tools/__init__.py +0 -0
  13. {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/src/nxs_analysis_tools/pairdistribution.py +0 -0
  14. {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/src/nxs_analysis_tools.egg-info/SOURCES.txt +0 -0
  15. {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/src/nxs_analysis_tools.egg-info/dependency_links.txt +0 -0
  16. {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/src/nxs_analysis_tools.egg-info/requires.txt +0 -0
  17. {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/src/nxs_analysis_tools.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nxs-analysis-tools
3
- Version: 0.0.16
3
+ Version: 0.0.18
4
4
  Summary: Reduce and transform nexus format (.nxs) scattering data.
5
5
  Author-email: "Steven J. Gomez Alvarado" <stevenjgomez@ucsb.edu>
6
6
  License: MIT License
@@ -6,7 +6,7 @@ build-backend = 'setuptools.build_meta'
6
6
 
7
7
  [project]
8
8
  name = 'nxs-analysis-tools'
9
- version = '0.0.16'
9
+ version = '0.0.18'
10
10
  description = 'Reduce and transform nexus format (.nxs) scattering data.'
11
11
  readme = 'README.md'
12
12
  requires-python = '>=3.7'
@@ -6,5 +6,5 @@ __author__ = 'Steven J. Gomez Alvarado'
6
6
  __email__ = 'stevenjgomez@ucsb.edu'
7
7
  __copyright__ = f"2023, {__author__}"
8
8
  __license__ = 'MIT'
9
- __version__= '0.0.16'
9
+ __version__= '0.0.18'
10
10
  __repo_url__ = 'https://github.com/stevenjgomez/nxs_analysis_tools'
@@ -4,7 +4,6 @@ This module provides classes and functions for analyzing scattering datasets col
4
4
  plotting linecuts.
5
5
  '''
6
6
  import os
7
- from nexusformat.nexus import NXentry
8
7
  import matplotlib.pyplot as plt
9
8
  import matplotlib as mpl
10
9
 
@@ -19,7 +18,7 @@ class TempDependence():
19
18
  '''
20
19
  Initialize TempDependence class.
21
20
  '''
22
- self.datasets=NXentry()
21
+ self.datasets={}
23
22
  self.folder=None
24
23
  self.temperatures=None
25
24
  self.scissors=None
@@ -40,7 +39,7 @@ class TempDependence():
40
39
  '''
41
40
  Clear the datasets stored in the TempDependence instance.
42
41
  '''
43
- self.datasets=NXentry()
42
+ self.datasets={}
44
43
 
45
44
  def load_datasets(self, folder, file_ending='hkli.nxs', temperatures_list=None):
46
45
  '''
@@ -51,13 +50,12 @@ class TempDependence():
51
50
  folder : str
52
51
  The path to the folder where the datasets are located.
53
52
  file_ending : str, optional
54
- The file ending of the datasets to be loaded. The default is 'hkli.nxs'.
53
+ The file extension of the datasets to be loaded. The default is 'hkli.nxs'.
55
54
  temperatures_list : list of int or None, optional
56
55
  The list of specific temperatures to load. If None, all available temperatures are
57
56
  loaded. The default is None.
58
57
  '''
59
- self.folder = os.path.normpath(folder)
60
-
58
+ self.folder=os.path.normpath(folder)
61
59
  temperature_folders=[] # Empty list to store temperature folder names
62
60
  for item in os.listdir(self.folder):
63
61
  try:
@@ -68,28 +66,54 @@ class TempDependence():
68
66
  temperature_folders = [str(i) for i in temperature_folders] # Convert to strings
69
67
 
70
68
  print('Found temperature folders:')
71
- [print('['+str(i)+'] '+folder for i,folder in temperature_folders)]
69
+ [print('['+str(i)+'] '+folder) for i,folder in enumerate(temperature_folders)]
72
70
 
73
71
  self.temperatures = temperature_folders
74
72
 
75
73
  if temperatures_list is not None:
76
- temperature_folders = [str(t) for t in temperatures_list]
77
- else:
78
- temperature_folders = self.temperatures
79
-
80
- self.temperatures = temperature_folders
74
+ self.temperatures = [str(t) for t in temperatures_list]
81
75
 
82
76
  # Load .nxs files
83
- for temperature in temperature_folders:
84
- for file in os.listdir(os.path.join(self.folder,temperature)):
77
+ for temperature in self.temperatures:
78
+ for file in os.listdir(os.path.join(self.folder, temperature)):
85
79
  if file.endswith(file_ending):
86
- filepath = os.path.join(self.folder,temperature, file)
80
+ filepath = os.path.join(self.folder, temperature, file)
87
81
  print('-----------------------------------------------')
88
82
  print('Loading ' + temperature + ' K indexed .nxs files...')
89
83
  print('Found ' + filepath)
90
84
  self.datasets[temperature] = load_data(filepath)
91
85
 
92
- def cut_data(self, center, window, axis=None):
86
+ self.scissors = [Scissors() for _ in range(len(self.datasets))]
87
+
88
+ for i,dataset in enumerate(self.datasets.values()):
89
+ self.scissors[i].set_data(dataset)
90
+
91
+ def set_window(self, window):
92
+ '''
93
+ Set the extents of the integration window.
94
+
95
+ Parameters
96
+ ----------
97
+ window : tuple
98
+ Extents of the window for integration along each axis.
99
+ '''
100
+ for i,scissors in enumerate(self.scissors):
101
+ print("----------------------------------")
102
+ print("T = " + self.temperatures[i] + " K")
103
+ scissors.set_window(window)
104
+
105
+ def set_center(self, center):
106
+ '''
107
+ Set the central coordinate for the linecut.
108
+
109
+ Parameters
110
+ ----------
111
+ center : tuple
112
+ Central coordinate around which to perform the linecut.
113
+ '''
114
+ [scissors.set_center(center) for scissors in self.scissors]
115
+
116
+ def cut_data(self, center=None, window=None, axis=None):
93
117
  '''
94
118
  Perform data cutting for each temperature dataset.
95
119
 
@@ -108,11 +132,13 @@ class TempDependence():
108
132
  list
109
133
  A list of linecuts obtained from the cutting operation.
110
134
  '''
111
- self.scissors = [Scissors() for _ in range(len(self.temperatures))]
135
+
136
+ center = center if center is not None else self.scissors[0].center
137
+ window = window if window is not None else self.scissors[0].window
138
+
112
139
  for i,T in enumerate(self.temperatures):
113
140
  print("-------------------------------")
114
141
  print("Cutting T = " + T + " K data...")
115
- self.scissors[i].set_data(self.datasets[T])
116
142
  self.scissors[i].cut_data(center, window, axis)
117
143
 
118
144
  self.linecuts = [scissors.linecut for scissors in self.scissors]
@@ -137,7 +163,7 @@ class TempDependence():
137
163
  for i, linecut in enumerate(self.linecuts):
138
164
  x_data = linecut[linecut.axes[0]].nxdata
139
165
  y_data = linecut[linecut.signal].nxdata + i*vertical_offset
140
- ax.plot(x_data, y_data, color=cmap(i / len(self.linecuts)), label=linecut.nxname,
166
+ ax.plot(x_data, y_data, color=cmap(i / len(self.linecuts)), label=self.temperatures[i],
141
167
  **kwargs)
142
168
 
143
169
  xlabel_components = [self.linecuts[0].axes[0] if i == self.scissors[0].axis \
@@ -155,4 +181,23 @@ class TempDependence():
155
181
 
156
182
  # Create a new legend with reversed order
157
183
  plt.legend(handles, labels)
158
- plt.show()
184
+
185
+ return fig,ax
186
+
187
+ def show_integration_window(self, temperature=None):
188
+ '''
189
+ Displays the integration window plot for a specific temperature or for all temperatures if
190
+ none is provided.
191
+
192
+ Parameters
193
+ ----------
194
+ temperature : str, optional
195
+ The temperature at which to display the integration window plot. If provided, the plot
196
+ will be generated using the dataset corresponding to the specified temperature. If not
197
+ provided, the integration window plots will be generated for all available
198
+ temperatures.
199
+ '''
200
+ if temperature is not None:
201
+ self.scissors[0].show_integration_window(data=self.datasets[temperature])
202
+ else:
203
+ self.scissors[0].show_integration_window(data=self.datasets[self.temperatures[0]])
@@ -354,7 +354,7 @@ class Scissors():
354
354
 
355
355
  Parameters
356
356
  ----------
357
- center : tuple or None
357
+ center : tuple
358
358
  Central coordinate around which to perform the linecut.
359
359
  '''
360
360
  self.center = center
@@ -365,7 +365,7 @@ class Scissors():
365
365
 
366
366
  Parameters
367
367
  ----------
368
- window : tuple or None
368
+ window : tuple
369
369
  Extents of the window for integration along each axis.
370
370
  '''
371
371
  self.window = window
@@ -444,11 +444,21 @@ class Scissors():
444
444
 
445
445
  return self.linecut
446
446
 
447
- def show_integration_window(self, label=None, **kwargs):
447
+ def show_integration_window(self, data=None, label=None, **kwargs):
448
448
  '''
449
449
  Plots integration window highlighted on 2D heatmap full dataset.
450
+
451
+ Parameters
452
+ ----------
453
+ data : array-like, optional
454
+ The 2D heatmap dataset to plot. If not provided, the dataset stored in `self.data` will be used.
455
+ label : str, optional
456
+ The label for the integration window plot.
457
+ **kwargs : keyword arguments, optional
458
+ Additional keyword arguments to customize the plot.
459
+
450
460
  '''
451
- data = self.data
461
+ data = self.data if data is None else data
452
462
  axis = self.axis
453
463
  center = self.center
454
464
  window = self.window
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nxs-analysis-tools
3
- Version: 0.0.16
3
+ Version: 0.0.18
4
4
  Summary: Reduce and transform nexus format (.nxs) scattering data.
5
5
  Author-email: "Steven J. Gomez Alvarado" <stevenjgomez@ucsb.edu>
6
6
  License: MIT License