示例#1
0
    def testHklToAngles(self):
        if self.calc:
            # Configure the angle calculator for this session scenario
            UB = matrix(self.sess.umatrix) * matrix(self.sess.bmatrix)
            mockUbcalc = createMockUbcalc(UB)
            hw = createMockHardwareMonitor()
            settings.geometry = createMockDiffractometerGeometry()
            settings.hardware = hw
            ac = VliegHklCalculator(mockUbcalc)
            ac.raiseExceptionsIfAnglesDoNotMapBackToHkl = True

            ## configure the angle calculator for this calculation
            ac.mode_selector.setModeByName(self.calc.modeToTest)

            # Set fixed parameters
            if self.calc.modeToTest in ('4cBeq', '4cFixedw'):

                #ac.setParameter('alpha', self.calc.alpha )
                ac.parameter_manager.setTrackParameter('alpha', True)
                hw.get_position.return_value = 888, self.calc.alpha, 999
                ac.parameter_manager.set_constraint('gamma', self.calc.gamma)

            # Test each hkl/position pair
            for idx in range(len(self.calc.hklList)):
                hkl = self.calc.hklList[idx]
                expectedpos = self.calc.posList[idx]
                (pos, params) = ac.hklToAngles(hkl[0], hkl[1], hkl[2],
                                               self.calc.wavelength)
                note = ("wrong positions calculated for TestScenario=%s, "
                        "AngleTestScenario=%s, hkl=(%f,%f,%f):\n"
                        "  expected pos=%s;\n"
                        "  returned pos=%s " %
                        (self.sess.name, self.calc.tag, hkl[0], hkl[1], hkl[2],
                         str(expectedpos), str(pos)))
                assert pos.nearlyEquals(expectedpos, 0.01), note
                print "*** hklToAngles ***"
                print "*** ", str(hkl), " ***"
                print params
                try:
                    print self.calc.paramList[idx]
                except IndexError:  # Not always specified
                    pass
示例#2
0
    def testHklToAngles(self):
        if self.calc:
            # Configure the angle calculator for this session scenario
            UB = matrix(self.sess.umatrix) * matrix(self.sess.bmatrix)
            mockUbcalc = createMockUbcalc(UB)
            hw = createMockHardwareMonitor()
            ac = VliegHklCalculator(mockUbcalc,
                                    createMockDiffractometerGeometry(), hw)
            ac.raiseExceptionsIfAnglesDoNotMapBackToHkl = True

            ## configure the angle calculator for this calculation
            ac.mode_selector.setModeByName(self.calc.modeToTest)

            # Set fixed parameters
            if self.calc.modeToTest in ('4cBeq', '4cFixedw'):

                #ac.setParameter('alpha', self.calc.alpha )
                ac.parameter_manager.setTrackParameter('alpha', True)
                hw.get_position.return_value = 888, self.calc.alpha, 999
                ac.parameter_manager.set_constraint('gamma', self.calc.gamma)

            # Test each hkl/position pair
            for idx in range(len(self.calc.hklList)):
                hkl = self.calc.hklList[idx]
                expectedpos = self.calc.posList[idx]
                (pos, params) = ac.hklToAngles(hkl[0], hkl[1], hkl[2],
                                               self.calc.wavelength)
                note = ("wrong positions calculated for TestScenario=%s, "
                        "AngleTestScenario=%s, hkl=(%f,%f,%f):\n"
                        "  expected pos=%s;\n"
                        "  returned pos=%s " %
                        (self.sess.name, self.calc.tag, hkl[0], hkl[1], hkl[2],
                         str(expectedpos), str(pos)))
                assert pos.nearlyEquals(expectedpos, 0.01), note
                print "*** hklToAngles ***"
                print "*** ", str(hkl), " ***"
                print params
                try:
                    print self.calc.paramList[idx]
                except IndexError:  # Not always specified
                    pass