def testAgainstI16Results(self):
     self.ubcalc.start_new('cubcalc')
     self.ubcalc.set_lattice('latt', 1, 1, 1, 90, 90, 90)
     self.ubcalc.add_reflection(1, 0, 0, REF1a, EN1, '100', None)
     self.ubcalc.add_reflection(0, 0, 1, REF1b, EN1, '001', None)
     self.ubcalc.calculate_UB()
     matrixeq_(self.ubcalc.UB, UB1)
 def testAgainstI16Results(self):
     self.ubcalc.start_new('cubcalc')
     self.ubcalc.set_lattice('latt', 1, 1, 1, 90, 90, 90)
     self.ubcalc.add_reflection(1, 0, 0, REF1a, EN1, '100', None)
     self.ubcalc.add_reflection(0, 0, 1, REF1b, EN1, '001', None)
     self.ubcalc.calculate_UB()
     matrixeq_(self.ubcalc.UB, UB1)
    def test_save_and_restore_ubcalc_with_manual_ub(self):
        NAME = 'test_save_and_restore_ubcalc_with_manual_ub'
        UB = matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
        self.ubcalc.start_new(NAME)
        self.ubcalc.set_UB_manually(UB)
        matrixeq_(self.ubcalc.UB, UB)

        self.ubcalc.start_new(NAME + '2')
        self.ubcalc.load(NAME)

        matrixeq_(self.ubcalc.UB, UB)
 def test_save_and_restore_ubcalc_with_manual_ub(self):
     NAME = 'test_save_and_restore_ubcalc_with_manual_ub'
     UB = matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
     self.ubcalc.start_new(NAME)
     self.ubcalc.set_UB_manually(UB)
     matrixeq_(self.ubcalc.UB, UB)
     
     self.ubcalc.start_new(NAME + '2')
     self.ubcalc.load(NAME)
     
     matrixeq_(self.ubcalc.UB, UB)
    def test_save_and_restore_ubcalc_with_UB_from_two_ref(self):
        NAME = 'test_save_and_restore_ubcalc_with_UB_from_two_ref'
        self.ubcalc.start_new(NAME)
        self.ubcalc.set_lattice('latt', 1, 1, 1, 90, 90, 90)
        self.ubcalc.add_reflection(1, 0, 0, REF1a, EN1, '100', None)
        self.ubcalc.add_reflection(0, 0, 1, REF1b, EN1, '001', None)
        matrixeq_(self.ubcalc.UB, UB1)

        self.ubcalc.start_new(NAME + '2')
        self.ubcalc.load(NAME)

        matrixeq_(self.ubcalc.UB, UB1)
 def test_save_and_restore_ubcalc_with_manual_u(self):
     NAME = 'test_save_and_restore_ubcalc_with_manual_u'
     U = matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
     self.ubcalc.start_new(NAME)
     self.ubcalc.set_lattice('latt', 1, 1, 1, 90, 90, 90)
     self.ubcalc.set_U_manually(U)
     matrixeq_(self.ubcalc.UB, U * 2 * pi)
     
     self.ubcalc.start_new(NAME + '2')
     self.ubcalc.load(NAME)
     
     matrixeq_(self.ubcalc.UB, U * 2 * pi)
 def test_save_and_restore_ubcalc_with_UB_from_one_ref(self):
     NAME = 'test_save_and_restore_ubcalc_with_UB_from_one_ref'
     self.ubcalc.start_new(NAME)
     self.ubcalc.set_lattice('latt', 1, 1, 1, 90, 90, 90)
     self.ubcalc.add_reflection(1, 0, 0, REF1a, EN1, '100', None)
     self.ubcalc.calculate_UB_from_primary_only()
     matrixeq_(self.ubcalc.UB, UB1,  places=2)
     
     self.ubcalc.start_new(NAME + '2')
     self.ubcalc.load(NAME)
     
     matrixeq_(self.ubcalc.UB, UB1,  places=2)
 def test_save_and_restore_ubcalc_with_UB_from_two_ref(self):
     NAME = 'test_save_and_restore_ubcalc_with_UB_from_two_ref'
     self.ubcalc.start_new(NAME)
     self.ubcalc.set_lattice('latt', 1, 1, 1, 90, 90, 90)
     self.ubcalc.add_reflection(1, 0, 0, REF1a, EN1, '100', None)
     self.ubcalc.add_reflection(0, 0, 1, REF1b, EN1, '001', None)
     matrixeq_(self.ubcalc.UB, UB1)
     
     self.ubcalc.start_new(NAME + '2')
     self.ubcalc.load(NAME)
     
     matrixeq_(self.ubcalc.UB, UB1)
    def test_save_and_restore_ubcalc_with_UB_from_one_ref(self):
        NAME = 'test_save_and_restore_ubcalc_with_UB_from_one_ref'
        self.ubcalc.start_new(NAME)
        self.ubcalc.set_lattice('latt', 1, 1, 1, 90, 90, 90)
        self.ubcalc.add_reflection(1, 0, 0, REF1a, EN1, '100', None)
        self.ubcalc.calculate_UB_from_primary_only()
        matrixeq_(self.ubcalc.UB, UB1, places=2)

        self.ubcalc.start_new(NAME + '2')
        self.ubcalc.load(NAME)

        matrixeq_(self.ubcalc.UB, UB1, places=2)
    def test_save_and_restore_ubcalc_with_manual_u(self):
        NAME = 'test_save_and_restore_ubcalc_with_manual_u'
        U = matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
        self.ubcalc.start_new(NAME)
        self.ubcalc.set_lattice('latt', 1, 1, 1, 90, 90, 90)
        self.ubcalc.set_U_manually(U)
        matrixeq_(self.ubcalc.UB, U * 2 * pi)

        self.ubcalc.start_new(NAME + '2')
        self.ubcalc.load(NAME)

        matrixeq_(self.ubcalc.UB, U * 2 * pi)
 def testAgainstResultsFromJan_27_2010(self):
     self.ubcalc.start_new('test')
     self.ubcalc.set_lattice('Si_5_5_12', 7.68, 53.48, 75.63, 90, 90, 90)
     self.ubcalc.add_reflection(
         Si_5_5_12_HKL0[0], Si_5_5_12_HKL0[1], Si_5_5_12_HKL0[2],
         Si_5_5_12_REF0, 12.39842 / Si_5_5_12_WAVELENGTH, 'ref0', None)
     self.ubcalc.add_reflection(
         Si_5_5_12_HKL1[0], Si_5_5_12_HKL1[1], Si_5_5_12_HKL1[2],
         Si_5_5_12_REF1, 12.39842 / Si_5_5_12_WAVELENGTH, 'ref1', None)
     self.ubcalc.calculate_UB()
     print "U: ", self.ubcalc.U
     print "UB: ", self.ubcalc.UB
     matrixeq_(self.ubcalc.U, Si_5_5_12_U_DIFFCALC)
