def setup_method(self):
     self._geometry = SixCircle()
     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, 'DEG')
     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, 'DEG')
     self.reflist.add_reflection(1.1, 2.2, 3.3, pos, 1100, "ref2",
                                 self.time)
Esempio n. 2
0
 def setup_method(self):
     self._geometry = SixCircle()
     self.orientlist = OrientationList(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, 'DEG')
     self.orientlist.add_orientation(1, 2, 3, 0.1, 0.2, 0.3, pos, "orient1",
                                     self.time)
     pos = Pos(0.11, 0.22, 0.33, 0.44, 0.55, 0.66, 'DEG')
     self.orientlist.add_orientation(1.1, 2.2, 3.3, 0.11, 0.12, 0.13, pos,
                                     "orient2", 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, 'DEG')
     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, 'DEG')
     assert (self.reflist.getReflection(2) == ([1, 2, 3], pos, 1000, "ref1",
                                               self.time))
     self.reflist.swap_reflections("ref1", "ref2")
     pos = Pos(0.11, 0.22, 0.33, 0.44, 0.55, 0.66, 'DEG')
     assert (self.reflist.getReflection(2) == ([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, 'DEG')
     assert (self.reflist.getReflection(1) == ([1, 2, 3], pos, 1000, "ref1",
                                               self.time))
Esempio n. 4
0
 def testGetOrientation(self):
     pos = Pos(0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 'DEG')
     answered = self.orientlist.getOrientation(1)
     desired = ([1, 2, 3], [0.1, 0.2, 0.3], pos, "orient1", self.time)
     assert answered == desired
     answered = self.orientlist.getOrientation("orient1")
     assert answered == desired
 def testGetReflection(self):
     answered = self.reflist.getReflection(1)
     pos = Pos(0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 'DEG')
     desired = ([1, 2, 3], pos, 1000, "ref1", self.time)
     assert answered == desired
     answered = self.reflist.getReflection('ref1')
     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, 'DEG')
     desired = ([1.1, 2.2, 3.3], pos, 1100, "ref2", self.time)
     assert answered == desired
     self.reflist.removeReflection("ref2")
     assert self.reflist._reflist == []
Esempio n. 7
0
 def makes_cases(self, zrot, yrot):
     self.zrot = zrot
     self.yrot = yrot
     self.wavelength = 1
     self.cases = (
         Pair(
             '100', (1, 0, 0),
             Pos(mu=30,
                 delta=0,
                 nu=60,
                 eta=0,
                 chi=90 + self.yrot,
                 phi=-180 + self.zrot)),
         Pair(
             '100-->001', (cos(4 * TORAD), 0, sin(4 * TORAD)),
             Pos(mu=30,
                 delta=0,
                 nu=60,
                 eta=0,
                 chi=90 - 4 + self.yrot,
                 phi=-180 + self.zrot)),
         Pair(
             '010', (0, 1, 0),
             Pos(mu=30, delta=0, nu=60, eta=0, chi=90,
                 phi=-90 + self.zrot)),  # no yrot as chi||q
         Pair(
             '001', (0, 0, 1),
             Pos(mu=30,
                 delta=0,
                 nu=60,
                 eta=0,
                 chi=0 - self.yrot,
                 phi=0 + self.zrot)),
         Pair(
             '001-->100', (cos(86 * TORAD), 0, sin(86 * TORAD)),
             Pos(mu=30,
                 delta=0,
                 nu=60,
                 eta=0,
                 chi=0 - 4 - self.yrot,
                 phi=0 + self.zrot)),
     )
     self.case_dict = {}
     for case in self.cases:
         self.case_dict[case.name] = case
Esempio n. 8
0
 def testRemoveOrientation(self):
     self.orientlist.removeOrientation(1)
     pos = Pos(0.11, 0.22, 0.33, 0.44, 0.55, 0.66, 'DEG')
     answered = self.orientlist.getOrientation(1)
     desired = ([1.1, 2.2, 3.3], [0.11, 0.12,
                                  0.13], pos, "orient2", self.time)
     assert answered == desired
     self.orientlist.removeOrientation("orient2")
     assert self.orientlist._orientlist == []
 def testedit_reflection(self):
     ps = Pos(0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 'DEG')
     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, 'DEG')
     assert (self.reflist.getReflection(2) == ([1.1, 2.2, 3.3], pos, 1100,
                                               "ref2", self.time))
     self.reflist.edit_reflection("ref2", 1.1, 2.2, 3.3, pos, 1100, "new2",
                                  self.time)
     assert (self.reflist.getReflection("new2") == ([1.1, 2.2,
                                                     3.3], pos, 1100,
                                                    "new2", self.time))
     self.reflist.edit_reflection("new2", 10, 20, 30, pos, 1100, "new1",
                                  self.time)
     assert (self.reflist.getReflection("new1") == ([10, 20, 30], ps, 1000,
                                                    "new1", self.time))
