advisor-scattering 0.5.3__py3-none-any.whl → 0.9.5__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.
Files changed (24) hide show
  1. advisor/controllers/app_controller.py +2 -1
  2. advisor/domain/__init__.py +4 -0
  3. advisor/domain/core/lab.py +9 -2
  4. advisor/domain/core/lattice.py +2 -5
  5. advisor/domain/core/sample.py +9 -2
  6. advisor/domain/orientation.py +219 -0
  7. advisor/domain/orientation_calculator.py +173 -0
  8. advisor/features/__init__.py +7 -4
  9. advisor/features/scattering_geometry/domain/brillouin_calculator.py +43 -1
  10. advisor/features/scattering_geometry/domain/core.py +4 -4
  11. advisor/features/scattering_geometry/ui/components/angles_to_hkl_components.py +10 -18
  12. advisor/features/scattering_geometry/ui/components/hk_angles_components.py +16 -29
  13. advisor/features/scattering_geometry/ui/components/hkl_scan_components.py +14 -25
  14. advisor/features/scattering_geometry/ui/components/hkl_to_angles_components.py +18 -29
  15. advisor/features/scattering_geometry/ui/scattering_geometry_tab.py +9 -1
  16. advisor/ui/dialogs/__init__.py +7 -0
  17. advisor/ui/dialogs/diffraction_test_dialog.py +287 -0
  18. advisor/ui/init_window.py +39 -15
  19. advisor/ui/visualizers/HKLScan2DVisualizer.py +37 -2
  20. {advisor_scattering-0.5.3.dist-info → advisor_scattering-0.9.5.dist-info}/METADATA +4 -2
  21. {advisor_scattering-0.5.3.dist-info → advisor_scattering-0.9.5.dist-info}/RECORD +24 -20
  22. {advisor_scattering-0.5.3.dist-info → advisor_scattering-0.9.5.dist-info}/WHEEL +0 -0
  23. {advisor_scattering-0.5.3.dist-info → advisor_scattering-0.9.5.dist-info}/entry_points.txt +0 -0
  24. {advisor_scattering-0.5.3.dist-info → advisor_scattering-0.9.5.dist-info}/top_level.txt +0 -0
advisor/ui/init_window.py CHANGED
@@ -1,22 +1,14 @@
1
1
  #!/usr/bin/env python3
2
2
  # -*- coding: utf-8 -*-
3
3
  # pylint: disable=no-name-in-module, import-error
4
- from PyQt5.QtWidgets import (
5
- QWidget,
6
- QGridLayout,
7
- QFormLayout,
8
- QLabel,
9
- QLineEdit,
10
- QPushButton,
11
- QDoubleSpinBox,
12
- QGroupBox,
13
- QMessageBox,
14
- QFileDialog,
15
- )
16
- from PyQt5.QtCore import pyqtSlot, pyqtSignal
4
+ from PyQt5.QtCore import pyqtSignal, pyqtSlot
17
5
  from PyQt5.QtGui import QDragEnterEvent, QDropEvent
6
+ from PyQt5.QtWidgets import (QDoubleSpinBox, QFileDialog, QFormLayout,
7
+ QGridLayout, QGroupBox, QLabel, QLineEdit,
8
+ QMessageBox, QPushButton, QWidget)
18
9
 
19
10
  from advisor.domain import UnitConverter
11
+ from advisor.ui.dialogs import DiffractionTestDialog
20
12
  from advisor.ui.utils import readcif
21
13
  from advisor.ui.visualizers import CoordinateVisualizer, UnitcellVisualizer
22
14
 
@@ -188,8 +180,8 @@ class InitWindow(QWidget):
188
180
  # Add energy group to main layout at (0,1)
189
181
  layout.addWidget(energy_group, 0, 1)
190
182
 
191
- # Group box for Euler angles
192
- euler_group = QGroupBox("Euler Angles")
183
+ # Group box for Sample orientation Euler angles
184
+ euler_group = QGroupBox("Sample Orientation (Euler Angles)")
193
185
  euler_layout = QFormLayout(euler_group)
