Migration from hklpy (v1)#
hklpy2 is a complete redesign of the hklpy (v1) library with significant architectural changes. The main difference is that hklpy2 moves from a design centered on Hkl/Soleil to a Python-native data model with pluggable solvers.
For an AI-assisted description of the factors involved in migration, see DeepWiki.
Caution
Be careful with the code examples presented by the AI-assisted description. Often, they are not correct technically.
Simulated Eulerian 4-circle diffractometer#
1from hklpy2 import creator
2
3fourc = creator()
1from hkl import E4CV
2from ophyd import PseudoSingle, SoftPositioner
3from ophyd import Component as Cpt
4
5class FourCircle(SimMixin, E4CV):
6 """
7 Our 4-circle. Eulerian, vertical scattering orientation.
8 """
9 h = Cpt(PseudoSingle, "", kind="hinted")
10 k = Cpt(PseudoSingle, "", kind="hinted")
11 l = Cpt(PseudoSingle, "", kind="hinted")
12
13 omega = Cpt(SoftPositioner, kind="hinted", init_pos=0)
14 chi = Cpt(SoftPositioner, kind="hinted", init_pos=0)
15 phi = Cpt(SoftPositioner, kind="hinted", init_pos=0)
16 tth = Cpt(SoftPositioner, kind="hinted", init_pos=0)
17
18fourc = FourCircle("", name="fourc")
EPICS-based Eulerian 4-circle diffractometer#
1from hklpy2 import creator
2
3fourc = creator(
4 prefix="PREFIX:",
5 name="fourc",
6 geometry="E4CV",
7 solver="hkl_soleil",
8 reals=dict(
9 omega="m30",
10 chi="m31",
11 phi="m32",
12 tth="m29",
13 )
14)
1from hkl import E4CV
2from ophyd import EpicsMotor, PseudoSingle
3from ophyd import Component as Cpt
4
5class FourCircle(E4CV):
6 """
7 Our 4-circle. Eulerian, vertical scattering orientation.
8 """
9 # the reciprocal axes h, k, l are defined by SimMixin
10 h = Cpt(PseudoSingle, "", kind="hinted")
11 k = Cpt(PseudoSingle, "", kind="hinted")
12 l = Cpt(PseudoSingle, "", kind="hinted")
13
14 omega = Cpt(EpicsMotor, "m30", kind="hinted")
15 chi = Cpt(EpicsMotor, "m31", kind="hinted")
16 phi = Cpt(EpicsMotor, "m32", kind="hinted")
17 tth = Cpt(EpicsMotor, "m29", kind="hinted")
18
19fourc = FourCircle("PREFIX:", name="fourc")