parameters: (hkl, UB, setang)
return_statement: return lambda_1, d, ttheta
docstring: % calculates some useful numbers from (ISAW calculated) UB
      % hkl is a 2D array containing all hkl's
      %
docstring_summary: % calculates some useful numbers from (ISAW calculated) UB
      % hkl is a 2D array containing all hkl's
      %
docstring_tokens: % calculates some useful numbers from ( ISAW calculated ) UB % hkl is a 2D array containing all hkl s %
function: def pkposcalc(hkl, UB, setang):
      '''
      % calculates some useful numbers from (ISAW calculated) UB
      % hkl is a 2D array containing all hkl's
      %
      '''
  
      ome = setang[0]
      phi = setang[1]
      chi = setang[2]
      thkl = hkl.transpose()
  
      Q = UB.dot(thkl)
  
      Rx = np.array([[1, 0, 0], [0, np.cos(np.radians(ome)), -np.sin(np.radians(ome))],
                     [0, np.sin(np.radians(ome)), np.cos(np.radians(ome))]])
      Ry = np.array([[np.cos(np.radians(phi)), 0, np.sin(np.radians(phi))], [0, 1, 0],
                     [-np.sin(np.radians(phi)), 0, np.cos(np.radians(phi))]])
      Rz = np.array([[np.cos(np.radians(chi)), -np.sin(np.radians(chi)), 0],
                     [np.sin(np.radians(chi)), np.cos(np.radians(chi)), 0], [0, 0, 1]])
      Rall = Rz.dot(Ry).dot(Rx)  # all three rotations
      # str = sprintf('initial: %6.4f %6.4f %6.4f',Q);
      # disp(str)
      Q = Rall.dot(Q)
      magQ = np.sqrt((Q * Q).sum(axis=0))
      '''
      # str = sprintf('Scattering vector: %6.4f %6.4f %6.4f',Q);
      # if show==1
      #    disp(str)
      # end
      % %calculate angle with incident beam i.e. (-1 0 0)
      % beam = [1 0 0];
      % alpha = acosd(dot(Q,beam)/norm(Q));
      % str = sprintf('Angle scat. vect. to beam: %6.4f',alpha);
      % if show==1
      %     disp(str)
      % end
      % beam = [0 1 0];
      % alpha = acosd(dot(Q,beam)/norm(Q));
      % str = sprintf('Angle scat. vect. to y: %6.4f',alpha);
      % if show==1
      %     disp(str)
      % end
      % beam = [0 0 1];
      % alpha = acosd(dot(Q,beam)/norm(Q));
      % str = sprintf('Angle scat. vect. to z: %6.4f',alpha);
      % if show==1
      %     disp(str)
      % end
      % Q is a vector pointing to the reciprocal lattice point corresponding to
      % vector hkl. The coordinate system is in frame I that is right handed with x pointing along
      % the beam direction and z vertical.
      '''
      d = (1.0 / magQ)  # by definition (note ISAW doesn't use 2pi factor)
      d = d.transpose()
      '''
      % In frame I the incident beam vector will be of the form [k 0 0]
      % where k = 1/lambda
      % by considering the scattering relation that Q=k_f-k_i, can show that the dot product of
      % -k_i.Q gives the scattering angle 2theta, thus:
      '''
      ttheta = 180 - 2 * np.degrees(np.arccos(-Q[0, :] / magQ))
      ttheta = ttheta.transpose()
      # and Bragg's law gives:
      lambda_1 = 2 * d * np.sin(np.radians(ttheta / 2))
      lambda_1 = lambda_1.transpose()
      '''
      %
      %   str = sprintf('for hkl: %3i%3i%3i',hkl(1),hkl(2),hkl(3));
      % disp(str)
      % str = sprintf('d-spacing is: %6.4f',d);
      % disp(str)
      % str = sprintf('ttheta is: %6.4f',ttheta);
      % disp(str)
      % str = sprintf('lambda is: %6.4f',lambda);
      % disp(str)
      '''
  
      return lambda_1, d, ttheta
