Author: bugman Date: Tue Oct 29 11:49:12 2013 New Revision: 21298 URL: http://svn.gna.org/viewcvs/relax?rev=21298&view=rev Log: Merged revisions 21297 via svnmerge from svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk ........ r21297 | bugman | 2013-10-29 11:47:39 +0100 (Tue, 29 Oct 2013) | 6 lines 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: branches/relax_disp/ (props changed) branches/relax_disp/pipe_control/spectrum.py Propchange: branches/relax_disp/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Tue Oct 29 11:49:12 2013 @@ -1,1 +1,1 @@ -/trunk:1-21292 +/trunk:1-21297 Modified: branches/relax_disp/pipe_control/spectrum.py URL: http://svn.gna.org/viewcvs/relax/branches/relax_disp/pipe_control/spectrum.py?rev=21298&r1=21297&r2=21298&view=diff ============================================================================== --- branches/relax_disp/pipe_control/spectrum.py (original) +++ branches/relax_disp/pipe_control/spectrum.py Tue Oct 29 11:49:12 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: