mailr24933 - /branches/R1_fitting/specific_analyses/relax_disp/data.py


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

Header


Content

Posted by tlinnet on August 04, 2014 - 16:27:
Author: tlinnet
Date: Mon Aug  4 16:27:51 2014
New Revision: 24933

URL: http://svn.gna.org/viewcvs/relax?rev=24933&view=rev
Log:
Made function return_r1_err_data() be dependent on model type.

sr #3135(https://gna.org/support/?3135): Optimisation of the R1 relaxation 
rate for the off-resonance R1rho relaxation dispersion models.

Modified:
    branches/R1_fitting/specific_analyses/relax_disp/data.py

Modified: branches/R1_fitting/specific_analyses/relax_disp/data.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/R1_fitting/specific_analyses/relax_disp/data.py?rev=24933&r1=24932&r2=24933&view=diff
==============================================================================
--- branches/R1_fitting/specific_analyses/relax_disp/data.py    (original)
+++ branches/R1_fitting/specific_analyses/relax_disp/data.py    Mon Aug  4 
16:27:51 2014
@@ -4143,38 +4143,78 @@
     # Initialise the data structure.
     r1_err = -ones((spin_num, field_count), float64)
 
+    # Set testing flags.
+    flags = [False]*field_count
+
     # Check for the presence of data.
-    if not hasattr(cdp, 'ri_ids'):
+    if not hasattr(cdp, 'ri_ids') and spins[0].model not in  
MODEL_LIST_R1RHO_FIT_R1:
+        warn_text = "No R1 relaxation data has been loaded.  Setting it to 
0.0.  This is essential for the proper handling of offsets in off-resonance 
R1rho experiments."
+        error_text = "No R1 relaxation data has been loaded.  This is 
essential for the proper handling of offsets in off-resonance R1rho 
experiments."
         if has_r1rho_exp_type():
-            warn(RelaxWarning("No R1 relaxation data has been loaded.  This 
is essential for the proper handling of offsets in off-resonance R1rho 
experiments."))
-        return 0.0 * r1_err
-
-    # 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':
-            continue
-
-        # The frequency.
-        frq = cdp.spectrometer_frq[ri_id]
-        mi = return_index_from_frq(frq)
-
-        # Flip the flag.
-        flags[mi] = True
-
+            # For all R1rho models using R1, raise an error, if R1 has not 
been loaded.
+            if spins[0].model in MODEL_LIST_R1RHO_W_R1:
+                raise RelaxError(error_text)
+
+            # For all models not listed in R1rho models, raise a warning, 
and set 0.0 as value.
+            else:
+                warn(RelaxWarning(warn_text))
+                r1_err = 0.0 * r1_err
+
+        # For all non-R1rho experiments, return 0.0.
+        else:
+            r1_err = 0.0 * r1_err
+
+        # Return the data.
+        return r1_err
+
+    # For all R1rho models fitting R1.
+    elif spins[0].model in MODEL_LIST_R1RHO_FIT_R1:
         # Spin loop.
         for si in range(spin_num):
-            # FIXME:  This is a kludge - the data randomisation needs to be 
incorporated into the dispersion base_data_loop() method and the standard 
Monte Carlo simulation pathway used.
-            # Randomise the R1 data, when required.
-            if sim_index != None and (not hasattr(spins[si], 'ri_data_sim') 
or ri_id not in spins[si].ri_data_sim):
-                randomise_R1(spin=spins[si], ri_id=ri_id, N=cdp.sim_number)
-
-            # Store the data.
-            if sim_index != None:
-                r1_err[si, mi] = spins[si].ri_data_err_sim[ri_id][sim_index]
-            else:
-                r1_err[si, mi] = spins[si].ri_data_err[ri_id]
+            # Assign spin:
+            spin = spins[si]
+
+            # Loop over exp type and frq.
+            for exp_type, frq, ei, mi in loop_exp_frq(return_indices=True):
+                # Assign key
+                r20_key = generate_r20_key(exp_type=exp_type, frq=frq)
+
+                # If no Monte-Carlo simulations has been performed, there 
will be no error.
+                if not hasattr(spin, 'r1_fit_err'):
+                    r1_err[si, mi] = None
+
+                else:
+                    r1_err[si, mi] = spin.r1_fit_err[r20_key]
+
+                # Flip the flag.
+                flags[mi] = True
+
+    else:
+        # Loop over the Rx IDs.
+        for ri_id in cdp.ri_ids:
+            # Only use R1 data.
+            if cdp.ri_type[ri_id] != 'R1':
+                continue
+
+            # The frequency.
+            frq = cdp.spectrometer_frq[ri_id]
+            mi = return_index_from_frq(frq)
+
+            # Flip the flag.
+            flags[mi] = True
+
+            # Spin loop.
+            for si in range(spin_num):
+                # FIXME:  This is a kludge - the data randomisation needs to 
be incorporated into the dispersion base_data_loop() method and the standard 
Monte Carlo simulation pathway used.
+                # Randomise the R1 data, when required.
+                if sim_index != None and (not hasattr(spins[si], 
'ri_data_sim') or ri_id not in spins[si].ri_data_sim):
+                    randomise_R1(spin=spins[si], ri_id=ri_id, 
N=cdp.sim_number)
+
+                # Store the data.
+                if sim_index != None:
+                    r1_err[si, mi] = 
spins[si].ri_data_err_sim[ri_id][sim_index]
+                else:
+                    r1_err[si, mi] = spins[si].ri_data_err[ri_id]
 
     # Check the data to prevent user mistakes.
     for mi in range(field_count):




Related Messages


Powered by MHonArc, Updated Mon Aug 04 16:40:02 2014