mailr21297 - /trunk/pipe_control/spectrum.py


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

Header


Content

Posted by edward on October 29, 2013 - 11:47:
Author: bugman
Date: Tue Oct 29 11:47:39 2013
New Revision: 21297

URL: http://svn.gna.org/viewcvs/relax?rev=21297&view=rev
Log:
Created the new pipe_control.spectrum.add_spectrum_id() function.

This is used to handle the creation of spectrum ID strings in the data store. 
 This way new spectrum
IDs can be created from different parts of relax in a controlled way.


Modified:
    trunk/pipe_control/spectrum.py

Modified: trunk/pipe_control/spectrum.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/pipe_control/spectrum.py?rev=21297&r1=21296&r2=21297&view=diff
==============================================================================
--- trunk/pipe_control/spectrum.py (original)
+++ trunk/pipe_control/spectrum.py Tue Oct 29 11:47:39 2013
@@ -240,6 +240,25 @@
         # Set the error to the RMSD multiplied by the square root of the 
total number of points.
         for key in spin.intensity.keys():
             spin.intensity_err[key] = spin.baseplane_rmsd[key] * sqrt(spin.N)
+
+
+def add_spectrum_id(spectrum_id=None):
+    """Add the spectrum ID to the data store.
+
+    @keyword spectrum_id:   The spectrum ID string.
+    @type spectrum_id:      str
+    """
+
+    # Initialise the structure, if needed.
+    if not hasattr(cdp, 'spectrum_ids'):
+        cdp.spectrum_ids = []
+
+    # The ID already exists.
+    if spectrum_id in cdp.spectrum_ids:
+        raise RelaxError("The spectrum ID '%s' already exists." % 
spectrum_id)
+
+    # Add the ID.
+    cdp.spectrum_ids.append(spectrum_id)
 
 
 def baseplane_rmsd(error=0.0, spectrum_id=None, spin_id=None):
@@ -569,15 +588,12 @@
     spectrum_ids = spectrum_id
     if isinstance(spectrum_id, str):
         spectrum_ids = [spectrum_id]
-    if not hasattr(cdp, 'spectrum_ids'):
-        cdp.spectrum_ids = []
+    if ncproc != None and not hasattr(cdp, 'ncproc'):
+        cdp.ncproc = {}
+    for i in range(len(spectrum_ids)):
+        add_spectrum_id(spectrum_ids[i])
         if ncproc != None:
-            cdp.ncproc = {}
-    for i in range(len(spectrum_ids)):
-        if not spectrum_ids[i] in cdp.spectrum_ids:
-            cdp.spectrum_ids.append(spectrum_ids[i])
-            if ncproc != None:
-                cdp.ncproc[spectrum_ids[i]] = ncproc
+            cdp.ncproc[spectrum_ids[i]] = ncproc
 
     # No data.
     if not data_flag:




Related Messages


Powered by MHonArc, Updated Tue Oct 29 12:00:02 2013