Skip to content

Commit

Permalink
ENH #75 note UB reflections
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed Dec 31, 2020
1 parent d585159 commit f011d43
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions hkl/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ def __init__(self, calc, sample=None, units='user', **kwargs):
except KeyError:
raise ValueError('Invalid unit type')

# List of reflections used in computing the U & UB matrices.
# If UB is computed by refinement of more than two reflections,
# the code that sets that up will also need to manage this list.
self._orientation_reflections = []

for name in ('lattice', 'name', 'U', 'UB', 'ux', 'uy', 'uz',
'reflections', ):
value = kwargs.pop(name, None)
Expand Down Expand Up @@ -194,6 +199,7 @@ def U(self):

@U.setter
def U(self, new_u):
self._orientation_reflections = []
self._sample.U_set(util.to_hkl(new_u))

def _get_parameter(self, param):
Expand Down Expand Up @@ -234,6 +240,7 @@ def UB(self):

@UB.setter
def UB(self, new_ub):
self._orientation_reflections = []
self._sample.UB_set(util.to_hkl(new_ub))

def _create_reflection(self, h, k, l, detector=None):
Expand Down Expand Up @@ -262,6 +269,7 @@ def compute_UB(self, r1, r2):
r2 : HklReflection
Reflection 2
'''
self._orientation_reflections = [r1, r2]
return self._sample.compute_UB_busing_levy(r1, r2)

@property
Expand All @@ -275,6 +283,7 @@ def reflections(self):
@reflections.setter
def reflections(self, refls):
self.clear_reflections()
self._orientation_reflections = []
for refl in refls:
self.add_reflection(*refl)

Expand Down Expand Up @@ -329,9 +338,9 @@ def remove_reflection(self, refl):

def clear_reflections(self):
'''Clear all reflections for the current sample'''
reflections = self._sample.reflections_get()
for refl in reflections:
for refl in self._sample.reflections_get():
self._sample.del_reflection(refl)
self._orientation_reflections = []

def _refl_matrix(self, fcn):
'''
Expand Down Expand Up @@ -387,20 +396,21 @@ def __str__(self):
', '.join(info))

def _get_reflection_dict(self, refl):
"""Return dictionary with detailds for the reflection."""
"""Return dictionary with reflection details."""
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
flag=refl.flag_get(),
wavelength=geom.wavelength_get(1),
position={
k: v
for k, v in zip(
geom.axis_names_get(),
geom.axis_values_get(1)
)
},
orientation_reflection=refl in self._orientation_reflections
)

@property
Expand Down

0 comments on commit f011d43

Please sign in to comment.