194
186
 
195
187
  self.roll_input = QDoubleSpinBox()
@@ -219,6 +211,14 @@ class InitWindow(QWidget):
219
211
  self.yaw_input.valueChanged.connect(self.update_visualization)
220
212
  euler_layout.addRow("Yaw:", self.yaw_input)
221
213
 
214
+ # Add "Set UB Matrix (Import from Diffraction Tests)" button
215
+ self.import_orientation_btn = QPushButton("Set UB Matrix")
216
+ self.import_orientation_btn.setToolTip(
217
+ "Calculate Sample orientation (Euler angles) from known diffraction measurements. E.g. Two Braggs (002) (101) peaks are found at certain angles (tth, theta, phi, chi), at certain energy, the sample orientation can be determined."
218
+ )
219
+ self.import_orientation_btn.clicked.connect(self.open_diffraction_test_dialog)
220
+ euler_layout.addRow(self.import_orientation_btn)
221
+
222
222
  # Add euler group to main layout at (0,2)
223
223
  layout.addWidget(euler_group, 0, 2)
224
224
 
@@ -283,6 +283,30 @@ class InitWindow(QWidget):
283
283
  self.file_path_input.setText(file_path)
284
284
  # on_cif_file_changed will be triggered by textChanged
285
285
 
286
+ @pyqtSlot()
287
+ def open_diffraction_test_dialog(self):
288
+ """Open the diffraction test dialog to import orientation from measurements."""
289
+ # Gather current lattice parameters
290
+ lattice_params = {
291
+ "a": self.a_input.value(),
292
+ "b": self.b_input.value(),
293
+ "c": self.c_input.value(),
294
+ "alpha": self.alpha_input.value(),
295
+ "beta": self.beta_input.value(),
296
+ "gamma": self.gamma_input.value(),
297
+ }
298
+
299
+ # Open the dialog
300
+ dialog = DiffractionTestDialog(lattice_params, self)
301
+ if dialog.exec_() == DiffractionTestDialog.Accepted:
302
+ result = dialog.get_result()
303
+ if result is not None:
304
+ # Apply the calculated Sample orientation Euler angles
305
+ self.roll_input.setValue(result["roll"])
306
+ self.pitch_input.setValue(result["pitch"])
307
+ self.yaw_input.setValue(result["yaw"])
308
+ # update_visualization will be triggered by valueChanged signals
309
+
286
310
  def set_lattice_inputs_enabled(self, enabled: bool):
287
311
  """Enable/disable lattice parameter inputs (a,b,c,alpha,beta,gamma)."""
288
312
  self.a_input.setEnabled(enabled)
@@ -1,6 +1,8 @@
1
- from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
2
- from matplotlib.figure import Figure
3
1
  import numpy as np
2
+ from matplotlib.backends.backend_qt5agg import \
3
+ FigureCanvasQTAgg as FigureCanvas
4
+ from matplotlib.figure import Figure
5
+ from matplotlib.patches import Ellipse
4
6
 
5
7
 
6
8
  class HKLScan2DVisualizer(FigureCanvas):
@@ -222,3 +224,36 @@ class HKLScan2DVisualizer(FigureCanvas):
222
224
  except Exception as e:
223
225
  print(f"Error in _plot_trajectory_only: {e}")
224
226
  return False
