mailr20842 - in /branches/relax_disp/specific_analyses/relax_disp: api.py disp_data.py


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

Header


Content

Posted by edward on September 05, 2013 - 14:25:
Author: bugman
Date: Thu Sep  5 14:25:02 2013
New Revision: 20842

URL: http://svn.gna.org/viewcvs/relax?rev=20842&view=rev
Log:
A number of fixes for the relax_disp.exp_type user function changes.

This follows from http://thread.gmane.org/gmane.science.nmr.relax.devel/4530, 
the thread about
supporting multiple data types such as SQ+MQ data simultaneously.


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

Modified: branches/relax_disp/specific_analyses/relax_disp/api.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/specific_analyses/relax_disp/api.py?rev=20842&r1=20841&r2=20842&view=diff
==============================================================================
--- branches/relax_disp/specific_analyses/relax_disp/api.py (original)
+++ branches/relax_disp/specific_analyses/relax_disp/api.py Thu Sep  5 
14:25:02 2013
@@ -866,12 +866,12 @@
                     continue
 
                 # Average the reference intensity data and errors.
-                ref_intensity = average_intensity(spin=spin, frq=frq, 
point=None, time=time)
-                ref_intensity_err = average_intensity(spin=spin, frq=frq, 
point=None, time=time, error=True)
+                ref_intensity = average_intensity(spin=spin, 
exp_type=exp_type, frq=frq, point=None, time=time)
+                ref_intensity_err = average_intensity(spin=spin, 
exp_type=exp_type, frq=frq, point=None, time=time, error=True)
 
                 # Average the intensity data and errors.
-                intensity = average_intensity(spin=spin, frq=frq, 
point=point, time=time)
-                intensity_err = average_intensity(spin=spin, frq=frq, 
point=point, time=time, error=True)
+                intensity = average_intensity(spin=spin, exp_type=exp_type, 
frq=frq, point=point, time=time)
+                intensity_err = average_intensity(spin=spin, 
exp_type=exp_type, frq=frq, point=point, time=time, error=True)
 
                 # Calculate the R2eff value.
                 spin.r2eff[param_key] = 
calc_two_point_r2eff(relax_time=time, I_ref=ref_intensity, I=intensity)
@@ -903,10 +903,10 @@
         # The R2eff model (with peak intensity base data).
         if cdp.model_type == 'R2eff':
             # Unpack the data.
-            spin, frq, point = data_id
+            spin, exp_type, frq, point = data_id
 
             # Back calculate the peak intensities.
-            values = self._back_calc_peak_intensities(spin=spin, frq=frq, 
point=point)
+            values = self._back_calc_peak_intensities(spin=spin, 
exp_type=exp_type, frq=frq, point=point)
 
         # All other models (with R2eff/R1rho base data).
         else:
@@ -1400,12 +1400,12 @@
         # The R2eff model.
         if cdp.model_type == 'R2eff':
             # Unpack the data.
-            spin, frq, point = data_id
+            spin, exp_type, frq, point = data_id
 
             # Generate the data structure to return.
             errors = []
             for time in cdp.relax_time_list:
-                errors.append(average_intensity(spin=spin, frq=frq, 
point=point, time=time, error=True))
+                errors.append(average_intensity(spin=spin, 
exp_type=exp_type, frq=frq, point=point, time=time, error=True))
 
         # All other models.
         else:

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=20842&r1=20841&r2=20842&view=diff
==============================================================================
--- branches/relax_disp/specific_analyses/relax_disp/disp_data.py (original)
+++ branches/relax_disp/specific_analyses/relax_disp/disp_data.py Thu Sep  5 
14:25:02 2013
@@ -54,7 +54,7 @@
 
 
 
