mailr22297 - in /branches/double_rotor: ./ specific_analyses/relax_disp/ test_suite/unit_tests/_specific_analyses/_relax_disp/


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

Header


Content

Posted by edward on February 25, 2014 - 09:22:
Author: bugman
Date: Tue Feb 25 09:22:19 2014
New Revision: 22297

URL: http://svn.gna.org/viewcvs/relax?rev=22297&view=rev
Log:
Merged revisions 22291-22294 via svnmerge from 
svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk

........
  r22291 | tlinnet | 2014-02-24 17:06:33 +0100 (Mon, 24 Feb 2014) | 5 lines
  
  Modified unit test to pass.
  
  Regarding bug #21665, (https://gna.org/bugs/?21665) - Running a CPMG 
analysis with two fields at two delay times.
  
  Implemented as suggested in: 
https://mail.gna.org/public/relax-devel/2014-02/msg00142.html
........
  r22292 | tlinnet | 2014-02-24 17:06:35 +0100 (Mon, 24 Feb 2014) | 5 lines
  
  Expanded the loop_time function to optional take the offset and dispersion 
point as input for restricting looping.
  
  Regarding bug #21665, (https://gna.org/bugs/?21665) - Running a CPMG 
analysis with two fields at two delay times.
  
  This is implemented as suggested in: 
https://mail.gna.org/public/relax-devel/2014-02/msg00143.html
........
  r22293 | tlinnet | 2014-02-24 17:06:36 +0100 (Mon, 24 Feb 2014) | 5 lines
  
  Added system test for loop_time.
  
  Regarding bug #21665, (https://gna.org/bugs/?21665) - Running a CPMG 
analysis with two fields at two delay times.
  
  This system can be extended later for purposes to test the restriction of 
the looping.
........
  r22294 | tlinnet | 2014-02-24 18:28:11 +0100 (Mon, 24 Feb 2014) | 5 lines
  
  Replacing looping over time points from cdp.relax_time_list to 
loop_time(frq=frq).
  
  Regarding bug #21665, (https://gna.org/bugs/?21665) - Running a CPMG 
analysis with two fields at two delay times.
  
  loop_time has been modified to accept spectrometer frequency as input to 
restrict the looping.
........

Modified:
    branches/double_rotor/   (props changed)
    branches/double_rotor/specific_analyses/relax_disp/api.py
    branches/double_rotor/specific_analyses/relax_disp/disp_data.py
    
branches/double_rotor/test_suite/unit_tests/_specific_analyses/_relax_disp/test_disp_data.py

Propchange: branches/double_rotor/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Feb 25 09:22:19 2014
@@ -1,1 +1,1 @@
-/trunk:1-22289
+/trunk:1-22294

Modified: branches/double_rotor/specific_analyses/relax_disp/api.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/double_rotor/specific_analyses/relax_disp/api.py?rev=22297&r1=22296&r2=22297&view=diff
==============================================================================
--- branches/double_rotor/specific_analyses/relax_disp/api.py (original)
+++ branches/double_rotor/specific_analyses/relax_disp/api.py Tue Feb 25 
09:22:19 2014
@@ -149,7 +149,7 @@
         values = []
         errors = []
         times = []
-        for time in cdp.relax_time_list:
+        for time in loop_time(frq=frq):
             # The data.
             values.append(average_intensity(spin=spin, exp_type=exp_type, 
frq=frq, offset=offset, point=point, time=time))
             errors.append(average_intensity(spin=spin, exp_type=exp_type, 
frq=frq, offset=offset, point=point, time=time, error=True))
@@ -378,7 +378,7 @@
                 values = []
                 errors = []
                 times = []
-                for time in cdp.relax_time_list:
+                for time in loop_time(frq=frq):
                     values.append(average_intensity(spin=spin, 
exp_type=exp_type, frq=frq, offset=offset, point=point, time=time, 
sim_index=sim_index))
                     errors.append(average_intensity(spin=spin, 
exp_type=exp_type, frq=frq, offset=offset, point=point, time=time, 
error=True))
                     times.append(time)
@@ -1373,7 +1373,7 @@
 
             # Generate the data structure to return.
             errors = []
-            for time in cdp.relax_time_list:
+            for time in loop_time(frq=frq):
                 errors.append(average_intensity(spin=spin, 
exp_type=exp_type, frq=frq, offset=offset, point=point, time=time, 
error=True))
 
         # All other models.
@@ -1597,7 +1597,7 @@
 
             # Loop over each time point.
             ti = 0
-            for time in loop_time():
+            for time in loop_time(frq=frq):
                 # Get the intensity keys.
                 int_keys = find_intensity_keys(exp_type=exp_type, frq=frq, 
point=point, time=time)
 

Modified: branches/double_rotor/specific_analyses/relax_disp/disp_data.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/double_rotor/specific_analyses/relax_disp/disp_data.py?rev=22297&r1=22296&r2=22297&view=diff
==============================================================================
--- branches/double_rotor/specific_analyses/relax_disp/disp_data.py (original)
+++ branches/double_rotor/specific_analyses/relax_disp/disp_data.py Tue Feb 
25 09:22:19 2014
@@ -1281,13 +1281,17 @@
         yield id
 
 
