mailr19345 - /branches/relax_disp/specific_analyses/relax_disp.py


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

Header


Content

Posted by edward on April 04, 2013 - 10:29:
Author: bugman
Date: Thu Apr  4 10:29:27 2013
New Revision: 19345

URL: http://svn.gna.org/viewcvs/relax?rev=19345&view=rev
Log:
Created the dispersion specific _exp_curve_loop() method for looping over 
each exponential curve.

This yields the index and key for each curve, simplifying the handling of 
this data.


Modified:
    branches/relax_disp/specific_analyses/relax_disp.py

Modified: branches/relax_disp/specific_analyses/relax_disp.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/specific_analyses/relax_disp.py?rev=19345&r1=19344&r2=19345&view=diff
==============================================================================
--- branches/relax_disp/specific_analyses/relax_disp.py (original)
+++ branches/relax_disp/specific_analyses/relax_disp.py Thu Apr  4 10:29:27 
2013
@@ -102,13 +102,7 @@
             spin = spins[spin_index]
 
             # Loop over each exponential curve.
-            for exp_i in range(cdp.curve_count):
-                # The key.
-                if cdp.exp_type == 'cpmg':
-                    key = cdp.cpmg_frqs_list[exp_i]
-                else:
-                    key = cdp.spin_lock_nu1_list[exp_i]
-
+            for exp_i, key in self._exp_curve_loop():
                 # Loop over the model parameters.
                 for i in range(len(spin.params)):
                     # Effective transversal relaxation rate.
@@ -216,7 +210,7 @@
             spin = spins[spin_index]
 
             # Loop over each exponential curve.
-            for exp_i in range(cdp.curve_count):
+            for exp_i, key in self._exp_curve_loop():
                 # Effective transversal relaxation rate scaling.
                 scaling_matrix[param_index, param_index] = 1e-1
                 param_index += 1
@@ -461,6 +455,25 @@
 
             # Chemical shift difference between states A and B.
             spin.dw = param_vector[5]
+
+
+    def _exp_curve_loop(self):
+        """Generator method looping over the exponential curves, yielding 
the index and key pair.
+
+        @return:    The index of the exponential curve and the floating 
point number key used in the R2eff and I0 spin data structures.
+        @rtype:     int and float
+        """
+
+        # Loop over each exponential curve.
+        for i in range(cdp.curve_count):
+            # The experiment specific key.
+            if cdp.exp_type == 'cpmg':
+                key = cdp.cpmg_frqs_list[i]
+            else:
+                key = cdp.spin_lock_nu1_list[i]
+
+            # Yield the data.
+            yield i, key
 
 
     def _exp_type(self, exp_type='cpmg'):
@@ -554,7 +567,7 @@
             spin = spins[spin_index]
 
             # Loop over each exponential curve.
-            for exp_i in range(cdp.curve_count):
+            for exp_i, key in self._exp_curve_loop():
                 # Loop over the parameters.
                 for i in range(len(spin.params)):
                     # R2eff relaxation rate (from 0 to 40 s^-1).
@@ -678,7 +691,7 @@
             spin = spins[spin_index]
 
             # Loop over each exponential curve.
-            for exp_i in range(cdp.curve_count):
+            for exp_i, key in self._exp_curve_loop():
                 # Loop over the parameters.
                 for k in range(len(spin.params)):
                     # The transversal relaxation rate >= 0.




Related Messages


Powered by MHonArc, Updated Thu Apr 04 11:00:02 2013