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.
- {nxs-analysis-tools-0.0.16/src/nxs_analysis_tools.egg-info → nxs-analysis-tools-0.0.18}/PKG-INFO +1 -1
- {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/pyproject.toml +1 -1
- {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/src/_meta/__init__.py +1 -1
- {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/src/nxs_analysis_tools/chess.py +65 -20
- {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/src/nxs_analysis_tools/datareduction.py +14 -4
- {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18/src/nxs_analysis_tools.egg-info}/PKG-INFO +1 -1
- {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/LICENSE +0 -0
- {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/MANIFEST.in +0 -0
- {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/README.md +0 -0
- {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/setup.cfg +0 -0
- {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/setup.py +0 -0
- {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/src/nxs_analysis_tools/__init__.py +0 -0
- {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/src/nxs_analysis_tools/pairdistribution.py +0 -0
- {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/src/nxs_analysis_tools.egg-info/SOURCES.txt +0 -0
- {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/src/nxs_analysis_tools.egg-info/dependency_links.txt +0 -0
- {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/src/nxs_analysis_tools.egg-info/requires.txt +0 -0
- {nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/src/nxs_analysis_tools.egg-info/top_level.txt +0 -0
|
@@ -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=
|
|
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=
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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=
|
|
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
|
-
|
|
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]])
|
{nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/src/nxs_analysis_tools/datareduction.py
RENAMED
|
@@ -354,7 +354,7 @@ class Scissors():
|
|
|
354
354
|
|
|
355
355
|
Parameters
|
|
356
356
|
----------
|
|
357
|
-
center : tuple
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/src/nxs_analysis_tools/pairdistribution.py
RENAMED
|
File without changes
|
{nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/src/nxs_analysis_tools.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{nxs-analysis-tools-0.0.16 → nxs-analysis-tools-0.0.18}/src/nxs_analysis_tools.egg-info/requires.txt
RENAMED
|
File without changes
|
|
File without changes
|