nxs-analysis-tools 0.0.19__tar.gz → 0.0.20__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 (21) hide show
  1. {nxs-analysis-tools-0.0.19/src/nxs_analysis_tools.egg-info → nxs-analysis-tools-0.0.20}/PKG-INFO +1 -1
  2. {nxs-analysis-tools-0.0.19 → nxs-analysis-tools-0.0.20}/pyproject.toml +1 -1
  3. {nxs-analysis-tools-0.0.19 → nxs-analysis-tools-0.0.20}/src/_meta/__init__.py +2 -2
  4. {nxs-analysis-tools-0.0.19 → nxs-analysis-tools-0.0.20}/src/nxs_analysis_tools/chess.py +69 -36
  5. {nxs-analysis-tools-0.0.19 → nxs-analysis-tools-0.0.20}/src/nxs_analysis_tools/datareduction.py +112 -111
  6. nxs-analysis-tools-0.0.20/src/nxs_analysis_tools/pairdistribution.py +438 -0
  7. {nxs-analysis-tools-0.0.19 → nxs-analysis-tools-0.0.20/src/nxs_analysis_tools.egg-info}/PKG-INFO +1 -1
  8. {nxs-analysis-tools-0.0.19 → nxs-analysis-tools-0.0.20}/src/nxs_analysis_tools.egg-info/SOURCES.txt +3 -1
  9. nxs-analysis-tools-0.0.20/tests/test_chess.py +16 -0
  10. {nxs-analysis-tools-0.0.19 → nxs-analysis-tools-0.0.20}/tests/test_datareduction.py +3 -3
  11. nxs-analysis-tools-0.0.20/tests/test_pairdistribution.py +19 -0
  12. nxs-analysis-tools-0.0.19/src/nxs_analysis_tools/pairdistribution.py +0 -80
  13. {nxs-analysis-tools-0.0.19 → nxs-analysis-tools-0.0.20}/LICENSE +0 -0
  14. {nxs-analysis-tools-0.0.19 → nxs-analysis-tools-0.0.20}/MANIFEST.in +0 -0
  15. {nxs-analysis-tools-0.0.19 → nxs-analysis-tools-0.0.20}/README.md +0 -0
  16. {nxs-analysis-tools-0.0.19 → nxs-analysis-tools-0.0.20}/setup.cfg +0 -0
  17. {nxs-analysis-tools-0.0.19 → nxs-analysis-tools-0.0.20}/setup.py +0 -0
  18. {nxs-analysis-tools-0.0.19 → nxs-analysis-tools-0.0.20}/src/nxs_analysis_tools/__init__.py +0 -0
  19. {nxs-analysis-tools-0.0.19 → nxs-analysis-tools-0.0.20}/src/nxs_analysis_tools.egg-info/dependency_links.txt +0 -0
  20. {nxs-analysis-tools-0.0.19 → nxs-analysis-tools-0.0.20}/src/nxs_analysis_tools.egg-info/requires.txt +0 -0
  21. {nxs-analysis-tools-0.0.19 → nxs-analysis-tools-0.0.20}/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.19
3
+ Version: 0.0.20
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.19'
9
+ version = '0.0.20'
10
10
  description = 'Reduce and transform nexus format (.nxs) scattering data.'
11
11
  readme = 'README.md'
12
12
  requires-python = '>=3.7'
@@ -1,4 +1,4 @@
1
- '''MagentroPy package metadata.'''
1
+ '''nxs-analysis-tools package metadata.'''
2
2
 
3
3
  # keep consistent with pyproject.toml
4
4
  __project__ = 'nxs-analysis-tools'
@@ -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.19'
9
+ __version__= '0.0.20'
10
10
  __repo_url__ = 'https://github.com/stevenjgomez/nxs_analysis_tools'
@@ -4,6 +4,7 @@ This module provides classes and functions for analyzing scattering datasets col
4
4
  plotting linecuts.
