mailr21616 - in /branches/relax_disp: lib/dispersion/ specific_analyses/relax_disp/ target_functions/


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

Header


Content

Posted by edward on November 24, 2013 - 13:09:
Author: bugman
Date: Sun Nov 24 13:09:02 2013
New Revision: 21616

URL: http://svn.gna.org/viewcvs/relax?rev=21616&view=rev
Log:
Updated the spin-lock field strength data structures to be experiment and 
field specific.

This allows different spin-locks to be used as different field strengths, or 
different experiments.
It brings the structures in line with those for CPMG-type experiments.


Modified:
    branches/relax_disp/lib/dispersion/mp05.py
    branches/relax_disp/lib/dispersion/ns_r1rho_2site.py
    branches/relax_disp/lib/dispersion/tap03.py
    branches/relax_disp/lib/dispersion/tp02.py
    branches/relax_disp/specific_analyses/relax_disp/disp_data.py
    branches/relax_disp/target_functions/relax_disp.py

Modified: branches/relax_disp/lib/dispersion/mp05.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/lib/dispersion/mp05.py?rev=21616&r1=21615&r2=21616&view=diff
==============================================================================
--- branches/relax_disp/lib/dispersion/mp05.py (original)
+++ branches/relax_disp/lib/dispersion/mp05.py Sun Nov 24 13:09:02 2013
@@ -85,12 +85,12 @@
     for i in range(num_points):
         # We assume that A resonates at 0 [s^-1], without loss of generality.
         W = pA*Wa + pB*Wb                           # Pop-averaged Larmor 
frequency [s^-1].
-        da = Wa - offset[i]                         # Offset of spin-lock 
from A.
-        db = Wb - offset[i]                         # Offset of spin-lock 
from B.
-        d = W - offset[i]                           # Offset of spin-lock 
from pop-average.
-        waeff2 = spin_lock_fields2[i] + da**2     # Effective field at A.
-        wbeff2 = spin_lock_fields2[i] + db**2     # Effective field at B.
-        weff2 = spin_lock_fields2[i] + d**2       # Effective field at 
pop-average.
+        da = Wa - offset                            # Offset of spin-lock 
from A.
+        db = Wb - offset                            # Offset of spin-lock 
from B.
+        d = W - offset                              # Offset of spin-lock 
from pop-average.
+        waeff2 = spin_lock_fields2[i] + da**2       # Effective field at A.
+        wbeff2 = spin_lock_fields2[i] + db**2       # Effective field at B.
+        weff2 = spin_lock_fields2[i] + d**2         # Effective field at 
pop-average.
 
         # The rotating frame flip angle.
         theta = atan(spin_lock_fields[i] / d)

Modified: branches/relax_disp/lib/dispersion/ns_r1rho_2site.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/lib/dispersion/ns_r1rho_2site.py?rev=21616&r1=21615&r2=21616&view=diff
==============================================================================
--- branches/relax_disp/lib/dispersion/ns_r1rho_2site.py (original)
+++ branches/relax_disp/lib/dispersion/ns_r1rho_2site.py Sun Nov 24 13:09:02 
2013
@@ -84,7 +84,7 @@
 
     # Loop over the time points, back calculating the R2eff values.
     for i in range(num_points):
-        Wsl = offset[i]                     # Larmor frequency of spin lock 
[s^-1].
+        Wsl = offset                        # Larmor frequency of spin lock 
[s^-1].
         dA = Wa - Wsl                       # Offset of spin-lock from A.
         dB = Wb - Wsl                       # Offset of spin-lock from B.
 

Modified: branches/relax_disp/lib/dispersion/tap03.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/lib/dispersion/tap03.py?rev=21616&r1=21615&r2=21616&view=diff
==============================================================================
--- branches/relax_disp/lib/dispersion/tap03.py (original)
+++ branches/relax_disp/lib/dispersion/tap03.py Sun Nov 24 13:09:02 2013
@@ -85,9 +85,9 @@
     # Loop over the dispersion points, back calculating the R1rho values.
     for i in range(num_points):
         # The factors.
-        da = Wa - offset[i]                         # Offset of spin-lock 
from A.
-        db = Wb - offset[i]                         # Offset of spin-lock 
from B.
-        d = W - offset[i]                           # Offset of spin-lock 
from pop-average.
+        da = Wa - offset    # Offset of spin-lock from A.
+        db = Wb - offset    # Offset of spin-lock from B.
+        d = W - offset      # Offset of spin-lock from pop-average.
 
         # The gamma factor.
         sigma = pB*da + pA*db

