Example #1
0
 def setup_method(self):
     self._geometry = SixCircleGammaOnArmGeometry()
     self.reflist = ReflectionList(self._geometry,
                                   ['a', 'd', 'g', 'o', 'c', 'p'])
     self.time = datetime.now()
     pos = Pos(0.1, 0.2, 0.3, 0.4, 0.5, 0.6)
     self.reflist.add_reflection(1, 2, 3, pos, 1000, "ref1", self.time)
     pos = Pos(0.11, 0.22, 0.33, 0.44, 0.55, 0.66)
     self.reflist.add_reflection(1.1, 2.2, 3.3, pos, 1100, "ref2",
                                 self.time)
Example #2
0
 def setup_method(self):
     self._geometry = SixCircleGammaOnArmGeometry()
     self.reflist = ReflectionList(self._geometry,
                                   ['a', 'd', 'g', 'o', 'c', 'p'])
     self.time = datetime.now()
     pos = Pos(0.1, 0.2, 0.3, 0.4, 0.5, 0.6)
     self.reflist.add_reflection(1, 2, 3, pos, 1000, "ref1", self.time)
     pos = Pos(0.11, 0.22, 0.33, 0.44, 0.55, 0.66)
     self.reflist.add_reflection(1.1, 2.2, 3.3, pos, 1100, "ref2", self.time)
Example #3
0
def decode_reflist(reflist_dict, geometry, diffractometer_axes_names, multiplier):
    reflections = []
    try:
        sorted_ref_keys = sorted(reflist_dict.keys(), key=int)
    except ValueError:
        logger.warning("Warning: Invalid index found in the stored list of reflections. "
                       "Please check the reflection list order.")
        sorted_ref_keys = sorted(reflist_dict.keys())
    for key in sorted_ref_keys:
        reflections.append(decode_reflection(reflist_dict[key], geometry))
        
    return ReflectionList(geometry, diffractometer_axes_names, reflections, multiplier)
Example #4
0
 def _clear(self, name=None):
     # NOTE the Diffraction calculator is expecting this object to exist in
     # the long run. We can't remove this entire object, and recreate it.
     # It also contains a required link to the angle calculator.
     reflist = ReflectionList(self._geometry,
                              self._get_diffractometer_axes_names())
     reference = YouReference(self._get_UB)
     self._state = UBCalcState(name=name,
                               reflist=reflist,
                               reference=reference)
     self._U = None
     self._UB = None
     self._state.configure_calc_type()
Example #5
0
 def _clear(self, name=None):
     # NOTE the Diffraction calculator is expecting this object to exist in
     # the long run. We can't remove this entire object, and recreate it.
     # It also contains a required link to the angle calculator.
     reflist = ReflectionList(
         settings.geometry,
         self._get_diffractometer_axes_names(),
         multiplier=settings.hardware.energyScannableMultiplierToGetKeV)
     orientlist = OrientationList(settings.geometry,
                                  self._get_diffractometer_axes_names())
     reference = YouReference(self._get_UB)
     reference._set_n_hkl_configured(settings.reference_vector)
     surface = YouReference(self._get_UB)
     surface._set_n_phi_configured(settings.surface_vector)
     self._state = UBCalcState(name=name,
                               reflist=reflist,
                               orientlist=orientlist,
                               reference=reference,
                               surface=surface)
     self._U = None
     self._UB = None
     self._state.configure_calc_type()
Example #6
0
class TestReflectionList(object):

    def setup_method(self):
        self._geometry = SixCircleGammaOnArmGeometry()
        self.reflist = ReflectionList(self._geometry,
                                      ['a', 'd', 'g', 'o', 'c', 'p'])
        self.time = datetime.now()
        pos = Pos(0.1, 0.2, 0.3, 0.4, 0.5, 0.6)
        self.reflist.add_reflection(1, 2, 3, pos, 1000, "ref1", self.time)
        pos = Pos(0.11, 0.22, 0.33, 0.44, 0.55, 0.66)
        self.reflist.add_reflection(1.1, 2.2, 3.3, pos, 1100, "ref2", self.time)

    def test_add_reflection(self):
        assert len(self.reflist) == 2

    def testGetReflection(self):
        answered = self.reflist.getReflection(1)
        pos = Pos(0.1, 0.2, 0.3, 0.4, 0.5, 0.6)
        desired = ([1, 2, 3], pos, 1000, "ref1", self.time)
        assert answered == desired

    def testRemoveReflection(self):
        self.reflist.removeReflection(1)
        answered = self.reflist.getReflection(1)
        pos = Pos(0.11, 0.22, 0.33, 0.44, 0.55, 0.66)
        desired = ([1.1, 2.2, 3.3], pos, 1100, "ref2", self.time)
        assert answered == desired

    def testedit_reflection(self):
        ps = Pos(0.1, 0.2, 0.3, 0.4, 0.5, 0.6)
        self.reflist.edit_reflection(1, 10, 20, 30, ps, 1000, "new1", self.time)
        assert (self.reflist.getReflection(1)
                == ([10, 20, 30], ps, 1000, "new1", self.time))
        pos = Pos(0.11, 0.22, 0.33, 0.44, 0.55, 0.66)
        assert (self.reflist.getReflection(2)
                == ([1.1, 2.2, 3.3], pos, 1100, "ref2", self.time))

    def testSwapReflection(self):
        self.reflist.swap_reflections(1, 2)
        pos = Pos(0.11, 0.22, 0.33, 0.44, 0.55, 0.66)
        assert (self.reflist.getReflection(1)
                == ([1.1, 2.2, 3.3], pos, 1100, "ref2", self.time))
        pos = Pos(0.1, 0.2, 0.3, 0.4, 0.5, 0.6)
        assert (self.reflist.getReflection(2)
                 == ([1, 2, 3], pos, 1000, "ref1", self.time))

    def createRefStateDicts(self):
        ref_0 = {
            'h': 1,
            'k': 2,
            'l': 3,
            'position': (0.1, 0.2, 0.3, 0.4, 0.5, 0.6),
            'energy': 1000,
            'tag': "ref1",
            'time': repr(self.time)
        }
        ref_1 = {
            'h': 1.1,
            'k': 2.2,
            'l': 3.3,
            'position': (0.11, 0.22, 0.33, 0.44, 0.55, 0.66),
            'energy': 1100,
            'tag': "ref2",
            'time': repr(self.time)
        }
        return ref_0, ref_1