5
5
  '''
6
6
  import os
7
+
7
8
  import matplotlib.pyplot as plt
8
9
  import matplotlib as mpl
9
10
 
@@ -14,6 +15,7 @@ class TempDependence():
14
15
  '''
15
16
  Class for analyzing scattering datasets collected at CHESS (ID4B) with temperature dependence.
16
17
  '''
18
+
17
19
  def __init__(self):
18
20
  '''
19
21
  Initialize TempDependence class.
@@ -21,8 +23,8 @@ class TempDependence():
21
23
  self.datasets={}
22
24
  self.folder=None
23
25
  self.temperatures=None
24
- self.scissors=None
25
- self.linecuts=None
26
+ self.scissors= {}
27
+ self.linecuts={}
26
28
 
27
29
  def get_folder(self):
28
30
  '''
@@ -81,40 +83,42 @@ class TempDependence():
81
83
  print('-----------------------------------------------')
82
84
  print('Loading ' + temperature + ' K indexed .nxs files...')
83
85
  print('Found ' + filepath)
84
- self.datasets[temperature] = load_data(filepath)
85
86
 
86
- self.scissors = [Scissors() for _ in range(len(self.datasets))]
87
+ # Load dataset at each temperature
88
+ self.datasets[temperature] = load_data(filepath)
87
89
 
88
- for i,dataset in enumerate(self.datasets.values()):
89
- self.scissors[i].set_data(dataset)
90
+ # Initialize scissors object at each temperature
91
+ self.scissors[temperature] = Scissors()
92
+ self.scissors[temperature].set_data(self.datasets[temperature])
90
93
 
91
94
  def set_window(self, window):
92
- '''
95
+ """
93
96
  Set the extents of the integration window.
94
97
 
95
98
  Parameters
96
99
  ----------
97
100
  window : tuple
98
101
  Extents of the window for integration along each axis.
99
- '''
100
- for i,scissors in enumerate(self.scissors):
102
+ """
103
+ for T in self.temperatures:
101
104
  print("----------------------------------")
102
- print("T = " + self.temperatures[i] + " K")
103
- scissors.set_window(window)
105
+ print("T = " + T + " K")
106
+ self.scissors[T].set_window(window)
104
107
 
105
108
  def set_center(self, center):
106
- '''
109
+ """
107
110
  Set the central coordinate for the linecut.
108
111
 
109
112
  Parameters
110
113
  ----------
111
114
  center : tuple
112
115
  Central coordinate around which to perform the linecut.
113
- '''
114
- [scissors.set_center(center) for scissors in self.scissors]
116
+ """
117
+ for T in self.temperatures:
118
+ self.scissors[T].set_center(center)
115
119
 
116
120
  def cut_data(self, center=None, window=None, axis=None):
117
- '''
121
+ """
118
122
  Perform data cutting for each temperature dataset.
119
123
 
120
124
  Parameters
@@ -131,21 +135,20 @@ class TempDependence():
131
135
  -------
132
136
  list
133
137
  A list of linecuts obtained from the cutting operation.
134
- '''
138
+ """
135
139
 
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
140
+ center = center if center is not None else self.scissors[self.temperatures[0]].center
141
+ window = window if window is not None else self.scissors[self.temperatures[0]].window
138
142
 
139
- for i,T in enumerate(self.temperatures):
143
+ for T in self.temperatures:
140
144
  print("-------------------------------")
141
145
  print("Cutting T = " + T + " K data...")
142
- self.scissors[i].cut_data(center, window, axis)
143
-
144
- self.linecuts = [scissors.linecut for scissors in self.scissors]
146
+ self.scissors[T].cut_data(center, window, axis)
147
+ self.linecuts[T] = self.scissors[T].linecut
145
148
  return self.linecuts
146
149
 
147
150
  def plot_linecuts(self, vertical_offset=0, **kwargs):
148
- '''
151
+ """
149
152
  Plot the linecuts obtained from data cutting.
150
153
 
151
154
  Parameters
@@ -154,23 +157,24 @@ class TempDependence():
154
157
  The vertical offset between linecuts on the plot. The default is 0.
155
158
  **kwargs
156
159
  Additional keyword arguments to be passed to the plot function.
157
- '''
160
+ """
158
161
  fig, ax = plt.subplots()