227
+
228
+ def plot_accessible_area(self, plane_type, h_max, k_max, l_max, message=None):
229
+ """ plot an ellipse in the plane to represent the accessible area in k-space.
230
+
231
+ Args:
232
+ plane_type: "HK", "HL", or "KL"
233
+ h_max: maximum value of the h-axis
234
+ k_max: maximum value of the k-axis
235
+ l_max: maximum value of the l-axis
236
+ """
237
+ # use matplotlib patches to plot an ellipse in the plane to represent the accessible area in
238
+ # k-space.
239
+
240
+ if plane_type == "HK":
241
+ x_max = h_max
242
+ y_max = k_max
243
+ elif plane_type == "HL":
244
+ x_max = h_max
245
+ y_max = l_max
246
+ elif plane_type == "KL":
247
+ x_max = k_max
248
+ y_max = l_max
249
+
250
+ ellipse = Ellipse(xy=(0, 0), width=2*x_max, height=2*y_max, angle=0, color='#80e8be', alpha=0.35, edgecolor='none')
251
+ self.axes.add_patch(ellipse)
252
+
253
+ # put a gray text on the top left corner of the plot
254
+ if message is not None:
255
+ self.axes.text(0.02, 0.985, message, color='gray', fontsize=8, transform=self.axes.transAxes, va="top", alpha = 0.65)
256
+
257
+ self.axes.text(0,0.1,"accessible area", color='#52a38b', fontsize=8, ha="center")
258
+ self.draw()
259
+ return True
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: advisor-scattering
3
- Version: 0.5.3
3
+ Version: 0.9.5
4
4
  Summary: Advisor-Scattering: Advanced Visual X-ray Scattering Toolkit for Reciprocal-space visualization and calculation
5
5
  Author: Xunyang Hong
6
6
  License: MIT
@@ -37,6 +37,7 @@ or use the link below to view the demo video.
37
37
  - Visualize scattering geometry and unit cells
38
38
  - Compute and visualize structure factors in reciprocal space.
39
39
  - CIF file drop-in support
40
+ - Import crystal orientation from diffraction test data
40
41
 
41
42
 
42
43
  ## Install
@@ -75,7 +76,8 @@ python -m advisor
75
76
  ### 1. Initialization window
76
77
  - Enter lattice constants (a, b, c) and angles (alpha, beta, gamma); beam energy auto-updates wavelength/|k|.
77
78
  - Optional: drop a CIF to autofill lattice parameters and preview the unit cell.
78
- - Adjust Euler angles (roll, pitch, yaw) to orient the sample relative to the scattering plane;
79
+ - Adjust Euler angles (roll, pitch, yaw) to orient the lattice/sample relative to the goniometer.
80
+ - **New:** Use **Import from Diffraction Test** to automatically determine Euler angles from known diffraction measurements.
79
81
  - Click **Initialize** to load the main interface and pass parameters to all tabs.
80
82
 
81
83
  ### 2. Scattering Geometry tab
@@ -2,28 +2,30 @@ advisor/__init__.py,sha256=9gmF8qfMHMVLbmvWW_20KkHU5zOCwUmmFHtju21klPQ,103
2
2
  advisor/__main__.py,sha256=FueZKRQwCGBKNtk4W_Z9yYpsI0YB5WiVREWyZXmSl8A,124
3
3
  advisor/app.py,sha256=52DxOOlZV_NHUzsnuYCCo_cI48D2THKE1m0-1ZVoNvE,1165
4
4
  advisor/controllers/__init__.py,sha256=DEzJDUTJcRrbe7ZYnYsQQ3NvnyayNwTafcQmY7aRtrw,198
5
- advisor/controllers/app_controller.py,sha256=cl7sKgfyz9J2o7RLgP18mExNjU_FDK5rUPrdmI15b1g,2344
5
+ advisor/controllers/app_controller.py,sha256=CGqlhez9467JMZZeMbnbF-HwqwCayoYIfajy4vRBZtE,2433
6
6
  advisor/controllers/feature_controller.py,sha256=6_XOck8ipQxbef24y16tCE08q7OUT0gs285d5tF5XRs,642
7
- advisor/domain/__init__.py,sha256=Lkpnerzg6qHzk-u4jOAU1rg6rYY4iIorIECdOTPd2DY,536
7
+ advisor/domain/__init__.py,sha256=SuMfLp1CJFqrpBE6UeyVe9BWdjbBlcwuHRTBN-UsOzg,733
8
8
  advisor/domain/geometry.py,sha256=E8YmecQpBh7PQeJIamOlPo2aBgJSbhyBlrYS02uxFMg,6856
