From c49c5168e6e0570d7c762bf1c9695954cffebc23 Mon Sep 17 00:00:00 2001 From: Pete R Jemian Date: Wed, 13 Dec 2023 18:59:49 -0600 Subject: [PATCH] MNT #310 canonical -> user axes --- hkl/util.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/hkl/util.py b/hkl/util.py index a46d8b5e..7d7fae80 100644 --- a/hkl/util.py +++ b/hkl/util.py @@ -444,19 +444,23 @@ def restore_reflections(orientation, diffractometer): Diffractometer object. """ _check_geometry(orientation, diffractometer) + calc = diffractometer.calc # remember this wavelength - wavelength0 = diffractometer.calc.wavelength + wavelength0 = calc.wavelength # short aliases pseudos = orientation["_pseudos"] reals = orientation["_reals"] + if reals != calc.physical_axis_names and reals == calc._geometry.axis_names_get(): + # Substitute user-defined axes names for canonical axes names. + reals = calc.physical_axis_names orientation_reflections = [] # might be renamed axes - renaming = diffractometer.calc._axis_name_to_original + renaming = calc._axis_name_to_original for ref_base in orientation["reflections_details"]: # every reflection has its own wavelength - diffractometer.calc.wavelength = ref_base["wavelength"] + calc.wavelength = ref_base["wavelength"] # Order of the items is important. # Can't just use the dictionaries in ``orientation``. @@ -471,17 +475,17 @@ def restore_reflections(orientation, diffractometer): # assemble the final form of the reflection for add_reflection() reflection = tuple([*miller_indices, ppp]) - r = diffractometer.calc.sample.add_reflection(*reflection) + r = calc.sample.add_reflection(*reflection) if ref_base["orientation_reflection"]: orientation_reflections.append(r) if len(orientation_reflections) > 1: # compute **UB** from the last two orientation reflections - diffractometer.calc.sample.compute_UB(*orientation_reflections[-2:]) + calc.sample.compute_UB(*orientation_reflections[-2:]) # restore previous wavelength - if diffractometer.calc.wavelength != wavelength0: - diffractometer.calc.wavelength = wavelength0 + if calc.wavelength != wavelength0: + calc.wavelength = wavelength0 def restore_orientation(orientation, diffractometer):