예제 #1
0
 def _check_angles_to_hkl(self, testname, zrot, yrot, hkl_expected, pos,
                          wavelength, virtual_expected={}):
     print ('_check_angles_to_hkl(%s, %.1f, %.1f, %s, %s, %.2f, %s)' %
            (testname, zrot, yrot, hkl_expected, pos, wavelength,
             virtual_expected))
     self.zrot, self.yrot = zrot, yrot
     self._configure_ub()
     hkl, virtual = self.calc.anglesToHkl(pos, wavelength)
     assert_array_almost_equal(hkl, hkl_expected, self.places, note="***Test (not diffcalc!) incorrect*** : the desired settings do not map to the target hkl")
     assert_second_dict_almost_in_first(virtual, virtual_expected)
예제 #2
0
 def _check_angles_to_hkl(self, testname, zrot, yrot, hkl_expected, pos,
                          wavelength, virtual_expected={}):
     print ('_check_angles_to_hkl(%s, %.1f, %.1f, %s, %s, %.2f, %s)' %
            (testname, zrot, yrot, hkl_expected, pos, wavelength,
             virtual_expected))
     self.zrot, self.yrot = zrot, yrot
     self._configure_ub()
     hkl, virtual = self.calc.anglesToHkl(pos, wavelength)
     assert_array_almost_equal(hkl, hkl_expected, self.places)
     assert_second_dict_almost_in_first(virtual, virtual_expected)
예제 #3
0
 def _check_hkl_to_angles(self, testname, zrot, yrot, hkl, pos_expected,
                          wavelength, virtual_expected={}):
     print ('_check_hkl_to_angles(%s, %.1f, %.1f, %s, %s, %.2f, %s)' %
            (testname, zrot, yrot, hkl, pos_expected, wavelength,
             virtual_expected))
     self.zrot, self.yrot = zrot, yrot
     self._configure_ub()
     pos, virtual = self.calc.hklToAngles(hkl[0], hkl[1], hkl[2],
                                          wavelength)
     assert_array_almost_equal(pos.totuple(), pos_expected.totuple(),
                               self.places)
     assert_second_dict_almost_in_first(virtual, virtual_expected)
예제 #4
0
 def check(self, name, value, theta, tau, psi_e, alpha_e, beta_e, places=7):
     # all in deg
     alpha, beta = self.calc._calc_remaining_reference_angles(
         name, value * TORAD, theta * TORAD, tau * TORAD)
     if alpha_e is not None:
         assert_almost_equal(alpha * TODEG, alpha_e, places)
     if beta_e is not None:
         assert_almost_equal(beta * TODEG, beta_e, places)
     psi_vals = list(self.calc._calc_psi(alpha, theta * TORAD, tau * TORAD))
     if psi_e is not None:
         assert_array_almost_equal(sorted([v * TODEG for v in psi_vals]),
                                   sorted(psi_e))
     for psi in psi_vals:
         print 'psi', psi * TODEG, ' alpha:', alpha * TODEG,\
               ' beta:', beta * TODEG
예제 #5
0
 def _check_angles_to_hkl(self,
                          testname,
                          zrot,
                          yrot,
                          hkl_expected,
                          pos,
                          wavelength,
                          virtual_expected={}):
     print('_check_angles_to_hkl(%s, %.1f, %.1f, %s, %s, %.2f, %s)' %
           (testname, zrot, yrot, hkl_expected, pos, wavelength,
            virtual_expected))
     self.zrot, self.yrot = zrot, yrot
     self._configure_ub()
     hkl, virtual = self.calc.anglesToHkl(pos, wavelength)
     assert_array_almost_equal(hkl, hkl_expected, self.places)
     assert_second_dict_almost_in_first(virtual, virtual_expected)
예제 #6
0
 def _check_hkl_to_angles(self,
                          testname,
                          zrot,
                          yrot,
                          hkl,
                          pos_expected,
                          wavelength,
                          virtual_expected={}):
     print('_check_hkl_to_angles(%s, %.1f, %.1f, %s, %s, %.2f, %s)' %
           (testname, zrot, yrot, hkl, pos_expected, wavelength,
            virtual_expected))
     self.zrot, self.yrot = zrot, yrot
     self._configure_ub()
     pos, virtual = self.calc.hklToAngles(hkl[0], hkl[1], hkl[2],
                                          wavelength)
     assert_array_almost_equal(pos.totuple(), pos_expected.totuple(),
                               self.places)
     assert_second_dict_almost_in_first(virtual, virtual_expected)
