示例#1
0
# rotation is called 'mu' in the spec-session)
# The second sample rotation ('eta') is lefthanded (-) around y -> y-

# define experimental geometry with respect to the crystalline directions
# of the substrate
hxrd = xu.HXRD((1, 0, 0), (0, 0, 1), en=energy, qconv=qconv)

# tell bounds of angles / (min,max) pair for all motors
# mu,eta,phi detector nu,del
bounds = (0, (0, 90), 0, (-1, 90), (0, 90))

#############################
# call angle fit function
#############################

ang = None
tbegin = time.time()
print("time  error (code)      qvec             angles")
for i in range(100):

    qvec = numpy.array((0, 0, i * 0.01))
    t0 = time.time()
    ang, qerror, errcode = xu.Q2AngFit(qvec, hxrd, bounds, startvalues=ang)
    t1 = time.time()

    print("%.4f: %.3g (%d) %s %s" %
          (t1 - t0, qerror, errcode, str(qvec), str(ang)))

tend = time.time()
print("Total time needed: %.2fsec" % (tend - tbegin))
示例#2
0
    raise ValueError("maximum of three free motors exceeded")

#############################################
# calculate the angles of Bragg reflections #
#############################################
comment = material.name
nb_reflex = len(reflections)
for idx in range(nb_reflex):
    hkl = reflections[idx]
    q_material = material.Q(hkl)
    q_laboratory = hxrd.Transform(q_material)
    print(
        comment,
        "   hkl=",
        hkl,
        "   q=",
        np.round(q_material, 5),
        "   lattice spacing= %.4f" % material.planeDistance(hkl),
        "angstroms",
    )

    # determine the goniometer angles with the correct geometry restrictions
    ang, qerror, errcode = xu.Q2AngFit(q_laboratory, hxrd, bounds)
    print("angles %s" % (str(np.round(ang, 5))))
    # check that qerror is small!!
    print(
        "sanity check with back-transformation (hkl): ",
        np.round(hxrd.Ang2HKL(*ang, mat=material), 5),
        "\n",
    )
示例#3
0
 def test_q2angfit(self):
     ang, qerror, errcode = xu.Q2AngFit(self.qvec, self.hxrd, self.bounds)
     qout = self.hxrd.Ang2Q(*ang)
     for i in range(3):
         self.assertAlmostEqual(qout[i], self.qvec[i], places=5)