nxs-analysis-tools 0.0.43__py3-none-any.whl → 0.0.45__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 nxs-analysis-tools might be problematic. Click here for more details.

_meta/__init__.py CHANGED
@@ -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.43'
9
+ __version__ = '0.0.45'
10
10
  __repo_url__ = 'https://github.com/stevenjgomez/nxs_analysis_tools'
@@ -50,6 +50,8 @@ class TempDependence:
50
50
  -------
51
51
  set_temperatures(temperatures):
52
52
  Set the list of temperatures for the datasets.
53
+ find_temperatures():
54
+ Set the list of temperatures by automatically scanning the sample directory.
53
55
  set_sample_directory(path):
54
56
  Set the directory path where the datasets are located.
55
57
  initialize():
@@ -105,7 +107,7 @@ class TempDependence:
105
107
  Initialize the TempDependence class with default values.
106
108
  """
107
109
 
108
- self.sample_directory = ''
110
+ self.sample_directory = None
109
111
  self.xlabel = ''
110
112
  self.datasets = {}
111
113
  self.temperatures = []
@@ -127,6 +129,31 @@ class TempDependence:
127
129
  """
128
130
  self.temperatures = temperatures
129
131
 
132
+ def find_temperatures(self):
133
+ """
134
+ Set the list of temperatures by automatically scanning the sample directory.
135
+ """
136
+
137
+ # Assert that self.sample_directory must exist
138
+ if self.sample_directory is None:
139
+ raise ValueError("Sample directory is not set. Use set_sample_directory(path) first.")
140
+
141
+ # Clear existing temperatures
142
+ self.temperatures = []
143
+
144
+ # Search for nxrefine .nxs files
145
+ for item in os.listdir(self.sample_directory):
146
+ pattern = r'_(\d+)\.nxs'
147
+ match = re.search(pattern, item)
148
+ if match:
149
+ # Identify temperature
150
+ temperature = match.group(1)
151
+ self.temperatures.append(temperature)
152
+ # Convert all temperatures to int temporarily to sort temperatures list
153
+ self.temperatures = [int(t) for t in self.temperatures]
154
+ self.temperatures.sort()
155
+ self.temperatures = [str(t) for t in self.temperatures]
156
+
130
157
  def set_sample_directory(self, path):
131
158
  """
132
159
  Set the directory path where the datasets are located.
@@ -172,6 +199,9 @@ class TempDependence:
172
199
  if temperatures_list:
173
200
  temperatures_list = [str(t) for t in temperatures_list]
174
201
 
202
+ # Clear existing temperatures before loading files
203
+ self.temperatures = []
204
+
175
205
  # Identify files to load
176
206
  items_to_load = []
177
207
  # Search for nxrefine .nxs files
@@ -179,7 +209,6 @@ class TempDependence:
179
209
  pattern = r'_(\d+)\.nxs'
180
210
  match = re.search(pattern, item)
181
211
  if match:
182
- print(f'Found {item}')
183
212
  # Identify temperature
184
213
  temperature = match.group(1)
185
214
  # print(f'Temperature = {temperature}')
@@ -188,7 +217,6 @@ class TempDependence:
188
217
  self.temperatures.append(temperature)
189
218
  items_to_load.append(item)
190
219
  # print(f'Preparing to load {temperature} K data: {item}')
191
-
192
220
  # Convert all temperatures to int temporarily to sort temperatures list before loading
193
221
  self.temperatures = [int(t) for t in self.temperatures]
194
222
 
@@ -238,9 +266,6 @@ class TempDependence:
238
266
  temperature_folders.sort() # Sort from low to high T
239
267
  temperature_folders = [str(i) for i in temperature_folders] # Convert to strings
240
268
 
241
- print('Found temperature folders:')
242
- [print('[' + str(i) + '] ' + folder) for i, folder in enumerate(temperature_folders)]
243
-
244
269
  self.temperatures = temperature_folders
245
270
 
246
271
  if temperatures_list is not None:
@@ -251,9 +276,6 @@ class TempDependence:
251
276
  for file in os.listdir(os.path.join(self.sample_directory, T)):
252
277
  if file.endswith(file_ending):
253
278
  filepath = os.path.join(self.sample_directory, T, file)
254
- print('-----------------------------------------------')
255
- print('Loading ' + T + ' K indexed .nxs files...')
256
- print('Found ' + filepath)
257
279
 
258
280
  # Load dataset at each temperature
259
281
  self.datasets[T] = load_data(filepath)
@@ -15,7 +15,7 @@ from scipy import ndimage
15
15
 
16
16
  # Specify items on which users are allowed to perform standalone imports
17
17
  __all__ = ['load_data', 'load_transform', 'plot_slice', 'Scissors',
18
- 'reciprocal_lattice_params', 'rotate_data',
18
+ 'reciprocal_lattice_params', 'rotate_data', 'rotate_data_2D'
19
19
  'array_to_nxdata', 'Padder']
20
20
 
21
21
 
@@ -853,7 +853,7 @@ def rotate_data(data, lattice_angle, rotation_angle, rotation_axis, printout=Fal
853
853
  (data[data.axes[0]], data[data.axes[1]], data[data.axes[2]]))
854
854
 
855
855
 
856
- def rotate_data2D(data, lattice_angle, rotation_angle):
856
+ def rotate_data_2D(data, lattice_angle, rotation_angle):
857
857
  """
