Skip to content

Commit

Permalink
ENH #75 get all reflection details
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed Dec 30, 2020
1 parent 26233b0 commit aa3de49
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
6 changes: 5 additions & 1 deletion hkl/diffract.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,14 @@ class (using `calc_kw`) to instantiate a new one.
doc='Sample lattice')
lattice_reciprocal = Cpt(AttributeSignal, attr='calc.sample.reciprocal',
doc='Reciprocal lattice')

U = Cpt(AttributeSignal, attr='calc.sample.U', doc='U matrix')
UB = Cpt(AttributeSignal, attr='calc.sample.UB', doc='UB matrix')
reflections = Cpt(ArrayAttributeSignal, attr='calc.sample.reflections',
doc='Reflections')
reflections_details = Cpt(AttributeSignal,
attr='calc.sample.reflections_details',
doc='Details of reflections')
ux = Cpt(AttributeSignal, attr='calc.sample.ux.value',
doc='ux portion of the U matrix')
uy = Cpt(AttributeSignal, attr='calc.sample.uy.value',
Expand Down Expand Up @@ -170,7 +174,7 @@ def __init__(self, prefix, calc_kw=None, decision_fcn=None,
)

if configuration_attrs is None:
configuration_attrs = ["UB", "energy"]
configuration_attrs = ["UB", "energy", "reflections_details"]

if decision_fcn is None:
# the default decision function is to just grab solution #1:
Expand Down
25 changes: 25 additions & 0 deletions hkl/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,3 +385,28 @@ def __str__(self):
info.append('reflection_theoretical_angles={!r}'.format(self.reflection_theoretical_angles))
return '{}({})'.format(self.__class__.__name__,
', '.join(info))

def _get_reflection_dict(self, refl):
"""Return dictionary with detailds for the reflection."""
h, k, l = refl.hkl_get()
flag = refl.flag_get()
geom = refl.geometry_get()
wavelength = geom.wavelength_get(1)
pos = {
k: v
for k, v in zip(geom.axis_names_get(), geom.axis_values_get(1))
}
return dict(
reflection=dict(h=h, k=k, l=l),
flag=flag,
wavelength=wavelength,
position=pos
)

@property
def reflections_details(self):
"""Return a list with details of all reflections."""
return [
self._get_reflection_dict(r)
for r in self._sample.reflections_get()
]

0 comments on commit aa3de49

Please sign in to comment.