Пример #1
0
 def _calc_alpha(self):
     """
     Calc alpha, ie incidence angle or angle btwn 
     -1*k_in (which is parallel to lab-y) and the
     plane perp to the reference vector n.
     """
     nm = self.nm
     ki = num.array([0., -1., 0.])
     alpha = arcsind(num.dot(nm, ki))
     self.pangles['alpha'] = alpha
Пример #2
0
    def tth(self,hkl,lam=None):
        """
        Calculate 2Theta for given [h,k,l] and wavelength

        Notes:
        ------
        If lam is None the default lambda will be used (Cu Ka1)
        If you pass in lam, this will change the default for
        subsequent calls
        """
        if lam != None: self.lam = float(lam)
        d = self.d(hkl)
        if d == 0.: return 0.
        r = self.lam/(2.*d)
        if num.fabs(r) > 1.0:
            r = r/num.fabs(r)
        tth = 2.*arcsind(r)
        return tth
Пример #3
0
    def tth(self,hkl,lam=None):
        """
        Calculate 2Theta for given [h,k,l] and wavelength

        Notes:
        ------
        If lam is None the default lambda will be used (Cu Ka1)
        If you pass in lam, this will change the default for
        subsequent calls
        """
        if lam != None: self.lam = float(lam)
        d = self.d(hkl)
        if d == 0.: return 0.
        r = self.lam/(2.*d)
        if num.fabs(r) > 1.0:
            r = r/num.fabs(r)
        tth = 2.*arcsind(r)
        return tth
Пример #4
0
    def _calc_beta(self):
        """
        Calc beta, ie exit angle, or angle btwn k_r and the
        plane perp to the reference vector n

        Notes:
        ------
        beta = arcsind(2*sind(tth/2)*cosd(tau)-sind(alpha))
        """
        # calc normalized kr
        #delta = self.angles['delta']
        #nu    = self.angles['nu']
        #kr = num.array([sind(delta),
        #                cosd(nu)*cosd(delta),
        #                sind(nu)*cosd(delta)])
        nm = self.nm
        kr = self.kr / cartesian_mag(self.kr)
        beta = arcsind(num.dot(nm, kr))
        self.pangles['beta'] = beta
Пример #5
0
def _spec_or_angles(angles, calc_kappa=False):
    """
    Angles defined by spec for the OR's.
    See specfile.py

    Notes:
    ------
    Assume the following.
    
    If parsing angles from the P array:
    (generally shouldnt need this since angles
    are tagged with motor labels on read)
    angles = P
    if psic:
       angles = angles[0:5]
    elif kappa fourc
       angles = [angles[0:3], angles[8], angles[7]]

    If parsing angles from the G array:
      angles = G[x:y]
    where x:y depend on whether you are
    parsing out or0 or or1.
    See spec_G below

    We then assume the following:
      del = angles[0]
      eta = angles[1]
      chi = angles[2]
      phi = angles[3]
      nu  = angles[4]
      mu  = angles[5]

    Note: calc kappa, keta and kphi
    kap_alp = 50.031;
    keta    = eta - asin(-tan(chi/2)/tan(kap_alp))
    kphi    = phi - asin(-tan(chi/2)/tan(kap_alp))
    kappa   = asin(sin(chi/2)/sin(kap_alp))
    """
    # angles from spec
    delta = angles[0]
    eta = angles[1]
    chi = angles[2]
    phi = angles[3]
    nu = angles[4]
    mu = angles[5]

    # kappa angles
    if calc_kappa:
        kap_alp = 50.031
        keta = eta - arcsind(-tand(chi / 2.) / tand(kap_alp))
        kphi = phi - arcsind(-tand(chi / 2.) / tand(kap_alp))
        kappa = asind(sind(chi / 2.) / sind(kap_alp))
        return {
            'phi': phi,
            'chi': chi,
            'eta': eta,
            'mu': mu,
            'delta': delta,
            'nu': nu,
            'keta': keta,
            'kphi': kphi,
            'kappa': kappa
        }
    else:
        return {
            'phi': phi,
            'chi': chi,
            'eta': eta,
            'mu': mu,
            'delta': delta,
            'nu': nu
        }