Author: bugman Date: Fri Jul 12 18:28:21 2013 New Revision: 20289 URL: http://svn.gna.org/viewcvs/relax?rev=20289&view=rev Log: Added the functions for creating the X-axis pi-pulse rotation matrices in lib.dispersion.ns_matrices. The code comes from the 'fitting_main_kex.py' file attached to https://gna.org/task/?7712#comment3 (https://gna.org/support/download.php?file_id=18263). Modified: branches/relax_disp/lib/dispersion/ns_matrices.py Modified: branches/relax_disp/lib/dispersion/ns_matrices.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/lib/dispersion/ns_matrices.py?rev=20289&r1=20288&r2=20289&view=diff ============================================================================== --- branches/relax_disp/lib/dispersion/ns_matrices.py (original) +++ branches/relax_disp/lib/dispersion/ns_matrices.py Fri Jul 12 18:28:21 2013 @@ -26,7 +26,57 @@ """ # Python module imports. +from math import cos, sin, pi from numpy import matrix + + +def r180x_2d(flip=pi): + """The 2D rotation matrix for an imperfect X-axis pi-pulse. + + @keyword flip: The X-axis pi-pulse flip angle (in rad). This is currently unused, hence perfect pi-pulses are assumed. + @type flip: float + @return: The 2D rotational matrix. + @rtype: numpy rank-2, 4D array + """ + + # Build the matrix. + R = matrix([ + [ 1.0, 0.0, 0.0, 0.0], + [ 0.0, -1.0, 0.0, 0.0], + [ 0.0, 0.0, 1.0, 0.0], + [ 0.0, 0.0, 0.0, -1.0] + ]) + + # Return the matrix. + return R + + +def r180x_3d(flip=pi): + """The 3D rotation matrix for an imperfect X-axis pi-pulse. + + @keyword flip: The X-axis pi-pulse flip angle (in rad). + @type flip: float + @return: The 3D rotational matrix. + @rtype: numpy rank-2, 7D array + """ + + # Replicated calculations. + ct = cos(flip) + st = sin(flip) + + # Build the matrix. + R = matrix([ + [1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], + [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0], + [0.0, 0.0, ct, -st, 0.0, 0.0, 0.0], + [0.0, 0.0, st, ct, 0.0, 0.0, 0.0], + [0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0], + [0.0, 0.0, 0.0, 0.0, 0.0, ct, -st], + [0.0, 0.0, 0.0, 0.0, 0.0, st, ct] + ]) + + # Return the matrix. + return R def rcpmg_2d(R2E=None, R2G=None, df=None, kGE=None, kEG=None):