mailr8045 - /branches/spectral_errors/specific_fns/noe.py


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

Header


Content

Posted by edward on November 27, 2008 - 16:29:
Author: bugman
Date: Thu Nov 27 16:29:02 2008
New Revision: 8045

URL: http://svn.gna.org/viewcvs/relax?rev=8045&view=rev
Log:
Modified the NOE calculation code for the new spectra setup.


Modified:
    branches/spectral_errors/specific_fns/noe.py

Modified: branches/spectral_errors/specific_fns/noe.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/spectral_errors/specific_fns/noe.py?rev=8045&r1=8044&r2=8045&view=diff
==============================================================================
--- branches/spectral_errors/specific_fns/noe.py (original)
+++ branches/spectral_errors/specific_fns/noe.py Thu Nov 27 16:29:02 2008
@@ -81,11 +81,13 @@
         # Get the current data pipe.
         cdp = pipes.get_pipe()
 
-        # Test if the 2 spectra ids 'ref' and 'sat' exist.
-        if not 'ref' in cdp.spectrum_ids or not 'sat' in cdp.spectrum_ids:
+        # The spectrum types have not been set.
+        if not hasattr(cdp, 'spectrum_type'):
+            raise RelaxError, "The spectrum types have not been set."
+
+        # Test if the 2 spectra types 'ref' and 'sat' exist.
+        if not 'ref' in cdp.spectrum_type or not 'sat' in cdp.spectrum_type:
             raise RelaxError, "The reference and saturated NOE spectra have 
not been loaded."
-        if len(cdp.spectrum_ids) != 2:
-            raise RelaxError, "The spectrum ids %s should only consist of 
the labels 'ref' and 'sat'." % cdp.spectrum_ids
 
         # Loop over the spins.
         for spin in spin_loop():
@@ -93,11 +95,27 @@
             if not spin.select:
                 continue
 
+            # Average intensities (if required).
+            sat = 0.0
+            sat_err = 0.0
+            ref = 0.0
+            ref_err = 0.0
+            for i in xrange(len(cdp.spectrum_type)):
+                # Sat spectra.
+                if cdp.spectrum_type[i] == 'sat':
+                    sat = sat + spin.intensities[i]
+                    sat_err = sat_err + spin.intensity_err[i]
+            
+                # Ref spectra.
+                if cdp.spectrum_type[i] == 'ref':
+                    ref = ref + spin.intensities[i]
+                    ref_err = ref_err + spin.intensity_err[i]
+            
             # Calculate the NOE.
-            spin.noe = spin.sat / spin.ref
+            spin.noe = sat / ref
 
             # Calculate the error.
-            spin.noe_err = sqrt((spin.sat_err * spin.ref)**2 + (spin.ref_err 
* spin.sat)**2) / spin.ref**2
+            spin.noe_err = sqrt((sat_err * ref)**2 + (ref_err * sat)**2) / 
ref**2
 
 
     def overfit_deselect(self):




Related Messages


Powered by MHonArc, Updated Thu Nov 27 18:00:05 2008