Modified: branches/relax_disp/lib/dispersion/tp02.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/lib/dispersion/tp02.py?rev=21616&r1=21615&r2=21616&view=diff
==============================================================================
--- branches/relax_disp/lib/dispersion/tp02.py (original)
+++ branches/relax_disp/lib/dispersion/tp02.py Sun Nov 24 13:09:02 2013
@@ -80,12 +80,12 @@
     for i in range(num_points):
         # We assume that A resonates at 0 [s^-1], without loss of generality.
         W = pA*Wa + pB*Wb                           # Pop-averaged Larmor 
frequency [s^-1].
-        da = Wa - offset[i]                         # Offset of spin-lock 
from A.
-        db = Wb - offset[i]                         # Offset of spin-lock 
from B.
-        d = W - offset[i]                           # Offset of spin-lock 
from pop-average.
-        waeff2 = spin_lock_fields2[i] + da**2     # Effective field at A.
-        wbeff2 = spin_lock_fields2[i] + db**2     # Effective field at B.
-        weff2 = spin_lock_fields2[i] + d**2       # Effective field at 
pop-average.
+        da = Wa - offset                            # Offset of spin-lock 
from A.
+        db = Wb - offset                            # Offset of spin-lock 
from B.
+        d = W - offset                              # Offset of spin-lock 
from pop-average.
+        waeff2 = spin_lock_fields2[i] + da**2       # Effective field at A.
+        wbeff2 = spin_lock_fields2[i] + db**2       # Effective field at B.
+        weff2 = spin_lock_fields2[i] + d**2         # Effective field at 
pop-average.
 
         # The rotating frame flip angle.
         theta = atan(spin_lock_fields[i] / d)

Modified: branches/relax_disp/specific_analyses/relax_disp/disp_data.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/specific_analyses/relax_disp/disp_data.py?rev=21616&r1=21615&r2=21616&view=diff
==============================================================================
--- branches/relax_disp/specific_analyses/relax_disp/disp_data.py (original)
+++ branches/relax_disp/specific_analyses/relax_disp/disp_data.py Sun Nov 24 
13:09:02 2013
@@ -1993,7 +1993,7 @@
     return key
 
 
