mailRe: r24780 - /branches/r1rho_plotting/lib/nmr.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by Edward d'Auvergne on July 28, 2014 - 14:10:
This is a good idea, standardising these calculations!  That should
remove a potential source of bugs.

Cheers,

Edward

On 28 July 2014 12:56,  <tlinnet@xxxxxxxxxxxxx> wrote:
Author: tlinnet
Date: Mon Jul 28 12:56:51 2014
New Revision: 24780

URL: http://svn.gna.org/viewcvs/relax?rev=24780&view=rev
Log:
Added function to calculate rotating frame paramters for lib/nmr.py.

This function is called several times in 
specific_analyses/relax_disp/data.py by plotting functions.

sr #3124(https://gna.org/support/?3124): Grace graphs production for R1rho 
analysis with R2_eff as function of Omega_eff.
sr #3138(https://gna.org/support/?3138): Interpolating theta through 
spin-lock offset [Omega], rather than spin-lock field strength [w1].

Modified:
    branches/r1rho_plotting/lib/nmr.py

Modified: branches/r1rho_plotting/lib/nmr.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/r1rho_plotting/lib/nmr.py?rev=24780&r1=24779&r2=24780&view=diff
==============================================================================
--- branches/r1rho_plotting/lib/nmr.py  (original)
+++ branches/r1rho_plotting/lib/nmr.py  Mon Jul 28 12:56:51 2014
@@ -23,7 +23,7 @@
 """Module containing functions related to basic NMR concepts."""

 # Python module imports.
-from math import pi
+from math import atan2, pi, sqrt

 # relax module imports.
 from lib.physical_constants import g1H, return_gyromagnetic_ratio
@@ -95,3 +95,35 @@

     # Convert and return.
     return frq * 2.0 * pi * B0 / g1H * return_gyromagnetic_ratio(isotope) 
* 1e-6
+
+
+def rotating_frame_params(chemical_shift=None, spin_lock_offset=None, 
omega1=None):
+    """Calculate the rotating frame paramaters.
+
+    @keyword chemical_shift:    The chemical shift in rad/s.
+    @type chemical_shift:       float
+    @keyword spin_lock_offset:  spin-lock offset in rad/s.
+    @type spin_lock_offset:     float
+    @keyword omega1:            Spin-lock field strength in rad/s.
+    @type omega1:               float
+    @return:                    The average resonance offset in the 
rotating frame, angle describing the tilted rotating frame relative to the 
laboratory, effective field in rotating frame.
+    @rtype:                     float, float, float
+    """
+
+    # The average resonance offset in the rotating frame.
+    Delta_omega = chemical_shift - spin_lock_offset
+
+    # Calculate the theta angle describing the tilted rotating frame 
relative to the laboratory.
+    # theta = atan(omega1 / Delta_omega).
+    # If Delta_omega is negative, there follow the symmetry of atan, that 
atan(-x) = - atan(x).
+    # Then it should be: theta = pi + atan(-x) = pi - atan(x) = pi - 
abs(atan( +/- x)).
+    # This is taken care of with the atan2(y, x) function, which return 
atan(y / x), in radians, and the result is between -pi and pi.
+    if Delta_omega == 0.0:
+        theta = pi / 2.0
+    else:
+        theta = atan2(omega1, Delta_omega)
+
+    # Calculate effective field in rotating frame.
+    w_eff = sqrt( Delta_omega*Delta_omega + omega1*omega1 )
+
+    return Delta_omega, theta, w_eff


_______________________________________________
relax (http://www.nmr-relax.com)

This is the relax-commits mailing list
relax-commits@xxxxxxx

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits



Related Messages


Powered by MHonArc, Updated Tue Jul 29 14:00:16 2014