diffcalc.ub.reference

Module providing objects for working with reference reflections and orientations.

Classes

Orientation(h, k, l, x, y, z, pos, tag)

Class containing reference orientation information.

OrientationList([orientations])

Class containing collection of reference orientations.

Reflection(h, k, l, pos, energy, tag)

Class containing reference reflection information.

ReflectionList([reflections])

Class containing collection of reference reflections.

class diffcalc.ub.reference.Reflection(h: float, k: float, l: float, pos: Position, energy: float, tag: str)[source]

Class containing reference reflection information.

h

h miller index.

Type

float

k

k miller index.

Type

float

l

l miller index.

Type

float

pos

Diffractometer position object.

Type

Position

energy

Beam energy in keV.

Type

float

tag

Identifying tag for the reflection.

Type

str

Attributes
asdict

Serialise the object into a JSON compatible dictionary.

astuple

Return reference reflection data as tuple.

Methods

fromdict(data)

Construct Reflection instance from a JSON compatible dictionary.

h: float
k: float
l: float
pos: Position
energy: float
tag: str
property astuple: Tuple[Tuple[float, float, float], Tuple[float, float, float, float, float, float], float, str]

Return reference reflection data as tuple.

Returns

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

float, str]

Tuple containing miller indices, position object, energy and reflection tag.

Return type