Esempio n. 10
0
 def testHkl100(self):
     hkl = (1, 0, 0)
     pos = Pos(mu=0,
               delta=89.42926563609406,
               nu=0,
               eta=134.71463281804702,
               chi=90,
               phi=-90)
     self._check_angles_to_hkl('100', 999, 999, hkl, pos, self.wavelength,
                               {})
     self._check_hkl_to_angles('100', 999, 999, hkl, pos, self.wavelength,
                               {})
Esempio n. 11
0
 def testHkl101(self):
     hkl = (1, 0, 1)
     pos = Pos(mu=0,
               delta=98.74666191021282,
               nu=0,
               eta=117.347760720783,
               chi=90,
               phi=-90)
     self._check_angles_to_hkl('101', 999, 999, hkl, pos, self.wavelength,
                               {})
     self._check_hkl_to_angles('101', 999, 999, hkl, pos, self.wavelength,
                               {})
Esempio n. 12
0
 def testSwapOrientation(self):
     self.orientlist.swap_orientations(1, 2)
     pos = Pos(0.11, 0.22, 0.33, 0.44, 0.55, 0.66, 'DEG')
     assert (self.orientlist.getOrientation(1) == ([1.1, 2.2, 3.3],
                                                   [0.11, 0.12, 0.13], pos,
                                                   "orient2", self.time))
     pos = Pos(0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 'DEG')
     assert (self.orientlist.getOrientation(2) == ([1, 2,
                                                    3], [0.1, 0.2,
                                                         0.3], pos,
                                                   "orient1", self.time))
     self.orientlist.swap_orientations("orient1", "orient2")
     pos = Pos(0.11, 0.22, 0.33, 0.44, 0.55, 0.66, 'DEG')
     assert (self.orientlist.getOrientation(2) == ([1.1, 2.2, 3.3],
                                                   [0.11, 0.12, 0.13], pos,
                                                   "orient2", self.time))
     pos = Pos(0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 'DEG')
     assert (self.orientlist.getOrientation(1) == ([1, 2,
                                                    3], [0.1, 0.2,
                                                         0.3], pos,
                                                   "orient1", self.time))
Esempio n. 13
0
 def testHkl001(self):
     hkl = (0, 0, 1)
     pos = Pos(mu=0,
               delta=33.07329403295449,
               nu=0,
               eta=16.536647016477247,
               chi=90,
               phi=-90)
     self._check_angles_to_hkl('001', 999, 999, hkl, pos, self.wavelength,
                               {})
     self._check_hkl_to_angles('001', 999, 999, hkl, pos, self.wavelength,
                               {})
Esempio n. 14
0
 def testedit_orientation(self):
     ps = Pos(0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 'DEG')
     self.orientlist.edit_orientation(1, 10, 20, 30, 1, 2, 3, ps, "new1",
                                      self.time)
     assert (self.orientlist.getOrientation(1) == ([10, 20, 30], [1, 2, 3],
                                                   ps, "new1", self.time))
     pos = Pos(0.11, 0.22, 0.33, 0.44, 0.55, 0.66, 'DEG')
     assert (self.orientlist.getOrientation(2) == ([1.1, 2.2, 3.3],
                                                   [0.11, 0.12, 0.13], pos,
                                                   "orient2", self.time))
     self.orientlist.edit_orientation("orient2", 1.1, 2.2, 3.3, 1.11, 1.12,
                                      1.13, pos, "new2", self.time)
     assert (self.orientlist.getOrientation("new2") == ([1.1, 2.2, 3.3],
                                                        [1.11, 1.12,
                                                         1.13], pos, "new2",
                                                        self.time))
     self.orientlist.edit_orientation("new2", 1.1, 2.2, 3.3, 1.11, 1.12,
                                      1.13, pos, "new1", self.time)
     assert (self.orientlist.getOrientation("new1") == ([10, 20,
                                                         30], [1, 2, 3], ps,
                                                        "new1", self.time))