예제 #7
0
 def _check_angles_to_hkl(self,
                          testname,
                          zrot,
                          yrot,
                          hkl_expected,
                          pos,
                          wavelength,
                          virtual_expected={}):
     print('_check_angles_to_hkl(%s, %.1f, %.1f, %s, %s, %.2f, %s)' %
           (testname, zrot, yrot, hkl_expected, pos, wavelength,
            virtual_expected))
     self.zrot, self.yrot = zrot, yrot
     self._configure_ub()
     hkl, virtual = self.calc.anglesToHkl(pos, wavelength)
     assert_array_almost_equal(
         hkl,
         hkl_expected,
         self.places,
         note=
         "***Test (not diffcalc!) incorrect*** : the desired settings do not map to the target hkl"
     )
     assert_second_dict_almost_in_first(virtual, virtual_expected)
예제 #8
0
 def check(self, name, value, Q_lab, n_lab, Q_phi, n_phi, phi_e, chi_e,
           eta_e, mu_e):
     mu, eta, chi, phi = zip(*self.calc._calc_remaining_sample_angles(
         name, value * TORAD, Q_lab, n_lab, Q_phi, n_phi))
     for mu_, eta_, chi_, phi_ in zip(mu, eta, chi, phi):
         print 'phi', phi_ * TODEG, ' chi:', chi_ * TODEG, ' eta:', eta_ * TODEG,\
               ' mu:', mu_ * TODEG
     if phi_e is not None:
         assert_array_almost_equal([v * TODEG for v in phi], phi_e)
     if chi_e is not None:
         assert_array_almost_equal([v * TODEG for v in chi], chi_e)
     if eta_e is not None:
         assert_array_almost_equal([v * TODEG for v in eta], eta_e)
     if mu_e is not None:
         assert_array_almost_equal([v * TODEG for v in mu], mu_e)
예제 #9
0
 def check(self, name, value, theta, delta_e, nu_e, qaz_e):
     # all in deg
     delta, nu, qaz = zip(
         *self.calc._calc_remaining_detector_angles(name, value *
                                                    TORAD, theta * TORAD))
     for delta_, nu_, qaz_ in zip(delta, nu, qaz):
         print 'delta:', delta_ * TODEG, ' nu:', nu_ * TODEG, ' qaz:', qaz_ * TODEG
     assert_array_almost_equal([v * TODEG for v in delta], delta_e)
     assert_array_almost_equal([v * TODEG for v in nu], nu_e)
     if qaz_e is not None:
         assert_array_almost_equal([v * TODEG for v in qaz], qaz_e)
예제 #10
0
 def test_wrong_value(self):
     try:
         assert_array_almost_equal((3, 2, 1), (3, 2, 1.0000001))
         assert False
     except AssertionError:
         pass
예제 #11
0
 def test_wrong_length(self):
     try:
         assert_array_almost_equal((1, 2, 3), (1, 2))
         assert False
     except AssertionError, e:
         eq_(e.args[0], '(1, 2, 3) != (1, 2) as lengths differ')
예제 #12
0
 def test__passes(self):
     assert_array_almost_equal((1, 2, 3), (1.00000001, 2, 3.))
     assert_array_almost_equal((1, 2, 3), (1.0000001, 2, 3.), 6)
     assert_array_almost_equal((1, 2, 3), [1, 2, 3])
     assert_array_almost_equal((), ())
     assert_array_almost_equal([], ())
예제 #13
0
 def test_wrong_value(self):
     try:
         assert_array_almost_equal((3, 2, 1), (3, 2, 1.0000001))
         assert False
     except AssertionError:
         pass
예제 #14
0
 def test_wrong_length(self):
     try:
         assert_array_almost_equal((1, 2, 3), (1, 2))
         assert False
     except AssertionError, e:
         eq_(e.args[0], '(1, 2, 3) != (1, 2) as lengths differ')
예제 #15
0
 def test__passes(self):
     assert_array_almost_equal((1, 2, 3), (1.00000001, 2, 3.))
     assert_array_almost_equal((1, 2, 3), (1.0000001, 2, 3.), 6)
     assert_array_almost_equal((1, 2, 3), [1, 2, 3])
     assert_array_almost_equal((), ())
     assert_array_almost_equal([], ())