-def loop_time(exp_type=None, frq=None, return_indices=False):
+def loop_time(exp_type=None, frq=None, offset=None, point=None, 
return_indices=False):
     """Generator method for looping over the relaxation times.
 
     @keyword exp_type:          The experiment type.
     @type exp_type:             str
     @keyword frq:               The spectrometer frequency in Hz.
     @type frq:                  float
+    @keyword offset:            The spin-lock or hard pulse offset value in 
ppm.
+    @type offset:               None or float
+    @keyword point:             The dispersion point data (either the 
spin-lock field strength in Hz or the nu_CPMG frequency in Hz).
+    @type point:                float
     @keyword return_indices:    A flag which if True will cause the 
relaxation time index to be returned as well.
     @type return_indices:       bool
     @return:                    The relaxation time.
@@ -1310,6 +1314,25 @@
                 # Skip non-matching spectrometer frequencies.
                 if frq != None and hasattr(cdp, 'spectrometer_frq') and 
cdp.spectrometer_frq[id] != frq:
                     continue
+
+                # Skip non-matching offsets.
+                if offset != None and hasattr(cdp, 'spin_lock_offset') and 
cdp.spin_lock_offset[id] != offset:
+                    continue
+
+                # The dispersion point filter.
+                if point != None:
+                    # No experiment type set.
+                    if not hasattr(cdp, 'exp_type') or id not in 
cdp.exp_type:
+                        continue
+
+                    # The experiment type.
+                    exp_type = cdp.exp_type[id]
+
+                    # The CPMG dispersion data.
+                    if exp_type in EXP_TYPE_LIST_CPMG:
+                        # No dispersion point data set.
+                        if not hasattr(cdp, 'cpmg_frqs') or id not in 
cdp.cpmg_frqs:
+                            continue
 
                 if time != cdp.relax_times[id]:
                     continue
@@ -1907,7 +1930,7 @@
                     set_labels.append("Spin %s" % id)
 
                 # Loop over the relaxation time periods.
-                for time in cdp.relax_time_list:
+                for time in loop_time(frq=frq):
                     # The key.
                     keys = find_intensity_keys(exp_type=exp_type, frq=frq, 
point=point, time=time)
 

Modified: 
branches/double_rotor/test_suite/unit_tests/_specific_analyses/_relax_disp/test_disp_data.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/double_rotor/test_suite/unit_tests/_specific_analyses/_relax_disp/test_disp_data.py?rev=22297&r1=22296&r2=22297&view=diff
==============================================================================
--- 
branches/double_rotor/test_suite/unit_tests/_specific_analyses/_relax_disp/test_disp_data.py
 (original)
+++ 
branches/double_rotor/test_suite/unit_tests/_specific_analyses/_relax_disp/test_disp_data.py
 Tue Feb 25 09:22:19 2014
@@ -25,7 +25,7 @@
 # relax module imports.
 from data_store import Relax_data_store; ds = Relax_data_store()
 from pipe_control import state
-from specific_analyses.relax_disp.disp_data import loop_exp_frq, 
loop_exp_frq_offset, loop_exp_frq_offset_point, loop_exp_frq_offset_point_time
+from specific_analyses.relax_disp.disp_data import loop_exp_frq, 
loop_exp_frq_offset, loop_exp_frq_offset_point, 
loop_exp_frq_offset_point_time, loop_time
 from status import Status; status = Status()
 from test_suite.unit_tests.base_classes import UnitTestCase
 
@@ -214,7 +214,7 @@
         # Original indices (ei, mi, oi).
         indices = [
             [0, 0, 0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 
16], 0],
-            [0, 1, 0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 
16], 1]
+            [0, 1, 0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 
16], 0]
         ]
 
         # Check the number of iterations.
@@ -291,3 +291,38 @@
                 j += 1
                 self.assertEqual(time, time_T2_2)
                 self.assertAlmostEqual(point, cpmg_2[j],3)
+
+
+    def test_loop_time(self):
+        """Unit test of the loop_time() function.
+
+        This uses the data of the saved state attached to U{bug 
#21665<https://gna.org/bugs/?21665>}.
+        """
+
+        # Load the state.
+        statefile = status.install_path + 
sep+'test_suite'+sep+'shared_data'+sep+'dispersion'+sep+'bug_21665.bz2'
+        state.load_state(statefile, force=True)
+
+        # Original data (exp_type, frq, offset, point).
+        data = [
+            ['SQ CPMG', 499862140.0, 0, [50.0, 100.0, 150.0, 200.0, 250.0, 
300.0, 350.0, 400.0, 450.0, 500.0, 550.0, 600.0, 650.0, 700.0, 800.0, 900.0, 
1000.0],0.04],
+            ['SQ CPMG', 599890858.69999993, 0, [33.3333, 66.666, 100.0, 
133.333, 166.666, 200.0, 233.333, 266.666, 300.0, 333.333, 366.666, 400.0, 
466.666, 533.333, 666.666, 866.666, 1000.0],0.06]
+        ]
+
+        # Original indices (ei, mi, oi, ti).
+        indices = [
+            [0, 0, 0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 
16], 0],
+            [0, 1, 0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 
16], 0]
+        ]
+
+        # Check the number of iterations.
+        print("Checking the number of iterations of the loop.")
+        count_frq = 0
+        for dat in data:
+            frq = dat[1]
+            for time, ti in loop_time(frq=frq, return_indices=True):
+                print(time, ti)
+                count_frq += 1
+        self.assertEqual(count_frq, 2)
+
+




Related Messages


Powered by MHonArc, Updated Tue Feb 25 09:40:02 2014