9
+ advisor/domain/orientation.py,sha256=PDPxosByY_Yo7FePUAZLsrN1OcH4_kUiF8TwC5jFGL8,7649
10
+ advisor/domain/orientation_calculator.py,sha256=EunUKxbLecFxmo6xZVEYO4r9OFJVFM-M8V83D0j1xE8,5840
9
11
  advisor/domain/unit_converter.py,sha256=D20FvdV7_ilAX7KDPxQ1GDCA6IxdjjcQ2QBiahb3lLI,2085
10
12
  advisor/domain/core/__init__.py,sha256=UPDQYo7-5f9Ghx3p6qlwljTLhHsxlGmEl_MvdaHM2Jg,173
11
- advisor/domain/core/lab.py,sha256=pLA5DhG_LMbJhbEABN53BU0FdTUAZbA38jiPjXzd29g,4871
12
- advisor/domain/core/lattice.py,sha256=UXxkZG6iHGLXwHPEH6VQLXAg274rD3BTpq4ObDIOxIg,2728
13
- advisor/domain/core/sample.py,sha256=iMPvQprPGllp6WfwnsESzNode4tujYNbVHhcNL6Uhuk,4105
14
- advisor/features/__init__.py,sha256=wQYN67pLXVgxmsoG70WJ51BnE9ACUgbpx-G740KHsEA,272
13
+ advisor/domain/core/lab.py,sha256=_IbRVbPvffkM73f41uJ3R43ZeZ6LOxNOrywWz_DDT_8,5129
14
+ advisor/domain/core/lattice.py,sha256=339_veWj1KFTAwuH37-vx5a9wjUfQzJI6MoSxMm8tX8,2757
15
+ advisor/domain/core/sample.py,sha256=zz0qMlpeGHEXmmkoY1GtOBI5-uK4hhOVeLjuje6-Osc,4278
16
+ advisor/features/__init__.py,sha256=Arhqas6uY2uJp58ttNEVap9gRYE0uOVw1dA6gtB9544,330
15
17
  advisor/features/scattering_geometry/controllers/__init__.py,sha256=2V9KZMlxjHpsBIdkphveylQgL9z6BV09DaufqQcLX_Y,169
16
18
  advisor/features/scattering_geometry/controllers/scattering_geometry_controller.py,sha256=QGcm5_y8EPNYUF_FM9xViVzPJs6qh1dB_OA3fjoKAEg,1076
17
19
  advisor/features/scattering_geometry/domain/__init__.py,sha256=BsK0j9-RJiK0-g0qB3DH8qoSqlEZNAPBQb7eXYrg0oU,142
18
- advisor/features/scattering_geometry/domain/brillouin_calculator.py,sha256=_vpR8T1j1h-agZOlxk4xfpBq1XmbrZsssgookIqYwr0,15620
19
- advisor/features/scattering_geometry/domain/core.py,sha256=OQ7gZ19XwZPtC3mXukkzlmOiDmgjvKBrVzRNJRi1OuU,20149
20
+ advisor/features/scattering_geometry/domain/brillouin_calculator.py,sha256=XIHIgPg5RBHp25k0RgbFsxZLONESpQehipYCBnsGrj8,17033
21
+ advisor/features/scattering_geometry/domain/core.py,sha256=2JdHNjdl_GnyhOr0iGRMgTK1JlYFg6WA0uWe0mYUgyY,20149
20
22
  advisor/features/scattering_geometry/ui/__init__.py,sha256=9Lm-sc1Q3KeQ-0kKJneD10MWuqyDgh29QDAVdHghh1Q,154