159
162
 
160
163
  # Get the Viridis colormap
161
164
  cmap = mpl.colormaps.get_cmap('viridis')
162
165
 
163
- for i, linecut in enumerate(self.linecuts):
166
+ for i, linecut in enumerate(self.linecuts.values()):
164
167
  x_data = linecut[linecut.axes[0]].nxdata
165
168
  y_data = linecut[linecut.signal].nxdata + i*vertical_offset
166
169
  ax.plot(x_data, y_data, color=cmap(i / len(self.linecuts)), label=self.temperatures[i],
167
170
  **kwargs)
168
171
 
169
- xlabel_components = [self.linecuts[0].axes[0] if i == self.scissors[0].axis \
170
- else str(c) for i,c in enumerate(self.scissors[0].center)]
172
+ xlabel_components = [self.linecuts[self.temperatures[0]].axes[0]
173
+ if i == self.scissors[self.temperatures[0]].axis \
174
+ else str(c) for i,c in enumerate(self.scissors[self.temperatures[0]].center)]
171
175
  xlabel = ' '.join(xlabel_components)
172
176
  ax.set(xlabel=xlabel,
173
- ylabel=self.linecuts[0].signal)
177
+ ylabel=self.linecuts[self.temperatures[0]].signal)
174
178
 
175
179
  # Get the current legend handles and labels
176
180
  handles, labels = plt.gca().get_legend_handles_labels()
@@ -184,9 +188,9 @@ class TempDependence():
184
188
 
185
189
  return fig,ax
186
190
 
187
- def highlight_integration_window(self, temperature=None):
188
- '''
189
- Displays the integration window plot for a specific temperature or for all temperatures if
191
+ def highlight_integration_window(self, temperature=None, **kwargs):
192
+ """
193
+ Displays the integration window plot for a specific temperature, or for the first temperature if
190
194
  none is provided.
191
195
 
192
196
  Parameters
@@ -194,10 +198,39 @@ class TempDependence():
194
198
  temperature : str, optional
195
199
  The temperature at which to display the integration window plot. If provided, the plot
196
200
  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
- '''
201
+ provided, the integration window plots will be generated for the first temperature.
202
+ **kwargs : keyword arguments, optional
203
+ Additional keyword arguments to customize the plot.
204
+ """
205
+
200
206
  if temperature is not None:
201
- self.scissors[0].highlight_integration_window(data=self.datasets[temperature])
207
+ p = self.scissors[self.temperatures[0]].highlight_integration_window(data=self.datasets[temperature],
208
+ **kwargs)
202
209
  else:
203
- self.scissors[0].highlight_integration_window(data=self.datasets[self.temperatures[0]])
210
+ p = self.scissors[self.temperatures[0]].highlight_integration_window(
211
+ data=self.datasets[self.temperatures[0]], **kwargs
212
+ )
213
+
214
+ return p
215
+
216
+ def plot_integration_window(self, temperature=None, **kwargs):
217
+ """
218
+ Plots the three principal cross-sections of the integration volume on a single figure for a specific
219
+ temperature, or for the first temperature if none is provided.
220
+
221
+ Parameters
222
+ ----------
223
+ temperature : str, optional
224
+ The temperature at which to plot the integration volume. If provided, the plot
225
+ will be generated using the dataset corresponding to the specified temperature. If not
226
+ provided, the integration window plots will be generated for the first temperature.
227
+ **kwargs : keyword arguments, optional
228
+ Additional keyword arguments to customize the plot.
229
+ """
230
+
231
+ if temperature is not None:
232
+ p = self.scissors[self.temperatures[0]].plot_integration_window(**kwargs)
233
+ else:
234
+ p = self.scissors[self.temperatures[0]].plot_integration_window(**kwargs)
235
+
236
+ return p