Exemple #12
0
 def testAgainstResultsFromJan_27_2010(self):
     self.ubcalc.start_new('test')
     self.ubcalc.set_lattice('Pt531', 6.204, 4.806, 23.215, 90, 90, 49.8)
     self.ubcalc.add_reflection(Pt531_HKL0[0], Pt531_HKL0[1], Pt531_HKL0[2],
                                Pt531_REF0, 12.39842 / Pt531_WAVELENGTH,
                                'ref0', None)
     self.ubcalc.add_reflection(Pt531_HKL1[0], Pt531_HKL1[1], Pt531_HKL1[2],
                                Pt531_REF1, 12.39842 / Pt531_WAVELENGTH,
                                'ref1', None)
     self.ubcalc.calculate_UB()
     print "U: ", self.ubcalc.U
     print "UB: ", self.ubcalc.UB
     matrixeq_(self.ubcalc.U, Pt531_U_DIFFCALC)
Exemple #13
0
 def testAgainstResultsFromJan_27_2010(self):
     self.ubcalc.start_new('test')
     self.ubcalc.set_lattice('Si_5_5_12', 7.68, 53.48, 75.63, 90, 90, 90)
     self.ubcalc.add_reflection(HKL0[0], HKL0[1], HKL0[2],
                                willmott_to_you_fixed_mu_chi(REF0), ENERGY,
                                'ref0', None)
     self.ubcalc.add_reflection(HKL1[0], HKL1[1], HKL1[2],
                                willmott_to_you_fixed_mu_chi(REF1), ENERGY,
                                'ref1', None)
     self.ubcalc.calculate_UB()
     print "U: ", self.ubcalc.U
     print "UB: ", self.ubcalc.UB
     matrixeq_(self.ubcalc.U, U_DIFFCALC)
 def testAgainstResultsFromJan_27_2010(self):
     self.ubcalc.start_new('test')
     self.ubcalc.set_lattice('Pt531', 6.204, 4.806, 23.215, 90, 90, 49.8)
     self.ubcalc.add_reflection(
         Pt531_HKL0[0], Pt531_HKL0[1], Pt531_HKL0[2], Pt531_REF0,
         12.39842 / Pt531_WAVELENGTH, 'ref0', None)
     self.ubcalc.add_reflection(
         Pt531_HKL1[0], Pt531_HKL1[1], Pt531_HKL1[2], Pt531_REF1,
         12.39842 / Pt531_WAVELENGTH, 'ref1', None)
     self.ubcalc.calculate_UB()
     print "U: ", self.ubcalc.U
     print "UB: ", self.ubcalc.UB
     matrixeq_(self.ubcalc.U, Pt531_U_DIFFCALC)
 def test_calc_offset_for_hkl(self):
     NAME = 'test_calc_offset_for_hkl'
     self.ubcalc.start_new(NAME)
     self.ubcalc.set_lattice('latt', 1, 1, 1, 90, 90, 90)
     self.ubcalc.set_U_manually(x_rotation(0))
     for hklref, hkloff, pol_ref, az_ref, sc_ref in [
         ([0, 0, 1], [1, 1, 0], 90 * TORAD, -45 * TORAD, sqrt(2)),
         ([0, 0, 1], [-1, 0, 1], 45 * TORAD, 90 * TORAD, sqrt(2)),
         ([1, 0, 0], [1, 0, 2], atan2(2, 1), 90 * TORAD, sqrt(5)),
     ]:
         pol, az, sc = self.ubcalc.calc_offset_for_hkl(hkloff, hklref)
         matrixeq_(matrix([[pol_ref, az_ref, sc_ref]]),
                   matrix([[pol, az, sc]]))
 def testAgainstResultsFromJan_27_2010(self):
     self.ubcalc.start_new('test')
     self.ubcalc.set_lattice('Si_5_5_12', 7.68, 53.48, 75.63, 90, 90, 90)
     self.ubcalc.add_reflection(
         HKL0[0], HKL0[1], HKL0[2], willmott_to_you_fixed_mu_chi(REF0),
         ENERGY, 'ref0', None)
     self.ubcalc.add_reflection(
         HKL1[0], HKL1[1], HKL1[2], willmott_to_you_fixed_mu_chi(REF1),
         ENERGY, 'ref1', None)
     self.ubcalc.calculate_UB()
     print "U: ", self.ubcalc.U
     print "UB: ", self.ubcalc.UB
     matrixeq_(self.ubcalc.U, U_DIFFCALC)
