mailr21853 - /trunk/specific_analyses/relax_disp/disp_data.py


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

Header


Content

Posted by edward on December 07, 2013 - 17:35:
Author: bugman
Date: Sat Dec  7 17:35:24 2013
New Revision: 21853

URL: http://svn.gna.org/viewcvs/relax?rev=21853&view=rev
Log:
Improvements for the find_intensity_keys() dispersion analysis function.

This now handles the reference point None being converted to NaN in numpy 
arrays and the logic is
now clearer.


Modified:
    trunk/specific_analyses/relax_disp/disp_data.py

Modified: trunk/specific_analyses/relax_disp/disp_data.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/specific_analyses/relax_disp/disp_data.py?rev=21853&r1=21852&r2=21853&view=diff
==============================================================================
--- trunk/specific_analyses/relax_disp/disp_data.py (original)
+++ trunk/specific_analyses/relax_disp/disp_data.py Sat Dec  7 17:35:24 2013
@@ -275,13 +275,15 @@
             return exp_type, frq
 
 
-def find_intensity_keys(exp_type=None, frq=None, point=None, time=None, 
raise_error=True):
+def find_intensity_keys(exp_type=None, frq=None, offset=None, point=None, 
time=None, raise_error=True):
     """Return the key corresponding to the spectrometer frequency, 
dispersion point, and relaxation time.
 
     @keyword exp_type:      The experiment type.
     @type exp_type:         str
     @keyword frq:           The spectrometer frequency.
     @type frq:              float
+    @keyword offset:        The optional offset value for off-resonance 
R1rho-type data.
+    @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 time:          The relaxation time period.
@@ -296,6 +298,10 @@
     if exp_type == None:
         raise RelaxError("The experiment type has not been supplied.")
 
+    # Catch NaNs.
+    if isNaN(point):
+        point = None
+
     # The dispersion data.
     if exp_type in EXP_TYPE_LIST_CPMG:
         disp_data = cdp.cpmg_frqs
@@ -309,26 +315,31 @@
         if cdp.exp_type[id] != exp_type:
             continue
 
-        # The spectrometer frequency.
-        frq2 = None
-        if hasattr(cdp, 'spectrometer_frq'):
-            frq2 = cdp.spectrometer_frq[id]
-
-        # Matching frequency and dispersion point.
-        if frq2 == frq and id in disp_data.keys() and disp_data[id] == point:
-            # The reference point, so checking the time is pointless (and 
can fail as specifying the time should not be necessary).
-            if point == None:
-                ids.append(id)
-
-            # Matching time.
-            elif time == None:
-                ids.append(id)
-            elif cdp.relax_times[id] == time:
-                ids.append(id)
+        # Skip non-matching spectrometer frequencies.
+        if 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
+
+        # Skip non-matching dispersion points.
+        if disp_data[id] != point:
+            continue
+
+        # The reference point, so checking the time is pointless (and can 
fail as specifying the time should not be necessary).
+        if point == None or isNaN(point):
+            ids.append(id)
+
+        # Matching time.
+        elif time == None:
+            ids.append(id)
+        elif cdp.relax_times[id] == time:
+            ids.append(id)
 
     # Check for missing IDs.
     if raise_error and len(ids) == 0:
-        if point == None:
+        if point == None or isNaN(point):
             raise RelaxError("No reference intensity data could be found 
corresponding to the spectrometer frequency of %s MHz and relaxation time of 
%s s." % (frq*1e-6, time))
         else:
             raise RelaxError("No intensity data could be found corresponding 
to the spectrometer frequency of %s MHz, dispersion point of %s and 
relaxation time of %s s." % (frq*1e-6, point, time))




Related Messages


Powered by MHonArc, Updated Sat Dec 07 17:40:01 2013