-def average_intensity(spin=None, frq=None, point=None, time=None, 
sim_index=None, error=False):
+def average_intensity(spin=None, exp_type=None, frq=None, point=None, 
time=None, sim_index=None, error=False):
     """Return the average peak intensity for the spectrometer frequency, 
dispersion point, and relaxation time.
 
     This is for handling replicate peak intensity data.
@@ -62,6 +62,8 @@
 
     @keyword spin:      The spin container to average the peak intensities 
for.
     @type spin:         SpinContainer instance
+    @keyword exp_type:  The experiment type.
+    @type exp_type:     str
     @keyword frq:       The spectrometer frequency.
     @type frq:          float
     @keyword point:     The dispersion point data (either the spin-lock 
field strength in Hz or the nu_CPMG frequency in Hz).
@@ -77,7 +79,7 @@
     """
 
     # The keys.
-    int_keys = find_intensity_keys(frq=frq, point=point, time=time)
+    int_keys = find_intensity_keys(exp_type=exp_type, frq=frq, point=point, 
time=time)
 
     # Initialise.
     intensity = 0.0
@@ -241,6 +243,10 @@
     @rtype:             List of str
     """
 
+    # Check.
+    if exp_type == None:
+        raise RelaxError("The experiment type has not been supplied.")
+
     # The dispersion data.
     if exp_type in EXP_TYPE_LIST_CPMG:
         disp_data = cdp.cpmg_frqs
@@ -590,6 +596,17 @@
         yield time
 
 
+def num_exp_types():
+    """Count the number of experiment types present.
+
+    @return:    The number of experiment types.
+    @rtype:     int
+    """
+
+    # Return the count.
+    return len(cdp.exp_type_list)
+
+
 def plot_disp_curves(dir=None, force=None):
     """Custom 2D Grace plotting function for the dispersion curves.
 
@@ -616,7 +633,7 @@
         for spin, spin_id in spin_loop(return_id=True, skip_desel=True):
             # The unique file name.
             file_name = "disp%s.agr" % spin_id.replace('#', 
'_').replace(':', '_').replace('@', '_')
-            if num_exp_type > 1:
+            if num_exp_types() > 1:
                 file_name = exp_type.replace(' ', '_') + file_name
 
             # Open the file for writing.
@@ -811,7 +828,7 @@
                 # Loop over the relaxation time periods.
                 for time in cdp.relax_time_list:
                     # The key.
-                    keys = find_intensity_keys(frq=frq, point=disp_point, 
time=time)
+                    keys = find_intensity_keys(exp_type=exp_type, frq=frq, 
point=disp_point, time=time)
 
                     # Loop over each key.
                     for key in keys:
@@ -994,22 +1011,24 @@
         return return_index_from_disp_point(cdp.spin_lock_nu1[key])
 
 
-def return_intensity(spin=None, frq=None, point=None, time=None, ref=False):
+def return_intensity(spin=None, exp_type=None, frq=None, point=None, 
time=None, ref=False):
     """Return the peak intensity corresponding to the given field strength 
and dispersion point.
 
     The corresponding reference intensity can be returned if the ref flag is 
set.  This assumes that the data is of the fixed relaxation time period type.
 
 
-    @keyword spin:  The spin container object.
-    @type spin:     SpinContainer instance
-    @keyword frq:   The spectrometer frequency.
-    @type frq:      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.
-    @type time:     float
-    @keyword ref:   A flag which if True will cause the corresponding 
reference intensity to be returned instead.
-    @type ref:      bool
+    @keyword spin:      The spin container object.
+    @type spin:         SpinContainer instance
+    @keyword exp_type:  The experiment type.
+    @type exp_type:     str
+    @keyword frq:       The spectrometer frequency.
+    @type frq:          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.
+    @type time:         float
+    @keyword ref:       A flag which if True will cause the corresponding 
reference intensity to be returned instead.
+    @type ref:          bool
     """
 
     # Checks.
@@ -1018,9 +1037,9 @@
 
     # The key.
     if ref:
-        keys = find_intensity_keys(frq=frq, point=None, time=time)
+        keys = find_intensity_keys(exp_type=exp_type, frq=frq, point=None, 
time=time)
     else:
-        keys = find_intensity_keys(frq=frq, point=point, time=time)
+        keys = find_intensity_keys(exp_type=exp_type, frq=frq, point=point, 
time=time)
 
     # Return the intensity.
     return spin.intensities[key]




Related Messages


Powered by MHonArc, Updated Thu Sep 05 14:40:01 2013