21
- advisor/features/scattering_geometry/ui/scattering_geometry_tab.py,sha256=GHczdi74GxCxo3svF7oBdXrbTilLZ4ODkTuatJrfTkE,29448
23
+ advisor/features/scattering_geometry/ui/scattering_geometry_tab.py,sha256=84ag1_p-Ie7sWP6u3cAw9mGbiLNJwTsAHQD89bmeUK0,29981
22
24
  advisor/features/scattering_geometry/ui/components/__init__.py,sha256=OsX27CeUv5gznYXmkZWqeXwcskf4DmxOH6xJ0-cUwDg,358
23
- advisor/features/scattering_geometry/ui/components/angles_to_hkl_components.py,sha256=l6kPM7b95nvNsp1Eg0kmWIfFPTtmuGQyDol_mnx7lOs,4889
24
- advisor/features/scattering_geometry/ui/components/hk_angles_components.py,sha256=ZkzRASVeII5dF5_WfwmVBrRwYWTCDNvE05VNa6idxGo,20538
25
- advisor/features/scattering_geometry/ui/components/hkl_scan_components.py,sha256=JLzbkK1zM8CZm2WZvDyRg-Twwmt46KNKGr1DG7MPfXs,20522
26
- advisor/features/scattering_geometry/ui/components/hkl_to_angles_components.py,sha256=0J-CXiBCTOoLjFK5-PgY0PjZSG1aU7sYrE-MilJSAEA,15834
25
+ advisor/features/scattering_geometry/ui/components/angles_to_hkl_components.py,sha256=jXV3uLQZ2k_jfDYhTQEXb-nJzJjK7wgcdORfHhe0Wto,4883
26
+ advisor/features/scattering_geometry/ui/components/hk_angles_components.py,sha256=RMR1sY43wJOathWB23XTUV8bvfaJAacMR0HrIhPPnOE,20587
27
+ advisor/features/scattering_geometry/ui/components/hkl_scan_components.py,sha256=norgU88nvxZIhdV6GxWBKZpiGlBpUXwDO8pfOX_mvSs,20573
28
+ advisor/features/scattering_geometry/ui/components/hkl_to_angles_components.py,sha256=sGTKxOEHli18N937LDULMj6VymerCOWhoIksZZi6Ioo,15885
27
29
  advisor/features/structure_factor/controllers/__init__.py,sha256=aGyA8cXJ64HfULWo6_6D4azt4Hs8qJ6wH_OW6BClv9Y,158
28
30
  advisor/features/structure_factor/controllers/structure_factor_controller.py,sha256=4PBHg8lPXcQA7Tpocu3A3GzGQP2IZP8CNPH6PILHyWw,975
29
31
  advisor/features/structure_factor/domain/__init__.py,sha256=lNxY4RcTYCSboXpAWJfib29WqYg6o4jesbNk-Z279rU,159
@@ -49,21 +51,23 @@ advisor/resources/icons/sf_calculator.jpg,sha256=W7e89x2K6np5l200hklRfdh0pkA3SGz
49
51
  advisor/resources/icons/sf_calculator.png,sha256=ArnSfIQo8Gc8uWQhpG7DTCBNFcuVGXDIiQ7Yb-x9D_M,44466
50
52
  advisor/resources/qss/styles.qss,sha256=R29qftSIvN0AI1UVsLSsHcUImIYGnbbuF_1LvViF3mg,8070
51
53
  advisor/ui/__init__.py,sha256=isDNFKHsZq1s8Och-5tHcFC5FAJA653x4r5DYGsVowU,202
52
- advisor/ui/init_window.py,sha256=pOxGUfKcObnQKcGDKtEbBmQ18yOOfwEY1SxhHO3DRqs,22273
54
+ advisor/ui/init_window.py,sha256=z2AJXf_beZe22q9mWQYo0KZPbm_6oG9Eg2SsL5TdiOQ,23996
53
55
  advisor/ui/main_window.py,sha256=I5vCpPPQCwaSag538YPQC_bgarVJGQ1ryuxjWxuMP-0,6170
54
56
  advisor/ui/tab_interface.py,sha256=8okMV0NurIyEGxRf-YXHrjftzWyMzXcea3cdt3i1FtE,1180