-def return_offset_data(spins=None, spin_ids=None, fields=None, 
field_count=None):
+def return_offset_data(spins=None, spin_ids=None, fields=None, 
field_count=None, spin_lock_nu1=None):
     """Return numpy arrays of the chemical shifts, offsets and tilt angles.
 
     @keyword spins:         The list of spin containers in the cluster.
@@ -2004,72 +2004,89 @@
     @type fields:           list of float
     @keyword field_count:   The number of spectrometer field strengths.  
This may not be equal to the length of the fields list as the user may not 
have set the field strength.
     @type field_count:      int
+    @keyword spin_lock_nu1: The spin-lock field strengths to use instead of 
the user loaded values - to enable interpolation.
+    @type spin_lock_nu1:    list of lists of numpy rank-1 float arrays
     @return:                The numpy array structures of the chemical 
shifts in rad/s, spin-lock offsets in rad/s, and rotating frame tilt angles.  
For each structure, the first dimension corresponds to the spins of a spin 
block, the second to the spectrometer field strength, and the third is the 
dispersion points.  For the chemical shift structure, the third dimension is 
omitted.
-    @rtype:                 numpy rank-2 float array, numpy rank-3 float 
array, numpy rank-3 float array
-    """
-
-    # The spin count.
+    @rtype:                 list of numpy float arrays, list of numpy float 
arrays, list of lists of numpy float arrays
+    """
+
+    # Make sure offset data exists.
+    if not hasattr(cdp, 'spin_lock_offset'):
+        raise RelaxError("The spin-lock offsets have not been set.")
+
+    # The counts.
+    exp_num = num_exp_types()
     spin_num = len(spins)
 
+    # The spin-lock data.
+    if spin_lock_nu1 == None:
+        spin_lock_nu1 = return_spin_lock_nu1(ref_flag=False)
+
     # Initialise the data structures for the target function.
-    shifts = zeros((spin_num, field_count), float64)
-    offsets = zeros((spin_num, field_count, cdp.dispersion_points), float64)
-    theta = zeros((spin_num, field_count, cdp.dispersion_points), float64)
-
-    # Assemble the shift data.
+    shifts = []
+    offsets = []
+    theta = []
+    for exp_index in range(exp_num):
+        shifts.append([])
+        offsets.append([])
+        theta.append([])
+        for spin_index in range(spin_num):
+            shifts[exp_index].append([])
+            offsets[exp_index].append([])
+            theta[exp_index].append([])
+            for frq, frq_index in loop_frq(return_indices=True):
+                shifts[exp_index][spin_index].append(None)
+                offsets[exp_index][spin_index].append(None)
+                theta[exp_index][spin_index].append([])
+
+    # Assemble the data.
     data_flag = False
     for spin_index in range(spin_num):
         # Alias the spin.
         spin = spins[spin_index]
+        spin_id = spin_ids[spin_index]
 
         # No data.
         if not hasattr(spin, 'chemical_shift'):
             continue
         data_flag = True
 
-        # Loop over the spectrometer frequencies.
-        for frq, frq_index in loop_frq(return_indices=True):
+        # Loop over the experiments and spectrometer frequencies.
+        for exp_type, frq, exp_index, frq_index in 
loop_exp_frq(return_indices=True):
             # Convert the shift from ppm to rad/s and store it.
-            shifts[spin_index, frq_index] = spin.chemical_shift * 2.0 * pi * 
frq / g1H * return_gyromagnetic_ratio(spin.isotope) * 1e-6
+            shifts[exp_index][spin_index][frq_index] = spin.chemical_shift * 
2.0 * pi * frq / g1H * return_gyromagnetic_ratio(spin.isotope) * 1e-6
+
+            # Loop over the dispersion points.
+            for point_index in 
range(len(spin_lock_nu1[exp_index][frq_index])):
+                # Alias the point.
+                point = spin_lock_nu1[exp_index][frq_index][point_index]
+
+                # Skip reference spectra.
+                if point == None:
+                    continue
+
+                # Fetch all of the matching intensity keys.
+                keys = find_intensity_keys(exp_type=exp_type, frq=frq, 
point=point, raise_error=False)
+
+                # No data.
+                if not len(keys):
+                    continue
+
+                # Store the offset in rad/s.  Only once and using the first 
key.
+                if offsets[exp_index][spin_index][frq_index] == None:
+                    offsets[exp_index][spin_index][frq_index] = 
cdp.spin_lock_offset[keys[0]] * 2.0 * pi * frq / g1H * 
return_gyromagnetic_ratio(spin.isotope) * 1e-6
+
+                # Calculate the tilt angle.
+                omega1 = point * 2.0 * pi
+                Delta_omega = shifts[exp_index][spin_index][frq_index] - 
offsets[exp_index][spin_index][frq_index]
+                if Delta_omega == 0.0:
+                    theta[exp_index][spin_index][frq_index].append(pi / 2.0)
+                else:
+                    
theta[exp_index][spin_index][frq_index].append(atan(omega1 / Delta_omega))
 
     # No shift data for the spin cluster.
     if not data_flag:
         return None, None, None
-
-    # Make sure offset data exists.
-    if not hasattr(cdp, 'spin_lock_offset'):
-        raise RelaxError("The spin-lock offsets have not been set.")
-
-    # Loop over all spectrum IDs.
-    for id in cdp.exp_type.keys():
-        # The data.
-        exp_type = cdp.exp_type[id]
-        frq = cdp.spectrometer_frq[id]
-        point = cdp.spin_lock_nu1[id]
-
-        # Skip reference spectra.
-        if point == None:
-            continue
-
-        # The indices.
-        frq_index = return_index_from_frq(frq)
-        disp_pt_index = return_index_from_disp_point(point, 
exp_type=exp_type)
-
-        # Loop over the spins.
-        for spin_index in range(spin_num):
-            # Alias the spin.
-            spin = spins[spin_index]
-
-            # Store the offset in rad/s.
-            offsets[spin_index, frq_index, disp_pt_index] = 
cdp.spin_lock_offset[id] * 2.0 * pi * frq / g1H * 
return_gyromagnetic_ratio(spin.isotope) * 1e-6
-
-            # Calculate the tilt angle.
-            omega1 = point * 2.0 * pi
-            Delta_omega = shifts[spin_index, frq_index] - 
offsets[spin_index, frq_index, disp_pt_index]
-            if Delta_omega == 0.0:
-                theta[spin_index, frq_index, disp_pt_index] = pi / 2.0
-            else:
-                theta[spin_index, frq_index, disp_pt_index] = atan(omega1 / 
Delta_omega)
 
     # Return the structures.
     return shifts, offsets, theta

Modified: branches/relax_disp/target_functions/relax_disp.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/target_functions/relax_disp.py?rev=21616&r1=21615&r2=21616&view=diff
==============================================================================
--- branches/relax_disp/target_functions/relax_disp.py (original)
+++ branches/relax_disp/target_functions/relax_disp.py Sun Nov 24 13:09:02 
2013
@@ -587,7 +587,7 @@
                 phi_ex_scaled = phi_ex[spin_index] * 
self.frqs[0][spin_index][frq_index]**2
 
                 # Back calculate the R2eff values.
-                r1rho_DPL94(r1rho_prime=R20[r20_index], 
phi_ex=phi_ex_scaled, kex=kex, theta=self.tilt_angles[spin_index, frq_index], 
R1=self.r1[spin_index, frq_index], 
spin_lock_fields2=self.spin_lock_omega1_squared[0][frq_index], 
back_calc=self.back_calc[spin_index][frq_index], 
num_points=self.num_disp_points[0][frq_index])
+                r1rho_DPL94(r1rho_prime=R20[r20_index], 
phi_ex=phi_ex_scaled, kex=kex, 
theta=self.tilt_angles[0][spin_index][frq_index], R1=self.r1[spin_index, 
frq_index], spin_lock_fields2=self.spin_lock_omega1_squared[0][frq_index], 
back_calc=self.back_calc[spin_index][frq_index], 
num_points=self.num_disp_points[0][frq_index])
 
                 # For all missing data points, set the back-calculated value 
to the measured values so that it has no effect on the chi-squared value.
                 for point_index in range(self.num_disp_points[0][frq_index]):
@@ -882,7 +882,7 @@
                 dw_frq = dw[spin_index] * self.frqs[0][spin_index][frq_index]
 
                 # Back calculate the R1rho values.
-                r1rho_MP05(r1rho_prime=R20[r20_index], 
omega=self.chemical_shifts[spin_index, frq_index], 
offset=self.spin_lock_offsets[spin_index, frq_index], pA=pA, pB=pB, 
dw=dw_frq, kex=kex, R1=self.r1[spin_index, frq_index], 
spin_lock_fields=self.spin_lock_omega1[0][frq_index], 
spin_lock_fields2=self.spin_lock_omega1_squared[0][frq_index], 
back_calc=self.back_calc[spin_index][frq_index], 
num_points=self.num_disp_points[0][frq_index])
+                r1rho_MP05(r1rho_prime=R20[r20_index], 
omega=self.chemical_shifts[0][spin_index][frq_index], 
offset=self.spin_lock_offsets[0][spin_index][frq_index], pA=pA, pB=pB, 
dw=dw_frq, kex=kex, R1=self.r1[spin_index, frq_index], 
spin_lock_fields=self.spin_lock_omega1[0][frq_index], 
spin_lock_fields2=self.spin_lock_omega1_squared[0][frq_index], 
back_calc=self.back_calc[spin_index][frq_index], 
num_points=self.num_disp_points[0][frq_index])
 
                 # For all missing data points, set the back-calculated value 
to the measured values so that it has no effect on the chi-squared value.
                 for point_index in range(self.num_disp_points[0][frq_index]):
@@ -1279,7 +1279,7 @@
                 dw_frq = dw[spin_index] * self.frqs[0][spin_index][frq_index]
 
                 # Back calculate the R2eff values.
-                ns_r1rho_2site(M0=self.M0, 
r1rho_prime=r1rho_prime[r20_index], omega=self.chemical_shifts[spin_index, 
frq_index], offset=self.spin_lock_offsets[spin_index, frq_index], 
r1=self.r1[spin_index, frq_index], pA=pA, pB=pB, dw=dw_frq, k_AB=k_AB, 
k_BA=k_BA, spin_lock_fields=self.spin_lock_omega1[0][frq_index], 
relax_time=self.relax_times[0][frq_index], 
inv_relax_time=self.inv_relax_times[0][frq_index], 
back_calc=self.back_calc[spin_index][frq_index], 
num_points=self.num_disp_points[0][frq_index])
+                ns_r1rho_2site(M0=self.M0, 
r1rho_prime=r1rho_prime[r20_index], 
omega=self.chemical_shifts[0][spin_index][frq_index], 
offset=self.spin_lock_offsets[0][spin_index][frq_index], 
r1=self.r1[spin_index, frq_index], pA=pA, pB=pB, dw=dw_frq, k_AB=k_AB, 
k_BA=k_BA, spin_lock_fields=self.spin_lock_omega1[0][frq_index], 
relax_time=self.relax_times[0][frq_index], 
inv_relax_time=self.inv_relax_times[0][frq_index], 
back_calc=self.back_calc[spin_index][frq_index], 
num_points=self.num_disp_points[0][frq_index])
 
                 # For all missing data points, set the back-calculated value 
to the measured values so that it has no effect on the chi-squared value.
                 for point_index in range(self.num_disp_points[0][frq_index]):
@@ -1329,7 +1329,7 @@
                 dw_frq = dw[spin_index] * self.frqs[0][spin_index][frq_index]
 
                 # Back calculate the R1rho values.
-                r1rho_TAP03(r1rho_prime=R20[r20_index], 
omega=self.chemical_shifts[spin_index, frq_index], 
offset=self.spin_lock_offsets[spin_index, frq_index], pA=pA, pB=pB, 
dw=dw_frq, kex=kex, R1=self.r1[spin_index, frq_index], 
spin_lock_fields=self.spin_lock_omega1[0][frq_index], 
spin_lock_fields2=self.spin_lock_omega1_squared[0][frq_index], 
back_calc=self.back_calc[spin_index][frq_index], 
num_points=self.num_disp_points[0][frq_index])
+                r1rho_TAP03(r1rho_prime=R20[r20_index], 
omega=self.chemical_shifts[0][spin_index][frq_index], 
offset=self.spin_lock_offsets[0][spin_index][frq_index], pA=pA, pB=pB, 
dw=dw_frq, kex=kex, R1=self.r1[spin_index, frq_index], 
spin_lock_fields=self.spin_lock_omega1[0][frq_index], 
spin_lock_fields2=self.spin_lock_omega1_squared[0][frq_index], 
back_calc=self.back_calc[spin_index][frq_index], 
num_points=self.num_disp_points[0][frq_index])
 
                 # For all missing data points, set the back-calculated value 
to the measured values so that it has no effect on the chi-squared value.
                 for point_index in range(self.num_disp_points[0][frq_index]):
@@ -1379,7 +1379,7 @@
                 dw_frq = dw[spin_index] * self.frqs[0][spin_index][frq_index]
 
                 # Back calculate the R1rho values.
-                r1rho_TP02(r1rho_prime=R20[r20_index], 
omega=self.chemical_shifts[spin_index, frq_index], 
offset=self.spin_lock_offsets[spin_index, frq_index], pA=pA, pB=pB, 
dw=dw_frq, kex=kex, R1=self.r1[spin_index, frq_index], 
spin_lock_fields=self.spin_lock_omega1[0][frq_index], 
spin_lock_fields2=self.spin_lock_omega1_squared[0][frq_index], 
back_calc=self.back_calc[spin_index][frq_index], 
num_points=self.num_disp_points[0][frq_index])
+                r1rho_TP02(r1rho_prime=R20[r20_index], 
omega=self.chemical_shifts[0][spin_index][frq_index], 
offset=self.spin_lock_offsets[0][spin_index][frq_index], pA=pA, pB=pB, 
dw=dw_frq, kex=kex, R1=self.r1[spin_index, frq_index], 
spin_lock_fields=self.spin_lock_omega1[0][frq_index], 
spin_lock_fields2=self.spin_lock_omega1_squared[0][frq_index], 
back_calc=self.back_calc[spin_index][frq_index], 
num_points=self.num_disp_points[0][frq_index])
 
                 # For all missing data points, set the back-calculated value 
to the measured values so that it has no effect on the chi-squared value.
                 for point_index in range(self.num_disp_points[0][frq_index]):




Related Messages


Powered by MHonArc, Updated Sun Nov 24 13:40:02 2013