function_tokens: def pkposcalc ( hkl , UB , setang ) : ome = setang [ 0 ] phi = setang [ 1 ] chi = setang [ 2 ] thkl = hkl . transpose ( ) Q = UB . dot ( thkl ) Rx = np . array ( [ [ 1 , 0 , 0 ] , [ 0 , np . cos ( np . radians ( ome ) ) , - np . sin ( np . radians ( ome ) ) ] , [ 0 , np . sin ( np . radians ( ome ) ) , np . cos ( np . radians ( ome ) ) ] ] ) Ry = np . array ( [ [ np . cos ( np . radians ( phi ) ) , 0 , np . sin ( np . radians ( phi ) ) ] , [ 0 , 1 , 0 ] , [ - np . sin ( np . radians ( phi ) ) , 0 , np . cos ( np . radians ( phi ) ) ] ] ) Rz = np . array ( [ [ np . cos ( np . radians ( chi ) ) , - np . sin ( np . radians ( chi ) ) , 0 ] , [ np . sin ( np . radians ( chi ) ) , np . cos ( np . radians ( chi ) ) , 0 ] , [ 0 , 0 , 1 ] ] ) Rall = Rz . dot ( Ry ) . dot ( Rx ) # all three rotations # str = sprintf('initial: %6.4f %6.4f %6.4f',Q); # disp(str) Q = Rall . dot ( Q ) magQ = np . sqrt ( ( Q * Q ) . sum ( axis = 0 ) ) '''
      # str = sprintf('Scattering vector: %6.4f %6.4f %6.4f',Q);
      # if show==1
      #    disp(str)
      # end
      % %calculate angle with incident beam i.e. (-1 0 0)
      % beam = [1 0 0];
      % alpha = acosd(dot(Q,beam)/norm(Q));
      % str = sprintf('Angle scat. vect. to beam: %6.4f',alpha);
      % if show==1
      %     disp(str)
      % end
      % beam = [0 1 0];
      % alpha = acosd(dot(Q,beam)/norm(Q));
      % str = sprintf('Angle scat. vect. to y: %6.4f',alpha);
      % if show==1
      %     disp(str)
      % end
      % beam = [0 0 1];
      % alpha = acosd(dot(Q,beam)/norm(Q));
      % str = sprintf('Angle scat. vect. to z: %6.4f',alpha);
      % if show==1
      %     disp(str)
      % end
      % Q is a vector pointing to the reciprocal lattice point corresponding to
      % vector hkl. The coordinate system is in frame I that is right handed with x pointing along
      % the beam direction and z vertical.
      ''' d = ( 1.0 / magQ ) # by definition (note ISAW doesn't use 2pi factor) d = d . transpose ( ) '''
      % In frame I the incident beam vector will be of the form [k 0 0]
      % where k = 1/lambda
      % by considering the scattering relation that Q=k_f-k_i, can show that the dot product of
      % -k_i.Q gives the scattering angle 2theta, thus:
      ''' ttheta = 180 - 2 * np . degrees ( np . arccos ( - Q [ 0 , : ] / magQ ) ) ttheta = ttheta . transpose ( ) # and Bragg's law gives: lambda_1 = 2 * d * np . sin ( np . radians ( ttheta / 2 ) ) lambda_1 = lambda_1 . transpose ( ) '''
      %
      %   str = sprintf('for hkl: %3i%3i%3i',hkl(1),hkl(2),hkl(3));
      % disp(str)
      % str = sprintf('d-spacing is: %6.4f',d);
      % disp(str)
      % str = sprintf('ttheta is: %6.4f',ttheta);
      % disp(str)
      % str = sprintf('lambda is: %6.4f',lambda);
      % disp(str)
      ''' return lambda_1 , d , ttheta