Skip to content

Commit

Permalink
MNT #310 canonical -> user axes
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed Dec 14, 2023
1 parent 7f8bef8 commit c49c516
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions hkl/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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``.
Expand All @@ -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):
Expand Down

0 comments on commit c49c516

Please sign in to comment.