Tuple[Tuple[float, float, float],

property asdict: Dict[str, Any]

Serialise the object into a JSON compatible dictionary.

Returns

Dictionary containing properties of this class. Can be unpacked to recreate the object using fromdict class method.

Return type

Dict[str, Any]

classmethod fromdict(data: Dict[str, Any]) Reflection[source]

Construct Reflection instance from a JSON compatible dictionary.

Parameters

data (Dict[str, Any]) – Dictionary containing properties of reflection class, must have the equivalent structure of asdict property above.

Returns

Instance of this class created from the dictionary.

Return type

Reflection

class diffcalc.ub.reference.ReflectionList(reflections=None)[source]

Class containing collection of reference reflections.

reflections

List containing reference reflections.

Type

List[Reflection]

Attributes
asdict

Serialise the object into a JSON compatible dictionary.

Methods

add_reflection(hkl, pos, energy, tag)

Add a reference reflection.

edit_reflection(idx, hkl, pos, energy, tag)

Change a reference reflection.

fromdict(data)

Construct ReflectionList instance from a JSON compatible dictionary.

get_reflection(idx)

Get a reference reflection.

get_tag_index(tag)

Get a reference reflection index.

remove_reflection(idx)

Delete a reference reflection.

swap_reflections(idx1, idx2)

Swap indices of two reference reflections.

get_tag_index(tag: str) int[source]

Get a reference reflection index.

Get a reference reflection index for the provided reflection tag.

Parameters

tag (str) – Identifying tag for the reflection.

Returns

The reference reflection index.

Return type

int

Raises

ValueError – If tag not found in reflection list.

add_reflection(hkl: Tuple[float, float, float], pos: Position, energy: float, tag: str) None[source]

Add a reference reflection.

Adds a reference reflection object to the reflection list.

Parameters
  • hkl (Tuple[float, float, float]) – Miller indices of the reflection.

  • pos (Position) – Object representing diffractometer angles.

  • energy (float) – Energy of the x-ray beam.

  • tag (str) – Identifying tag for the reflection.

edit_reflection(idx: Union[str, int], hkl: Tuple[float, float, float], pos: Position, energy: float, tag: str) None[source]

Change a reference reflection.

Changes the reference reflection object in the reflection list.

Parameters
  • idx (Union[str, int]) – Index or tag of the reflection to be changed.

  • hkl (Tuple[float,float,float]) – Miller indices of the reflection.

  • position (Position) – Object representing diffractometer angles.

  • energy (float) – Energy of the x-ray beam.

  • tag (str) – Identifying tag for the reflection.

Raises
  • ValueError – Reflection with specified tag not found.

  • IndexError – Reflection with specified index not found.

get_reflection(idx: Union[str, int]) Reflection[source]

Get a reference reflection.

Get an object representing reference reflection.

Parameters

idx (Union[str, int]) – Index or tag of the reflection.

Returns

Object representing reference reflection.

Return type

Reflection

Raises
  • ValueError – Reflection with the requested index/tan not present.

  • IndexError – Reflection with specified index not found.

remove_reflection(idx: Union[str, int]) None[source]

Delete a reference reflection.

Parameters

idx (Union[str, int]) – Index or tag of the deleted reflection.

Raises
  • ValueError – Reflection with the requested index/tag not present.

  • IndexError – Reflection with specified index not found.

swap_reflections(idx1: Union[str, int], idx2: Union[str, int]) None[source]

Swap indices of two reference reflections.

Parameters
  • idx1 (Union[str, int]) – Index or tag of the first reflection to be swapped.

  • idx2 (Union[str, int]) – Index or tag of the second reflection to be swapped.

Raises
  • ValueError – Reflection with the requested index/tag not present.

  • IndexError – Reflection with specified index not found.

property asdict: List[Dict[str, Any]]

Serialise the object into a JSON compatible dictionary.

Returns

Dictionary containing properties of this class. Can be unpacked to recreate this object using fromdict class method below.

Return type

Dict[str, Any]

classmethod fromdict(data: List[Dict[str, Any]]) ReflectionList[source]

Construct ReflectionList instance from a JSON compatible dictionary.

Parameters

data (Dict[str, Any]) – Dictionary containing properties of this class, must have the equivalent structure of asdict property above.

Returns

Instance of this class created from the dictionary.

Return type

ReflectionList

class diffcalc.ub.reference.Orientation(h: float, k: float, l: float, x: float, y: float, z: float, pos: Position, tag: str)[source]

Class containing reference orientation information.

h

h miller index.

Type

float

k

k miller index.

Type

float

l

l miller index.

Type

float

x

x coordinate in laboratory system.

Type

float

y

y coordinate in laboratory system.

Type

float

z

z coordinate in laboratory system.

Type

float

pos

Diffractometer position object.

Type

Position

tag

Identifying tag for the orientation.

Type

str

Attributes
asdict

Serialise the object into a JSON compatible dictionary.

astuple

Return reference orientation data as tuple.

Methods

fromdict(data)

Construct Orientation instance from a JSON compatible dictionary.

h: float
k: float
l: float
x: float
y: float
z: float
pos: Position
tag: str
property astuple: Tuple[Tuple[float, float, float], Tuple[float, float, float], Tuple[float, float, float, float, float, float], str]

Return reference orientation data as tuple.

Returns

Tuple[float, float, float],

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

Tuple containing miller indices, laboratory frame coordinates, position object and orientation tag.

Return type

Tuple[Tuple[float, float, float],

property asdict: Dict[str, Any]

Serialise the object into a JSON compatible dictionary.

Returns

Dictionary containing properties of this class. Can be unpacked to recreate this object using fromdict class method below.

Return type

Dict[str, Any]

classmethod fromdict(data: Dict[str, Any]) Orientation[source]

Construct Orientation instance from a JSON compatible dictionary.

Parameters

data (Dict[str, Any]) – Dictionary containing properties of this class, must have the equivalent structure to the asdict property.

Returns

Instance of this class created from the dictionary.

Return type

Orientation

class diffcalc.ub.reference.OrientationList(orientations=None)[source]

Class containing collection of reference orientations.

reflections

List containing reference orientations.

Type

List[Orientation]

Attributes
asdict

Serialise the object into a JSON compatible dictionary.

Methods

add_orientation(hkl, xyz, pos, tag)

Add a reference orientation.

edit_orientation(idx, hkl, xyz, pos, tag)

Change a reference orientation.

fromdict(data)

Construct OrientationList instance from a JSON compatible dictionary.

get_orientation(idx)

Get a reference orientation.

get_tag_index(tag)

Get a reference orientation index.

remove_orientation(idx)

Delete a reference orientation.

swap_orientations(idx1, idx2)

Swap indices of two reference orientations.

get_tag_index(tag: str) int[source]

Get a reference orientation index.

Get a reference orientation index for the provided orientation tag.

Parameters

tag (str) – Identifying tag for the orientation

Returns

The reference orientation index.

Return type

int

Raises

ValueError – If tag not found in orientations list.

add_orientation(hkl: Tuple[float, float, float], xyz: Tuple[float, float, float], pos: Position, tag: str) None[source]

Add a reference orientation.

Adds a reference orientation in the external diffractometer coordinate system.

Parameters
  • hkl (Tuple[float, float, float]) – Miller index of the reference orientation.

  • xyz (Tuple[float, float, float]) – Laboratory frame coordinates of the reference orientation.

  • position (Position) – Object representing diffractometer position.

  • tag (str) – Identifying tag for the orientation.

edit_orientation(idx: Union[str, int], hkl: Tuple[float, float, float], xyz: Tuple[float, float, float], pos: Position, tag: str) None[source]

Change a reference orientation.

Changes a reference orientation in the external diffractometer coordinate system.

Parameters
  • idx (str or int) – Index or tag of the orientation to be changed.

  • hkl (Tuple[float, float, float]) – Miller indices of the reference orientation.

  • xyz (:Tuple[float, float, float]) – Laboratory frame coordinates of the reference orientation.

  • pos (Position) – Object representing diffractometer position.

  • tag (str) – Identifying tag for the orientation.

Raises
  • ValueError – Orientation with specified tag not found.

  • IndexError – Orientation with specified index not found.

get_orientation(idx: Union[str, int]) Orientation[source]

Get a reference orientation.

Get an object representing reference orientation.

Parameters

idx (Union[str, int]) – Index or tag of the orientation.

Returns

Object representing reference orientation.

Return type

Orientation

Raises
  • ValueError – Orientation with the requested index/tag not present.

  • IndexError – Orientation with specified index not found.

remove_orientation(idx: Union[str, int]) None[source]

Delete a reference orientation.

Parameters

idx (Union[str, int]) – Index or tag of the deleted orientation.

Raises
  • ValueError – Orientation with the requested index/tag not present.

  • IndexError – Orientation with specified index not found.

swap_orientations(idx1: Union[str, int], idx2: Union[str, int]) None[source]

Swap indices of two reference orientations.

Parameters
  • idx1 (Union[str, int]) – Index or tag of the first orientation to be swapped.

  • idx2 (Union[str, int]) – Index or tag of the second orientation to be swapped.

Raises
  • ValueError – Orientation with the requested index/tag not present.

  • IndexError – Orientation with specified index not found.

property asdict: List[Dict[str, Any]]

Serialise the object into a JSON compatible dictionary.

Returns

Dictionary containing properties of this class. Can be unpacked to recreate this object using fromdict class method below.

Return type

Dict[str, Any]

classmethod fromdict(data: List[Dict[str, Any]]) OrientationList[source]

Construct OrientationList instance from a JSON compatible dictionary.

Parameters

data (Dict[str, Any]) – Dictionary containing properties of this class, must have the equivalent structure to the asdict property.

Returns

Instance of this class created from the dictionary.

Return type

OrientationList