mailr24293 - /branches/disp_spin_speed/lib/dispersion/ns_r1rho_2site.py


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

Header


Content

Posted by tlinnet on June 25, 2014 - 02:14:
Author: tlinnet
Date: Wed Jun 25 02:14:34 2014
New Revision: 24293

URL: http://svn.gna.org/viewcvs/relax?rev=24293&view=rev
Log:
Shortened the code dramatically for NS R1rho 2site.

It is possible to calculate all in "one" go, after having the 
trasposer/rolled-back M0 magnetization.

Task #7807 (https://gna.org/task/index.php?7807): Speed-up of dispersion 
models for Clustered analysis.

Modified:
    branches/disp_spin_speed/lib/dispersion/ns_r1rho_2site.py

Modified: branches/disp_spin_speed/lib/dispersion/ns_r1rho_2site.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/disp_spin_speed/lib/dispersion/ns_r1rho_2site.py?rev=24293&r1=24292&r2=24293&view=diff
==============================================================================
--- branches/disp_spin_speed/lib/dispersion/ns_r1rho_2site.py   (original)
+++ branches/disp_spin_speed/lib/dispersion/ns_r1rho_2site.py   Wed Jun 25 
02:14:34 2014
@@ -241,22 +241,18 @@
     # Transpose M0, to prepare for dot operation. Roll the last axis one 
back.
     M0_T = rollaxis(M0, 6, 5)
 
-    if NS != 1:
-        # Magnetization evolution, which include all dimensions.
-        MA_mat = einsum('...ij,...jk', M0_T, Rexpo_M0_mat)
-
-    # Loop over the spectrometer frequencies.
-    for mi in range(NM):
-        # Loop over offsets:
-        for oi in range(NO):
-            # Extract number of points.
-            num_points_i = num_points[0, 0, mi, oi]
-
-            # Loop over the time points, back calculating the R2eff values.
-            for j in range(num_points_i):
-
-                # If the number of spins are 1, do the fastest method by dot 
product.  Else do it by einstein summation.
-                if NS == 1:
+    if NS == 1:
+        # Loop over the spectrometer frequencies.
+        for mi in range(NM):
+            # Loop over offsets:
+            for oi in range(NO):
+                # Extract number of points.
+                num_points_i = num_points[0, 0, mi, oi]
+    
+                # Loop over the time points, back calculating the R2eff 
values.
+                for j in range(num_points_i):
+    
+                    # If the number of spins are 1, do the fastest method by 
dot product.  Else do it by einstein summation.
                     # Set the spin index for one spin.
                     si = 0
                     # Extract the preformed matrix that rotate the 
magnetization previous to spin-lock into the weff frame.
@@ -274,27 +270,11 @@
                     else:
                         back_calc[0, si, mi, oi, j]= -inv_relax_time[0, si, 
mi, oi, j] * log(MA)
 
-                # If there is multiple spin a clustered analysis.
-                else:
-                    # Loop over spins.
-                    for si in range(NS):
-                        # Extract the preformed matrix that rotate the 
magnetization previous to spin-lock into the weff frame.
-                        M0_i= M0_T[0, si, mi, oi, j]
-
-                        # Extract from the pre-formed Magnetization 
evolution matrix.
-                        Rexpo_M0_mat_i = Rexpo_M0_mat[0, si, mi, oi, j]
-
-                        # Magnetization evolution.
-                        MA = dot(M0_i, Rexpo_M0_mat_i)[0, 0]
-
-                        MA_mat_i = MA_mat[0, si, mi, oi, j, 0, 0]
-
-                        # Diff
-                        diff = MA - MA_mat_i
-                        if diff != 0.0:
-                            print "oh no"
-
-                        if MA_mat_i <= 0.0 or isNaN(MA_mat_i):
-                            back_calc[0, si, mi, oi, j] = 1e99
-                        else:
-                            back_calc[0, si, mi, oi, j]= -inv_relax_time[0, 
si, mi, oi, j] * log(MA_mat_i)
+    else:
+        # Magnetization evolution, which include all dimensions.
+        MA_mat = einsum('...ij,...jk', M0_T, Rexpo_M0_mat)[:, :, :, :, :, 0, 
0]
+
+        # Do back calculation.
+        back_calc[:] = -inv_relax_time * log(MA_mat)
+
+




Related Messages


Powered by MHonArc, Updated Wed Jun 25 02:20:03 2014