nxs-analysis-tools 0.0.40__py3-none-any.whl → 0.0.42__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.40'
9
+ __version__ = '0.0.42'
10
10
  __repo_url__ = 'https://github.com/stevenjgomez/nxs_analysis_tools'
@@ -8,6 +8,7 @@ import re
8
8
 
9
9
  import matplotlib.pyplot as plt
10
10
  import matplotlib as mpl
11
+ import pandas as pd
11
12
  import numpy as np
12
13
  from IPython.display import display, Markdown
13
14
  from nxs_analysis_tools import load_data, Scissors
@@ -190,8 +191,12 @@ class TempDependence:
190
191
 
191
192
  # Convert all temperatures to int temporarily to sort temperatures list before loading
192
193
  self.temperatures = [int(t) for t in self.temperatures]
193
- self.temperatures.sort()
194
+
195
+ loading_template = pd.DataFrame({'temperature': self.temperatures, 'filename': items_to_load})
196
+ loading_template = loading_template.sort_values(by='temperature')
197
+ self.temperatures = loading_template['temperature']
194
198
  self.temperatures = [str(t) for t in self.temperatures]
199
+ items_to_load = loading_template['filename'].to_list()
195
200
 
196
201
  for i, item in enumerate(items_to_load):
197
202
  path = os.path.join(self.sample_directory, item)