858
858
  Rotates 2D data.
859
859
 
@@ -197,7 +197,7 @@ class Symmetrizer2D:
197
197
  # Scale and skew counts
198
198
  skew_angle_adj = 90 - self.skew_angle
199
199
 
200
- scale2 = counts.shape[0] / counts.shape[1]
200
+ scale2 = 1 # q1.max()/q2.max() # TODO: Need to double check this
201
201
  counts_unscaled2 = ndimage.affine_transform(counts,
202
202
  Affine2D().scale(scale2, 1).inverted().get_matrix()[:2, :2],
203
203
  offset=[-(1 - scale2) * counts.shape[
@@ -253,7 +253,7 @@ class Symmetrizer2D:
253
253
  order=0,
254
254
  )
255
255
 
256
- scale2 = counts.shape[0] / counts.shape[1]
256
+ scale2 = counts.shape[0]/counts.shape[1]
257
257
  wedge = ndimage.affine_transform(wedge,
258
258
  Affine2D().scale(scale2, 1).get_matrix()[:2, :2],
259
259
  offset=[(1 - scale2) * counts.shape[0] / 2, 0],
@@ -477,7 +477,7 @@ class Symmetrizer3D:
477
477
  q1, q2, q3 = self.q1, self.q2, self.q3
478
478
  out_array = np.zeros(data[data.signal].shape)
479
479
 
480
- if self.plane1symmetrizer.theta_max:
480
+ if self.plane1symmetrizer.theta_max is not None:
481
481
  print('Symmetrizing ' + self.plane1 + ' planes...')
482
482
  for k, value in enumerate(q3):
483
483
  print(f'Symmetrizing {q3.nxname}={value:.02f}...', end='\r')
@@ -485,7 +485,7 @@ class Symmetrizer3D:
485
485
  out_array[:, :, k] = data_symmetrized[data.signal].nxdata
486
486
  print('\nSymmetrized ' + self.plane1 + ' planes.')
487
487
 
488
- if self.plane2symmetrizer.theta_max:
488
+ if self.plane2symmetrizer.theta_max is not None:
489
489
  print('Symmetrizing ' + self.plane2 + ' planes...')
490
490
  for j, value in enumerate(q2):
491
491
  print(f'Symmetrizing {q2.nxname}={value:.02f}...', end='\r')
@@ -495,7 +495,7 @@ class Symmetrizer3D:
495
495
  out_array[:, j, :] = data_symmetrized[data.signal].nxdata
496
496
  print('\nSymmetrized ' + self.plane2 + ' planes.')
497
497
 
498
- if self.plane3symmetrizer.theta_max:
498
+ if self.plane3symmetrizer.theta_max is not None:
499
499
  print('Symmetrizing ' + self.plane3 + ' planes...')
500
500
  for i, value in enumerate(q1):
501
501
  print(f'Symmetrizing {q1.nxname}={value:.02f}...', end='\r')
@@ -536,7 +536,7 @@ class Symmetrizer3D:
536
536
  print("Output file saved to: " + os.path.join(os.getcwd(), fout_name))
537
537
 
538
538
 
539
- def generate_gaussian(H, K, L, amp, stddev, lattice_params, coeffs=None):
539
+ def generate_gaussian(H, K, L, amp, stddev, lattice_params, coeffs=None, center=None):
540
540
  """
541
541
  Generate a 3D Gaussian distribution.
542
542
 
@@ -558,16 +558,23 @@ def generate_gaussian(H, K, L, amp, stddev, lattice_params, coeffs=None):
558
558
  Coefficients for the Gaussian expression, including cross-terms between axes.
559
559
  Default is [1, 0, 1, 0, 1, 0],
560
560
  corresponding to (1*H**2 + 0*H*K + 1*K**2 + 0*K*L + 1*L**2 + 0*L*H).
561
+ center : tuple
562
+ Tuple of coordinates for the center of the Gaussian. Default is (0,0,0).
561
563
 
562
564
  Returns
563
565
  -------
564
566
  gaussian : ndarray
565
567
  3D Gaussian distribution array.
566
568
  """
569
+ if center is None:
570
+ center=(0,0,0)
567
571
  if coeffs is None:
568
572
  coeffs = [1, 0, 1, 0, 1, 0]
569
573
  a, b, c, al, be, ga = lattice_params
570
574
  a_, b_, c_, _, _, _ = reciprocal_lattice_params((a, b, c, al, be, ga))
575
+ H = H-center[0]
576
+ K = K-center[1]
577
+ L = L-center[2]
571
578
  H, K, L = np.meshgrid(H, K, L, indexing='ij')
572
579
  gaussian = amp * np.exp(-(coeffs[0] * H ** 2 +
573
580
  coeffs[1] * (b_ * a_ / (a_ ** 2)) * H * K +
@@ -581,7 +588,6 @@ def generate_gaussian(H, K, L, amp, stddev, lattice_params, coeffs=None):
581
588
  gaussian = gaussian.transpose()
582
589
  return gaussian.transpose(1, 0, 2)
583
590
 
584
-
585
591
  class Puncher:
586
592
  """
587
593
  A class for applying masks to 3D datasets, typically for data processing in reciprocal space.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: nxs-analysis-tools
3
- Version: 0.0.43
3
+ Version: 0.0.45
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
@@ -66,6 +66,7 @@ Requires-Dist: sphinx-autobuild>=2021.3.14; extra == "dev"
66
66
  Requires-Dist: sphinx-copybutton>=0.5.0; extra == "dev"
67
67
  Requires-Dist: sphinxext-opengraph>=0.6.3; extra == "dev"
68
68
  Requires-Dist: twine>=4.0.1; extra == "dev"
69
+ Dynamic: license-file
69
70
 
70
71
  # nxs-analysis-tools
71
72
 
@@ -0,0 +1,11 @@
1
+ _meta/__init__.py,sha256=_FU9nkOG1MKsIB1CYm_1yIt6hHVXjoLMxh9CqkZr_sQ,352
2
+ nxs_analysis_tools/__init__.py,sha256=bxbTLpIcKasH3fuRZOvJ9zeu7IBBju82mOTgUV4ZqHE,530
3
+ nxs_analysis_tools/chess.py,sha256=Jtycq4b897bKQSwvf2zig2dA2ToPgQnsKEjHNCqK7wY,25825
4
+ nxs_analysis_tools/datareduction.py,sha256=4yk-UZIdEwlEHj9iEEyeJHM820MHdGyVf4VlKSx3YUI,41982
5
+ nxs_analysis_tools/fitting.py,sha256=vPx75lKvm5pWOGBtRtff8k6J5dA6kRk3EJyzxCH5Tyk,8809
6
+ nxs_analysis_tools/pairdistribution.py,sha256=SDkxAWschiIBZX1Kvzex77LEgX4YlgnB-8DB_7Yo9mU,60293
7
+ nxs_analysis_tools-0.0.45.dist-info/licenses/LICENSE,sha256=tdnoYVH1-ogW_5-gGs9bK-IkCamH1ATJqrdL37kWTHk,1102
8
+ nxs_analysis_tools-0.0.45.dist-info/METADATA,sha256=AKCAQZFj7ErkOPLy1_eOr_TGMxzJGq2o3Nz8uLiiM3Y,3918
9
+ nxs_analysis_tools-0.0.45.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
10
+ nxs_analysis_tools-0.0.45.dist-info/top_level.txt,sha256=8U000GNPzo6T6pOMjRdgOSO5heMzLMGjkxa1CDtyMHM,25
11
+ nxs_analysis_tools-0.0.45.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (78.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,11 +0,0 @@
1
- _meta/__init__.py,sha256=kxRgW9usOeluI-Bk-1GiZ0pt5jesv-HKRThTZKAvTtI,352
2
- nxs_analysis_tools/__init__.py,sha256=bxbTLpIcKasH3fuRZOvJ9zeu7IBBju82mOTgUV4ZqHE,530
3
- nxs_analysis_tools/chess.py,sha256=e3ZnyepnLATXZRk2cgh6iCZ7Pk3NKJ4IvRf4xNLuu94,24984
4
- nxs_analysis_tools/datareduction.py,sha256=arEWF8VI8qJfT--G77OJL37C_3usjfd3-wT2gTCtwZM,41964
5
- nxs_analysis_tools/fitting.py,sha256=vPx75lKvm5pWOGBtRtff8k6J5dA6kRk3EJyzxCH5Tyk,8809
6
- nxs_analysis_tools/pairdistribution.py,sha256=8E1grptUMb4UXVT9mBSk45xk2JwjCvTG0Rl6BlbJAdo,60013
7
- nxs_analysis_tools-0.0.43.dist-info/LICENSE,sha256=tdnoYVH1-ogW_5-gGs9bK-IkCamH1ATJqrdL37kWTHk,1102
8
- nxs_analysis_tools-0.0.43.dist-info/METADATA,sha256=aBNS2AJAECd6RLqqQCFBjJgrW0piIhFaDxQCekvMqFc,3895
9
- nxs_analysis_tools-0.0.43.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
10
- nxs_analysis_tools-0.0.43.dist-info/top_level.txt,sha256=8U000GNPzo6T6pOMjRdgOSO5heMzLMGjkxa1CDtyMHM,25
11
- nxs_analysis_tools-0.0.43.dist-info/RECORD,,