Open gfabbris opened 2 years ago
In [1]: %run start_macro.py
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
File /home/sector4/4idd/2022_2/Ir_Rodolfo/start_macro.py:26, in <module>
24 restore_sample(orientation, fourc)
25 restore_constraints(orientation, fourc)
---> 26 restore_reflections(orientation, fourc)
28 fourc.engine.mode = "constant_phi"
File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/hkl/util.py:413, in restore_reflections(orientation, diffractometer)
409 # Order of the items is important.
410 # Can't just use the dictionaries in ``orientation``.
411 # Get the canonical order from the orientation data.
412 miller_indices = [ref_base["reflection"][key] for key in pseudos]
--> 413 positions = [ref_base["position"][key] for key in reals]
414 ppp = namedtuple("PositionTuple", tuple(reals))(*positions)
416 # assemble the final form of the reflection for add_reflection()
File ~/.conda/envs/bluesky_2022_2/lib/python3.9/site-packages/hkl/util.py:413, in <listcomp>(.0)
409 # Order of the items is important.
410 # Can't just use the dictionaries in ``orientation``.
411 # Get the canonical order from the orientation data.
412 miller_indices = [ref_base["reflection"][key] for key in pseudos]
--> 413 positions = [ref_base["position"][key] for key in reals]
414 ppp = namedtuple("PositionTuple", tuple(reals))(*positions)
416 # assemble the final form of the reflection for add_reflection()
KeyError: 'theta'
The first problem may happen because fourc.energy.kind = omitted
?
https://github.com/APS-4ID-POLAR/ipython-polar/blob/fa20b5420b2b2fa51c577c861bd589abcfac7967/profile_bluesky/startup/instrument/devices/huber.py#L94
The second problem may be because we rename omega
to theta
.
https://github.com/APS-4ID-POLAR/ipython-polar/blob/fa20b5420b2b2fa51c577c861bd589abcfac7967/profile_bluesky/startup/instrument/devices/huber.py#L84
@prjemian: FYI
And I imagine, for the second problem, the rename map is not stored. Definitely an issue for hklpy.
Because it is certain that setting kind="omitted"
was a misconfiguration from the expected kind="config"
.
The reason for the omitted
energy
is because we are reading the monochromator directly and I was concerned about having two Devices
read the same EpicsSignal
. But, actually, it probably doesn't make sense to restore the energy for us as it should be set by the beamline energy.
When a reflection is defined, it uses the wavelength from the diffractometer. So the wavelength (from the X-ray photon energy) must be set before the hkl is defined by the reflection angles.
In the future, this should be made more flexible, so that an arbitrary wavelength could be supplied without the diffractometer actually being set to it. But that is not how the code (in the libhkl C code) works today.
Here's the upgrade issue in hklpy: https://github.com/bluesky/hklpy/issues/189
I agree that hklpy needs to be able to use the energy at which the reflection was defined, not the current energy. The UB matrix is energy independent, so I think I could tie the fourc energy to the Beamline's in a subscription, and then add restore_UB
to the end of a local version of restore_orientation
. Does that sound correct?
Yes
On Sat, Jun 4, 2022, 2:25 PM Gilberto Fabbris @.***> wrote:
I agree that hklpy needs to be able to use the energy at which the reflection was defined, not the current energy. The UB matrix is energy independent, so I think I could tie the fourc energy to the Beamline's in a subscription, and then add restore_UB to the end of a local version of restore_orientation. Does that sound correct?
— Reply to this email directly, view it on GitHub https://github.com/APS-4ID-POLAR/ipython-polar/issues/146#issuecomment-1146673009, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARMUMBXIH2JGVTN3Y4A2BDVNOUUFANCNFSM5XRXTRIA . You are receiving this because you were mentioned.Message ID: @.***>