@@ -787,7 +787,8 @@ def rotate_data(data, lattice_angle, rotation_angle, rotation_axis, printout=Fal
787
787
 
788
788
  p = Padder(sliced_data)
789
789
  padding = tuple(len(sliced_data[axis]) for axis in sliced_data.axes)
790
- counts = p.pad(padding).counts
790
+ counts = p.pad(padding)
791
+ counts = p.padded[p.padded.signal]
791
792
 
792
793
  counts_skewed = ndimage.affine_transform(counts,
793
794
  t.inverted().get_matrix()[:2, :2],
@@ -848,7 +849,7 @@ def rotate_data(data, lattice_angle, rotation_angle, rotation_axis, printout=Fal
848
849
  elif rotation_axis == 2:
849
850
  output_array[:, :, i] = counts_unpadded
850
851
  print('\nDone.')
851
- return NXdata(NXfield(output_array, name='counts'),
852
+ return NXdata(NXfield(output_array, name=p.padded.signal),
852
853
  (data[data.axes[0]], data[data.axes[1]], data[data.axes[2]]))
853
854
 
854
855
 
@@ -884,7 +885,8 @@ def rotate_data2D(data, lattice_angle, rotation_angle):
884
885
 
885
886
  p = Padder(data)
886
887
  padding = tuple(len(data[axis]) for axis in data.axes)
887
- counts = p.pad(padding).counts
888
+ counts = p.pad(padding)
889
+ counts = p.padded[p.padded.signal]
888
890
 
889
891
  counts_skewed = ndimage.affine_transform(counts,
890
892
  t.inverted().get_matrix()[:2, :2],
@@ -937,7 +939,7 @@ def rotate_data2D(data, lattice_angle, rotation_angle):
937
939
  counts_unpadded = p.unpad(counts_unskewed)
938
940
 
939
941
  print('\nDone.')
940
- return NXdata(NXfield(counts_unpadded, name='counts'),
942
+ return NXdata(NXfield(counts_unpadded, name=p.padded.signal),
941
943
  (data[data.axes[0]], data[data.axes[1]]))
942
944
 
943
945
 
@@ -1140,7 +1140,7 @@ class Interpolator:
1140
1140
  self.tapered = self.interpolated * self.window
1141
1141
 
1142
1142
 
1143
- def fourier_transform_nxdata(data):
1143
+ def fourier_transform_nxdata(data, is_2d=False):
1144
1144
  """
1145
1145
  Perform a 3D Fourier Transform on the given NXdata object.
1146
1146
 
@@ -1156,6 +1156,10 @@ def fourier_transform_nxdata(data):
1156
1156
  include the `signal` field for the data and `axes` fields
1157
1157
  specifying the coordinate axes.
1158
1158
 
1159
+ is_2d : bool
1160
+ If true, skip FFT on out-of-plane direction and only do FFT
1161
+ on axes 0 and 1. Default False.
1162
+
1159
1163
  Returns
1160
1164
  -------
1161
1165
  NXdata
@@ -1163,16 +1167,13 @@ def fourier_transform_nxdata(data):
1163
1167
  result includes:
1164
1168
 
1165
1169
  - `dPDF`: The transformed data array.
1166
- - `x`, `y`, `z`: Arrays representing the frequency components along each axis.
1170
+ - `x`, `y`, `z`: Arrays representing the real-space components along each axis.
1167
1171
 
1168
1172
  Notes
1169
1173
  -----
1170
- - The FFT is performed in two stages: first along the last dimension of
1171
- the input array and then along the first two dimensions.
1172
- - The function uses `pyfftw` for efficient computation of the Fourier
1173
- Transform.
1174
- - The output frequency components are computed based on the step sizes
1175
- of the original data axes.
1174
+ - The FFT is performed in two stages: first along the last dimension of the input array and then along the first two dimensions.
1175
+ - The function uses `pyfftw` for efficient computation of the Fourier Transform.
1176
+ - The output frequency components are computed based on the step sizes of the original data axes.
1176
1177
 
1177
1178
  """
1178
1179
  start = time.time()
@@ -1181,7 +1182,9 @@ def fourier_transform_nxdata(data):
1181
1182
  padded = data[data.signal].nxdata
1182
1183
 
1183
1184
  fft_array = np.zeros(padded.shape)
1185
+
1184
1186
  print("FFT on axes 1,2")
1187
+
1185
1188
  for k in range(0, padded.shape[2]):
1186
1189
  fft_array[:, :, k] = np.real(
1187
1190
  np.fft.fftshift(
@@ -1190,17 +1193,18 @@ def fourier_transform_nxdata(data):
1190
1193
  )
1191
1194
  print(f'k={k} ', end='\r')
1192
1195
 
1193
- print("FFT on axis 3")
1194
- for i in range(0, padded.shape[0]):
1195
- for j in range(0, padded.shape[1]):
1196
- f_slice = fft_array[i, j, :]
1197
- print(f'i={i} ', end='\r')
1198
- fft_array[i, j, :] = np.real(
1199
- np.fft.fftshift(
1200
- pyfftw.interfaces.numpy_fft.ifftn(np.fft.fftshift(f_slice),
1201
- planner_effort='FFTW_MEASURE')
1196
+ if not is_2d:
1197
+ print("FFT on axis 3")
1198
+ for i in range(0, padded.shape[0]):
1199
+ for j in range(0, padded.shape[1]):
1200
+ f_slice = fft_array[i, j, :]
1201
+ print(f'i={i} ', end='\r')
1202
+ fft_array[i, j, :] = np.real(
1203
+ np.fft.fftshift(
1204
+ pyfftw.interfaces.numpy_fft.ifftn(np.fft.fftshift(f_slice),
1205
+ planner_effort='FFTW_MEASURE')
1206
+ )
1202
1207
  )
1203
- )
1204
1208
 
1205
1209
  end = time.time()
1206
1210
  print("FFT complete.")
@@ -1520,7 +1524,7 @@ class DeltaPDF:
1520
1524
  """
1521
1525
  self.padded = self.padder.pad(padding)
1522
1526
 
1523
- def perform_fft(self):
1527
+ def perform_fft(self, is_2d=False):
1524
1528
  """
1525
1529
  Perform a 3D Fourier Transform on the padded data.
1526
1530
 
@@ -1548,4 +1552,4 @@ class DeltaPDF:
1548
1552
 
1549
1553
 
1550
1554
  """
1551
- self.fft = fourier_transform_nxdata(self.padded)
1555
+ self.fft = fourier_transform_nxdata(self.padded, is_2d=is_2d)
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: nxs-analysis-tools
3
- Version: 0.0.40
3
+ Version: 0.0.42
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
@@ -0,0 +1,11 @@
1
+ _meta/__init__.py,sha256=RgVI9i9hMP8JG47ZopZMSrPEHTeCD680Z5-BWeTUZzY,352
2
+ nxs_analysis_tools/__init__.py,sha256=bxbTLpIcKasH3fuRZOvJ9zeu7IBBju82mOTgUV4ZqHE,530
3
+ nxs_analysis_tools/chess.py,sha256=LA2z-qk7IgNGPm8ov7JLgIupv__vmHfAc9NFCblI5fQ,24632
4
+ nxs_analysis_tools/datareduction.py,sha256=RcfAqokK04CKuj867MdiF5EhzhhodJx99G40v8wh8W8,41932
5
+ nxs_analysis_tools/fitting.py,sha256=vPx75lKvm5pWOGBtRtff8k6J5dA6kRk3EJyzxCH5Tyk,8809
6
+ nxs_analysis_tools/pairdistribution.py,sha256=bO-Ljst8eD5wmeq6oH8ylhHqaUyu2CvARznDupCygWQ,58245
7
+ nxs_analysis_tools-0.0.42.dist-info/LICENSE,sha256=tdnoYVH1-ogW_5-gGs9bK-IkCamH1ATJqrdL37kWTHk,1102
8
+ nxs_analysis_tools-0.0.42.dist-info/METADATA,sha256=8lqJPJaka29fMmA2GTTtUzCnJnkhjVjKYcLv_gLqmu4,3895
9
+ nxs_analysis_tools-0.0.42.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
10
+ nxs_analysis_tools-0.0.42.dist-info/top_level.txt,sha256=8U000GNPzo6T6pOMjRdgOSO5heMzLMGjkxa1CDtyMHM,25
11
+ nxs_analysis_tools-0.0.42.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.1.0)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,11 +0,0 @@
1
- _meta/__init__.py,sha256=cgRdSYbkbQq7Gw011aNLk8NLfCZBtPjp2VfhtL5KeeE,352
2
- nxs_analysis_tools/__init__.py,sha256=bxbTLpIcKasH3fuRZOvJ9zeu7IBBju82mOTgUV4ZqHE,530
3
- nxs_analysis_tools/chess.py,sha256=GUW08BcDUGD88MPZCl4yJTQp4hwd9tVNTJN_afNSUUo,24339
4
- nxs_analysis_tools/datareduction.py,sha256=e__mBGZIpJ-_-Dr6-T9hJURJazFnBy3PoWfwRxOra4U,41848
5
- nxs_analysis_tools/fitting.py,sha256=vPx75lKvm5pWOGBtRtff8k6J5dA6kRk3EJyzxCH5Tyk,8809
6
- nxs_analysis_tools/pairdistribution.py,sha256=AtjllbbakFyo3MnGH18rvr6-h3ONopxXEmZK4F3VzMI,58023
7
- nxs_analysis_tools-0.0.40.dist-info/LICENSE,sha256=tdnoYVH1-ogW_5-gGs9bK-IkCamH1ATJqrdL37kWTHk,1102
8
- nxs_analysis_tools-0.0.40.dist-info/METADATA,sha256=H9FqaRexBO4zxSFcunsIieblI5jhUtosugg4sZVCMFU,3895
9
- nxs_analysis_tools-0.0.40.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
10
- nxs_analysis_tools-0.0.40.dist-info/top_level.txt,sha256=8U000GNPzo6T6pOMjRdgOSO5heMzLMGjkxa1CDtyMHM,25
11
- nxs_analysis_tools-0.0.40.dist-info/RECORD,,