sample

class hkl.sample.HklSample(calc, sample=None, units='user', **kwargs)

Represents a sample in diffractometer calculations

Parameters
  • calc (instance of CalcRecip) – Reciprocal space calculation class

  • name (str) – A user-defined name used to refer to the sample

  • sample (Hkl.Sample, optional) – A Sample instance from the wrapped Hkl library. Created automatically if not specified.

  • units ({'user', 'default'}) – Units to use

  • lattice (np.ndarray, optional) – The lattice

  • U (np.ndarray, optional) – The crystal orientation matrix, U

  • UB (np.ndarray, optional) – The UB matrix, where U is the crystal orientation matrix and B is the transition matrix of a non-orthonormal (the reciprocal of the crystal) in an orthonormal system

  • ux (np.ndarray, optional) – ux part of the U matrix

  • uy (np.ndarray, optional) – uy part of the U matrix

  • uz (np.ndarray, optional) – uz part of the U matrix

  • reflections

    All reflections for the current sample in the form:

    [(h, k, l), ...]
    

    This assumes the hkl engine is used; generally, the ordered set of positions for the engine in-use should be specified.

property U

The crystal orientation matrix, U

property UB

The UB matrix, where U is the crystal orientation matrix and B is the transition matrix of a non-orthonormal (the reciprocal of the crystal) in an orthonormal system

If written to, the B matrix will be kept constant:

U * B = UB -> U = UB * B^-1

add_reflection(h, k, l, position=None, detector=None, compute_ub=False)

Add a reflection, optionally specifying the detector to use

Parameters
  • h (float) – Reflection h

  • k (float) – Reflection k

  • l (float) – Reflection l

  • detector (Hkl.Detector, optional) – The detector

  • position (tuple or namedtuple, optional) – The physical motor position that this reflection corresponds to If not specified, the current geometry of the calculation engine is assumed.

  • compute_ub (bool, optional) – Calculate the UB matrix with the last two reflections

affine()

Make the sample transform affine

clear_reflections()

Clear all reflections for the current sample

compute_UB(r1, r2)

Compute the UB matrix with two reflections

Using the Busing and Levy method, compute the UB matrix for two sample reflections, r1 and r2.

Note that this modifies the internal state of the sample and does not return a UB matrix. To access it after computation, see Sample.UB.

Parameters
  • r1 (HklReflection) – Reflection 1

  • r2 (HklReflection) – Reflection 2

property hkl_calc

The HklCalc instance associated with the sample

property hkl_sample

The HKL library sample object

property lattice

The lattice (a, b, c, alpha, beta, gamma)

a, b, c [nm] alpha, beta, gamma [deg]

property name

The name of the currently selected sample

property reciprocal

The reciprocal lattice

property reflections

All reflections for the current sample in the form: [(h, k, l), …]

remove_reflection(refl)

Remove a specific reflection

property ux

ux part of the U matrix

property uy

uy part of the U matrix

property uz

uz part of the U matrix

hkl.sample.check_lattice(lattice)

Check an Hkl.Lattice for validity

Raises

ValueError