reflection#
Import: ad_hoc_diffractometer.reflection
A Reflection stores the Miller indices (hkl), the diffractometer motor angles at which the reflection was observed, the wavelength used, and the name of the geometry on which it was recorded.
A ReflectionList owns an ordered dict of named Reflection objects and
manages the primary (or1) and secondary (or2) orienting designations.
It is held as AdHocDiffractometer.reflections.
Typical usage:
g = psic()
rl = g.reflections # ReflectionList
r1 = rl.add("r1", hkl=(1, 0, 0),
angles={"mu": 0, "eta": 20, ...},
valid_stages=set(g._stages))
r2 = rl.add("r2", hkl=(0, 1, 0), ...)
rl.setor0("r1")
rl.setor1("r2")
rl.orienting_reflections # -> [r1, r2]
rl["r1"] # -> r1
del rl["r1"]
rl.clear()
Classes#
One observed reflection used for diffractometer orientation. |
|
Ordered, named collection of Reflection objects with or1/or2 management. |
Module Contents#
- class ad_hoc_diffractometer.reflection.Reflection[source]#
Import:
ad_hoc_diffractometer.reflection.ReflectionOne observed reflection used for diffractometer orientation.
- Parameters:
name (str) – User-supplied label (e.g.
"r1","Si_111"). Set byReflectionList.add().hkl (tuple of float) – Miller indices (h, k, l). Need not be integers.
angles (dict[str, float]) – Motor angles (degrees) keyed by stage name. Keys are specific to the geometry named in
geometry_nameand are validated byReflectionList.add()before the reflection is stored.wavelength (float or None) – Wavelength in Å. If None the geometry’s wavelength is assumed.
geometry_name (str or None) – Name of the geometry on which this reflection was recorded. Angle keys are only meaningful for that geometry.
Notes
Reflections are geometry-specific: angle keys from a
psicgeometry cannot be applied tokappa6cbecause the stage names differ.ReflectionList.add()validates keys and recordsgeometry_nameso cross-geometry misuse can be detected.- classmethod from_dict(d: dict) Reflection[source]#
Reconstruct a
Reflectionfrom a dict produced byto_dict().- Parameters:
d (dict) – Must contain
"name","hkl","angles"."wavelength"and"geometry_name"are optional (defaultNone).- Return type:
- class ad_hoc_diffractometer.reflection.ReflectionList(geometry_name: str, valid_stages: set[str])[source]#
Import:
ad_hoc_diffractometer.reflection.ReflectionListOrdered, named collection of Reflection objects with or1/or2 management.
Held as
AdHocDiffractometer.reflections. All mutation methods validate that angle keys belong to the owning geometry.- Parameters:
Examples
>>> rl = ReflectionList(geometry_name="psic", ... valid_stages={"mu", "eta", "chi", "phi", ... "nu", "delta"}) >>> r = rl.add("r1", hkl=(1, 0, 0), angles={"mu": 0, "eta": 20}) >>> rl.setor0("r1") >>> rl.orienting_reflections [Reflection(name='r1', ...)]
- _resolve(reflection: str | Reflection) str[source]#
Return the name of a reflection given a name or object.
- add(name: str, hkl: tuple[float, float, float], angles: dict[str, float], wavelength: float | None = None) Reflection[source]#
Add a named reflection, validate angle keys, and return it.
- Parameters:
- Raises:
ValueError – If
namealready exists or any angle key is not a valid stage.
- classmethod from_dict(d: dict) ReflectionList[source]#
Reconstruct a
ReflectionListfrom a dict produced byto_dict().- Parameters:
d (dict) – Must contain
"reflections"(list of reflection dicts)."geometry_name","or1", and"or2"are optional.- Return type:
- geometry_name#
- property orienting_reflections: list[Reflection]#
Ordered list of designated orienting reflections.
Returns
[],[or1], or[or1, or2]. A secondary without a primary is returned as a single-element list containing the secondary.
- remove(name: str) None[source]#
Remove the named reflection and clear any or1/or2 designation it held.
- Raises:
KeyError – If no reflection with that name exists.
- setor0(reflection: str | Reflection) None[source]#
Designate a reflection as primary (or1 slot, SPEC
setor0).If it was previously the secondary (or2), that designation is cleared. The previous or1 remains in the list without any designation.
- setor1(reflection: str | Reflection) None[source]#
Designate a reflection as secondary (or2 slot, SPEC
setor1).If it was previously the primary (or1), that designation is cleared. The previous or2 remains in the list without any designation.
- to_dict() dict[source]#
Return a JSON-serialisable
dictrepresenting this reflection list.- Returns:
Keys:
"geometry_name"(str or None),"reflections"(list of reflection dicts in insertion order),"or1"(name str or None),"or2"(name str or None).- Return type:
- valid_stages#