55
57
  advisor/ui/tips.py,sha256=5iP28xJvKBkdgvo3eDD2kzV52FEeT_Sd8ivtWlhi0Xs,742
58
+ advisor/ui/dialogs/__init__.py,sha256=yFeoZOe0euOXeie-fqwJquZ9Vhl8mtszIWg1aunawXI,197
59
+ advisor/ui/dialogs/diffraction_test_dialog.py,sha256=5fI8Ow73YXHCgot1Mq6KZup9EJXoI6hHpsIYHziS_ts,10640
56
60
  advisor/ui/utils/__init__.py,sha256=U_IwI_KEtmKLMKw6e2ko7GkUa50-PvkeMFS_6QfHoyg,84
57
61
  advisor/ui/utils/readcif.py,sha256=tRuz1WSBr8XWkgf6VUOlS5aTf2LYDi8CY4peJ1_0bjI,4554
58
- advisor/ui/visualizers/HKLScan2DVisualizer.py,sha256=Q8_MWKiyzrFk4-3S50Ro7_4I_ERbSagG52686lPSuFo,8706
62
+ advisor/ui/visualizers/HKLScan2DVisualizer.py,sha256=cm6HsSLzQr6ocDu7PnrogoiBhdtZ56J2TCFKApPee8Q,10039
59
63
  advisor/ui/visualizers/__init__.py,sha256=zSgo7A5nTkdV3hsBuSUjZ2GF-aRBObntR_bkRmMlaJU,524
60
64
  advisor/ui/visualizers/coordinate_visualizer.py,sha256=JqHhT5LSr7CLUDtOrzYCpbHSG7GNna2_qptOioiTc0o,7076
61
65
  advisor/ui/visualizers/scattering_visualizer.py,sha256=iyjTgy1WbqI7G0BpiJ59CKFCI9c-eJLSFWM31Wi2TBk,10723
62
66
  advisor/ui/visualizers/structure_factor_visualizer.py,sha256=Rt9ui7Qv4vvDCWiuIngoYzHJlFVef8M_h3BBRcmuFTc,15866
63
67
  advisor/ui/visualizers/structure_factor_visualizer_2d.py,sha256=xA1hrp7pKIfgD1G_Pt-uemHggmKf-7QC94dS-GasZI4,8119
64
68
  advisor/ui/visualizers/unitcell_visualizer.py,sha256=gwpMkU1YIu-8zkKVu5bHpyu_iLbzYEYTbVArchNMLOI,21384
65
- advisor_scattering-0.5.3.dist-info/METADATA,sha256=flwNil7WdTQXXr4pfw32egU2fBC6B7ewfvzcwMLH1Fg,4658
66
- advisor_scattering-0.5.3.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
67
- advisor_scattering-0.5.3.dist-info/entry_points.txt,sha256=b__0W6TTAPUTc0UIUyHdxvxtsVz025Y-QNrMKzt8b9o,83
68
- advisor_scattering-0.5.3.dist-info/top_level.txt,sha256=4YoJT7oclQ2yU-4KY0AB36cfAZG9yAI1tJNHrxEioMA,8
69
- advisor_scattering-0.5.3.dist-info/RECORD,,
69
+ advisor_scattering-0.9.5.dist-info/METADATA,sha256=mRA-dWKW_UPBF_W_Hw1wsgmEkJ4vFE0a-IVVW-YdGyQ,4841
70
+ advisor_scattering-0.9.5.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
71
+ advisor_scattering-0.9.5.dist-info/entry_points.txt,sha256=b__0W6TTAPUTc0UIUyHdxvxtsVz025Y-QNrMKzt8b9o,83
72
+ advisor_scattering-0.9.5.dist-info/top_level.txt,sha256=4YoJT7oclQ2yU-4KY0AB36cfAZG9yAI1tJNHrxEioMA,8
73
+ advisor_scattering-0.9.5.dist-info/RECORD,,