Diffractometer creator#

The creator(), a factory function, reduces the effort to create all but the most complex diffractometer objects. It uses the diffractometer_class_factory() to build the Python class for the chosen Solver and geometry. Here’s an example 6-circle diffractometer in kappa geometry with simulated motors:

k6c = hklpy2.creator(name="k6c", solver="hkl_soleil", geometry="K6C")

Tip

It’s always possible to define your own subclass of DiffractometerBase() when you need more control than provided by creator(). See Example 4-circle diffractometer custom Python class.

The diffractometer_class_factory() gets information (the pseudo and real axes) from the Solver about the requested geometry, then constructs a Python class with this structure. The class includes ophyd.EpicsMotor Components when EPICS PVs are provided for the real axes, otherwise ophyd.SoftPositioner (simulated motor) Components are used. Names for these Components, when provided by the caller are mapped in order to the reals expected by the Solver. All real axis name conversion between user-provided and Solver-defined is handled in the Core Operations.

Another factory, solver_factory(), locates if the selected Solver has been installed and then creates an instance of the corresponding SolverBase subclass with the selected geometry and any additional keyword arguments provided by the caller.

Tip

hklpy2 is extensible. A new Solver can be added to the Python environment using the "hklpy2.solver" entry point. (See Solvers for more details.)

Examples

See Examples for many documents which use the creator() factory function. Here’s a sampler:

diffractometer description

example

simple

hkl_soleil E4CV

geometry

hkl_soleil K4CV

solver

Demonstrate hklpy2’s API

engine (via solver_kwargs)

Use E4CV’s $Q$ calculation engine

EPICS PVs

hkl_soleil E4CV with EPICS motors

renamed axes

NSLS-II tardis diffractometer

additional reals

hkl_soleil E6C psi axis

auto assign

tbd

reals out of order

tbd

extras

hkl_soleil E6C psi axis