diffcalc.hkl.geometry

Module providing diffractometer position definition and rotation matrices.

Diffractometer axes and rotation matrix definitions are following conventions described in [1].

References

1

H. You. “Angle calculations for a ‘4S+2D’ six-circle diffractometer” J. Appl. Cryst. (1999). 32, 614-623.

Functions

get_q_phi(pos)

Calculate scattering vector in laboratory frame.

get_rotation_matrices(pos)

Create rotation matrices corresponding to the diffractometer axes.

rot_CHI(chi)

Return rotation matrix corresponding to chi axis.

rot_DELTA(delta)

Return rotation matrix corresponding to delta axis.

rot_ETA(eta)

Return rotation matrix corresponding to eta axis.

rot_MU(mu_or_alpha)

Return rotation matrix corresponding to mu axis.

rot_NU(nu)

Return rotation matrix corresponding to nu axis.

rot_PHI(phi)

Return rotation matrix corresponding to phi axis.

Classes

Position([mu, delta, nu, eta, chi, phi, ...])

Class representing diffractometer orientation.

class diffcalc.hkl.geometry.Position(mu: float = 0.0, delta: float = 0.0, nu: float = 0.0, eta: float = 0.0, chi: float = 0.0, phi: float = 0.0, indegrees: bool = True)[source]

Class representing diffractometer orientation.

Diffractometer orientation corresponding to (4+2) geometry defined in H. You paper (add reference)

fields

Tuple with angle names

Type

Tuple[str, str, str, str, str, str]

mu

mu angle value

Type

float, default = 0.0

delta

delta angle value

Type

float, default = 0.0

nu

nu angle value

Type

float, default = 0.0

eta

eta angle value

Type

float, default = 0.0

chi

chi angle value

Type

float, default = 0.0

phi

phi angle value

Type

float, default = 0.0

indegrees

If True, arguments are angles in degrees.

Type

bool, default = True

Attributes
asdict

Return dictionary of diffractometer angles.

astuple

Return tuple of diffractometer angles.

chi

Value of of chi angle.

delta

Value of of delta angle.

eta

Value of of eta angle.

mu

Value of of mu angle.

nu

Value of of nu angle.

phi

Value of of phi angle.

Methods

asdegrees(pos)

Create new Position object with angles in degrees.

asradians(pos)

Create new Position object with angles in radians.

fields: Tuple[str, str, str, str, str, str] = ('mu', 'delta', 'nu', 'eta', 'chi', 'phi')
classmethod asdegrees(pos: Position) Position[source]

Create new Position object with angles in degrees.

Parameters

pos (Position) – Input Position object

Returns

New Position object with angles in degrees.

Return type

Position

classmethod asradians(pos: Position) Position[source]

Create new Position object with angles in radians.

Parameters

pos (Position) – Input Position object

Returns

New Position object with angles in radians.

Return type

Position

property mu: Optional[float]

Value of of mu angle.

property delta: Optional[float]

Value of of delta angle.

property nu: Optional[float]

Value of of nu angle.

property eta: Optional[float]

Value of of eta angle.

property chi: Optional[float]

Value of of chi angle.

property phi: Optional[float]

Value of of phi angle.

property asdict: Dict[str, float]

Return dictionary of diffractometer angles.

Returns

Dictionary of axis names and angle values.

Return type

Dict[str, float]

property astuple: Tuple[float, float, float, float, float, float]

Return tuple of diffractometer angles.

Returns

Tuple of angle values.

Return type

Tuple[float, float, float, float, float, float]

diffcalc.hkl.geometry.get_rotation_matrices(pos: Position) Tuple[ndarray, ndarray, ndarray, ndarray, ndarray, ndarray][source]

Create rotation matrices corresponding to the diffractometer axes.

Parameters

pos (Position) – Position object containing set of diffractometer angles

Returns

np.ndarray, np.ndarray, np.ndarray, np.ndarray] Tuple containing set of rotation matrices corresponding to input diffractometer angle values.

Return type

Tuple[np.ndarray, np.ndarray,

diffcalc.hkl.geometry.rot_NU(nu: float) ndarray[source]

Return rotation matrix corresponding to nu axis.

Parameters
  • nu (float) –

  • angle (nu axis) –

Returns

Rotation matrix as a NumPy array.

Return type

np.ndarray

diffcalc.hkl.geometry.rot_DELTA(delta: float) ndarray[source]

Return rotation matrix corresponding to delta axis.

Parameters
  • delta (float) –

  • angle (delta axis) –

Returns

Rotation matrix as a NumPy array.

Return type

np.ndarray

diffcalc.hkl.geometry.rot_MU(mu_or_alpha: float) ndarray[source]

Return rotation matrix corresponding to mu axis.

Parameters
  • mu (float) –

  • angle (mu axis) –

Returns

Rotation matrix as a NumPy array.

Return type

np.ndarray

diffcalc.hkl.geometry.rot_ETA(eta: float) ndarray[source]

Return rotation matrix corresponding to eta axis.

Parameters
  • eta (float) –

  • angle (eta axis) –

Returns

Rotation matrix as a NumPy array.

Return type

np.ndarray

diffcalc.hkl.geometry.rot_CHI(chi: float) ndarray[source]

Return rotation matrix corresponding to chi axis.

Parameters
  • chi (float) –

  • angle (chi axis) –

Returns

Rotation matrix as a NumPy array.

Return type

np.ndarray

diffcalc.hkl.geometry.rot_PHI(phi: float) ndarray[source]

Return rotation matrix corresponding to phi axis.

Parameters
  • phi (float) –

  • angle (phi axis) –

Returns

Rotation matrix as a NumPy array.

Return type

np.ndarray

diffcalc.hkl.geometry.get_q_phi(pos: Position) ndarray[source]

Calculate scattering vector in laboratory frame.

Calculate hkl in the phi frame in units of 2 * pi / lambda.

Parameters

pos (object) – Diffractometer angles in radians.

Returns

Scattering vector coordinates corresponding to the input position.

Return type

matrix