mailr20700 - /branches/relax_disp/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 August 27, 2013 - 15:13:
Author: bugman
Date: Tue Aug 27 15:13:30 2013
New Revision: 20700

URL: http://svn.gna.org/viewcvs/relax?rev=20700&view=rev
Log:
Added checks to the specific_analyses.relax_disp.disp_data.return_r1_data() 
function.

This is to help indicate to the user when data is missing.


Modified:
    branches/relax_disp/specific_analyses/relax_disp/disp_data.py

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=20700&r1=20699&r2=20700&view=diff
==============================================================================
--- branches/relax_disp/specific_analyses/relax_disp/disp_data.py (original)
+++ branches/relax_disp/specific_analyses/relax_disp/disp_data.py Tue Aug 27 
15:13:30 2013
@@ -929,13 +929,18 @@
     @rtype:                 numpy rank-2 float array
     """
 
+    # Check for the presence of data.
+    if not hasattr(cdp, 'ri_ids'):
+        raise RelaxError("No R1 relaxation data has been loaded.  This data 
is essential for certain off-resonance R1rho experiments.")
+
     # The spin count.
     spin_num = len(spins)
 
     # Initialise the data structure.
-    r1 = zeros((spin_num, field_count), float64)
+    r1 = -ones((spin_num, field_count), float64)
 
     # Loop over the Rx IDs.
+    flags = [False]*field_count
     for ri_id in cdp.ri_ids:
         # Only use R1 data.
         if cdp.ri_type[ri_id] != 'R1':
@@ -944,6 +949,9 @@
         # The frequency.
         frq = cdp.spectrometer_frq[ri_id]
         frq_index = return_index_from_frq(frq)
+
+        # Flip the flag.
+        flags[frq_index] = True
 
         # Spin loop.
         for spin_index in range(spin_num):
@@ -952,6 +960,20 @@
                 r1[spin_index, frq_index] = 
spins[spin_index].ri_data_sim[ri_id][sim_index]
             else:
                 r1[spin_index, frq_index] = spins[spin_index].ri_data[ri_id]
+
+    # Check the data to prevent user mistakes.
+    for frq_index in range(field_count):
+        # The frequency.
+        frq = return_value_from_frq_index(frq_index=frq_index)
+
+        # Check for R1 data for this frequency.
+        if not flags[frq_index]:
+            raise RelaxError("R1 data for the %.1f MHz field strength cannot 
be found." % (frq/1e6))
+
+        # Check the spin data.
+        for spin_index in range(spin_num):
+            if r1[spin_index, frq_index] == -1.0:
+                raise RelaxError("R1 data for the '%s' spin at %.1f MHz 
field strength cannot be found." % (spin_ids[spin_index], frq/1e6))
 
     # Return the data.
     return r1




Related Messages


Powered by MHonArc, Updated Wed Aug 28 09:40:02 2013