def runTest(self): tth, eta = transform.compute_tth_eta_from_xyz(self.XLYLZL, self.omega * self.omegasign, t_x=self.t_x, t_y=self.t_y, t_z=self.t_z, wedge=self.wedge, chi=self.chi) gve1 = transform.compute_g_vectors(tth, eta, self.omega * self.omegasign, self.wvln, wedge=self.wedge, chi=self.chi) t = np.array((self.t_x, self.t_y, self.t_z)) gve2 = np.empty((len(tth), 3), np.float) cImageD11.compute_gv(self.XLYLZLT, self.omega, self.omegasign, self.wvln, self.wedge, self.chi, t, gve2) # print t, self.wedge,self.chi # for i in range( len(tth)): # print i, gve1[:,i],gve1[:,i]-gve2[i],gve1[:,i]-gve3[:,i] # print "Test C" self.assertTrue(np.allclose(gve1, gve2.T)) # print "Test Fortran" if TEST_FORTRAN: gve3 = np.empty((3, len(tth)), np.float, order='F') fImageD11.compute_gv(self.XLYLZL, self.omega, self.omegasign, self.wvln, self.wedge, self.chi, t, gve3)
try: pks = [c.sc, c.fc] except: pks = [c.xc, c.yc] wvln = float(p.get("wavelength")) wedge = float(p.get("wedge")) chi = float(p.get("chi")) t = np.array([float(p.get("t_x")), float(p.get("t_y")), float(p.get("t_z"))], np.float32) print("Reading %.4f" % (time.time() - start), end=' ') start = time.time() for i in range(10): xlylzl = compute_xyz_lab(pks, **p.parameters) tth, eta = compute_tth_eta_from_xyz(xlylzl, c.omega, **p.parameters) gv = compute_g_vectors(tth, eta, c.omega * p.get('omegasign'), wvln, wedge, chi) d1 = time.time() - start osi = p.get('omegasign') gvf = np.zeros(xlylzl.shape, np.float, order='F') start = time.time() for i in range(100): fImageD11.compute_gv(xlylzl, c.omega, osi, wvln, wedge, chi, t, gvf) d2 = time.time() - start print("%.4f %.4f" % (d1, d2), "Ratio %.2f" % (10 * d1 / d2)) err = gv - gvf scor = abs(err).mean(axis=1) / abs(gv).mean(axis=1) assert (scor < 1e-6).all(), "Mismatch"