Esempio n. 15
0
 def makes_cases(self, zrot, yrot):
     del zrot, yrot  # not used
     self.wavelength = 1.24
     self.cases = (
         Pair(
             '7_9_13', (0.7, 0.9, 1.3),
             Pos(mu=0,
                 delta=27.352179,
                 nu=0,
                 eta=13.676090,
                 chi=37.774500,
                 phi=53.965500)),
         Pair(
             '100', (1, 0, 0),
             Pos(mu=0,
                 delta=18.580230,
                 nu=0,
                 eta=9.290115,
                 chi=-2.403500,
                 phi=3.589000)),
         Pair(
             '010', (0, 1, 0),
             Pos(mu=0,
                 delta=18.580230,
                 nu=0,
                 eta=9.290115,
                 chi=0.516000,
                 phi=93.567000)),
         Pair(
             '110', (1, 1, 0),
             Pos(mu=0,
                 delta=26.394192,
                 nu=0,
                 eta=13.197096,
                 chi=-1.334500,
                 phi=48.602000)),
     )
     self.case_dict = {}
     for case in self.cases:
         self.case_dict[case.name] = case
Esempio n. 16
0
 def makes_cases(self, zrot, yrot):
     self.zrot = zrot
     self.yrot = yrot
     self.wavelength = 1
     self.cases = (
         Pair(
             '100', (1, 0, 0),
             Pos(mu=0,
                 delta=60,
                 nu=0,
                 eta=30,
                 chi=0 - self.yrot,
                 phi=0 + self.zrot)),
         Pair(
             '100-->001',
             (cos(4 * TORAD), 0, sin(4 * TORAD)),
             Pos(mu=0,
                 delta=60,
                 nu=0,
                 eta=30,
                 chi=4 - self.yrot,
                 phi=0 + self.zrot),
         ),
         Pair('010', (0, 1, 0),
              Pos(mu=0, delta=60, nu=0, eta=30, chi=0, phi=90 + self.zrot)),
         Pair(
             '001', (0, 0, 1),
             Pos(mu=0,
                 delta=60,
                 nu=0,
                 eta=30,
                 chi=90 - self.yrot,
                 phi=0 + self.zrot)),
         Pair(
             '0.1 0 1.5',
             (0.1, 0, 1.5),  # cover case where delta > 90 !
             Pos(mu=0,
                 delta=97.46959231642,
                 nu=0,
                 eta=97.46959231642 / 2,
                 chi=86.18592516571 - self.yrot,
                 phi=0 + self.zrot)),
         Pair(
             '001-->100', (cos(86 * TORAD), 0, sin(86 * TORAD)),
             Pos(mu=0,
                 delta=60,
                 nu=0,
                 eta=30,
                 chi=86 - self.yrot,
                 phi=0 + self.zrot)),
     )
     self.case_dict = {}
     for case in self.cases:
         self.case_dict[case.name] = case
Esempio n. 17
0
 def test_add_orientation(self):
     assert len(self.orientlist) == 2
     pos = Pos(0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 'DEG')
     self.orientlist.add_orientation(10, 20, 30, 0.1, 0.2, 0.3, pos,
                                     "orient1", self.time)
 def test_add_reflection(self):
     assert len(self.reflist) == 2
     pos = Pos(0.11, 0.22, 0.33, 0.44, 0.55, 0.66, 'DEG')
     self.reflist.add_reflection(11.1, 12.2, 13.3, pos, 1100, "ref2",
                                 self.time)