Exemple #17
0
 def testAgainstResultsFromJan_27_2010(self):
     self.ubcalc.start_new('test')
     self.ubcalc.set_lattice('Si_5_5_12', 7.68, 53.48, 75.63, 90, 90, 90)
     self.ubcalc.add_reflection(Si_5_5_12_HKL0[0], Si_5_5_12_HKL0[1],
                                Si_5_5_12_HKL0[2], Si_5_5_12_REF0,
                                12.39842 / Si_5_5_12_WAVELENGTH, 'ref0',
                                None)
     self.ubcalc.add_reflection(Si_5_5_12_HKL1[0], Si_5_5_12_HKL1[1],
                                Si_5_5_12_HKL1[2], Si_5_5_12_REF1,
                                12.39842 / Si_5_5_12_WAVELENGTH, 'ref1',
                                None)
     self.ubcalc.calculate_UB()
     print "U: ", self.ubcalc.U
     print "UB: ", self.ubcalc.UB
     matrixeq_(self.ubcalc.U, Si_5_5_12_U_DIFFCALC)
 def test_calc_hkl_offset(self):
     NAME = 'test_calc_hkl_offset'
     self.ubcalc.start_new(NAME)
     self.ubcalc.set_lattice('latt', 1, 1, 1, 90, 90, 90)
     self.ubcalc.set_U_manually(x_rotation(0))
     hkloff_110 = self.ubcalc.calc_hkl_offset(0, 0, sqrt(2), 90. * TORAD,
                                              -45 * TORAD)
     hkloff_m101 = self.ubcalc.calc_hkl_offset(0, 0, sqrt(2), 45. * TORAD,
                                               90 * TORAD)
     alpha = atan2(2, 1)
     hkloff_102 = self.ubcalc.calc_hkl_offset(sqrt(5), 0, 0, alpha,
                                              90 * TORAD)
     matrixeq_(matrix('1 1 0'), matrix(hkloff_110))
     matrixeq_(matrix('-1 0 1'), matrix(hkloff_m101))
     matrixeq_(matrix('1 0 2'), matrix(hkloff_102))
Exemple #19
0
 def check(self, testname, hklref1, hklref2, expectedUMatrix):
     self.addref(hklref1)
     self.addref(hklref2)
     matrixeq_(expectedUMatrix, self.ubcalc.U)
Exemple #20
0
 def check(self, testname, hklref, expectedUMatrix):
     print testname
     self.addref(hklref)
     self.ubcalc.calculate_UB_from_primary_only()
     matrixeq_(expectedUMatrix, self.ubcalc.U)
 def check(self, testname, hklref1, hklref2, expectedUMatrix):
     self.addref(hklref1)
     self.addref(hklref2)
     matrixeq_(expectedUMatrix, self.ubcalc.U)
 def check(self, testname, hklref, expectedUMatrix):
     print testname
     self.addref(hklref)
     self.ubcalc.calculate_UB_from_primary_only()
     matrixeq_(expectedUMatrix, self.ubcalc.U)