Example #7
0
def decode_reflist(reflist_dict, geometry, diffractometer_axes_names):
    reflections = []
    for key in sorted(reflist_dict.keys()):
        reflections.append(decode_reflection(reflist_dict[key], geometry))
        
    return ReflectionList(geometry, diffractometer_axes_names, reflections)
Example #8
0
class TestReflectionList(object):
    def setup_method(self):
        self._geometry = SixCircleGammaOnArmGeometry()
        self.reflist = ReflectionList(self._geometry,
                                      ['a', 'd', 'g', 'o', 'c', 'p'])
        self.time = datetime.now()
        pos = Pos(0.1, 0.2, 0.3, 0.4, 0.5, 0.6)
        self.reflist.add_reflection(1, 2, 3, pos, 1000, "ref1", self.time)
        pos = Pos(0.11, 0.22, 0.33, 0.44, 0.55, 0.66)
        self.reflist.add_reflection(1.1, 2.2, 3.3, pos, 1100, "ref2",
                                    self.time)

    def test_add_reflection(self):
        assert len(self.reflist) == 2

    def testGetReflection(self):
        answered = self.reflist.getReflection(1)
        pos = Pos(0.1, 0.2, 0.3, 0.4, 0.5, 0.6)
        desired = ([1, 2, 3], pos, 1000, "ref1", self.time)
        assert answered == desired

    def testRemoveReflection(self):
        self.reflist.removeReflection(1)
        answered = self.reflist.getReflection(1)
        pos = Pos(0.11, 0.22, 0.33, 0.44, 0.55, 0.66)
        desired = ([1.1, 2.2, 3.3], pos, 1100, "ref2", self.time)
        assert answered == desired

    def testedit_reflection(self):
        ps = Pos(0.1, 0.2, 0.3, 0.4, 0.5, 0.6)
        self.reflist.edit_reflection(1, 10, 20, 30, ps, 1000, "new1",
                                     self.time)
        assert (self.reflist.getReflection(1) == ([10, 20, 30], ps, 1000,
                                                  "new1", self.time))
        pos = Pos(0.11, 0.22, 0.33, 0.44, 0.55, 0.66)
        assert (self.reflist.getReflection(2) == ([1.1, 2.2, 3.3], pos, 1100,
                                                  "ref2", self.time))

    def testSwapReflection(self):
        self.reflist.swap_reflections(1, 2)
        pos = Pos(0.11, 0.22, 0.33, 0.44, 0.55, 0.66)
        assert (self.reflist.getReflection(1) == ([1.1, 2.2, 3.3], pos, 1100,
                                                  "ref2", self.time))
        pos = Pos(0.1, 0.2, 0.3, 0.4, 0.5, 0.6)
        assert (self.reflist.getReflection(2) == ([1, 2, 3], pos, 1000, "ref1",
                                                  self.time))

    def createRefStateDicts(self):
        ref_0 = {
            'h': 1,
            'k': 2,
            'l': 3,
            'position': (0.1, 0.2, 0.3, 0.4, 0.5, 0.6),
            'energy': 1000,
            'tag': "ref1",
            'time': repr(self.time)
        }
        ref_1 = {
            'h': 1.1,
            'k': 2.2,
            'l': 3.3,
            'position': (0.11, 0.22, 0.33, 0.44, 0.55, 0.66),
            'energy': 1100,
            'tag': "ref2",
            'time': repr(self.time)
        }
        return ref_0, ref_1