Author: bugman Date: Fri Aug 2 20:59:02 2013 New Revision: 20515 URL: http://svn.gna.org/viewcvs/relax?rev=20515&view=rev Log: Moved the adding function of adding the spectrum id (and ncproc) to the relax data store. Progress sr #3043: (https://gna.org/support/index.php?3043) - support for NMRPipe seriesTab format *.ser. Shifting it to later will prevent the cdp.spectrum_ids list to be populated after the user calls the user function incorrectly. Troels E. Linnet provided this patch. Commit by: tlinnet _aaattt_ gmail_dot_com Signed-off-by: Edward d'Auvergne <edward@xxxxxxxxxxxxx> 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=20515&r1=20514&r2=20515&view=diff ============================================================================== --- trunk/pipe_control/spectrum.py (original) +++ trunk/pipe_control/spectrum.py Fri Aug 2 20:59:02 2013 @@ -712,6 +712,62 @@ # Replace the data. intensity_data[i][2] = spin_id + # Loop over the peak intensity data. + data = [] + data_flag = False + + for i in range(len(intensity_data)): + # Extract the data. + H_name, X_name, spin_id, intensity, line = intensity_data[i] + + # Convert the intensity data and spectrum IDs to lists if needed. + if not isinstance(intensity, list): + intensity = [intensity] + if not isinstance(spectrum_id, list): + spectrum_id = [spectrum_id] + + # Checks for matching length of spectrum IDs and intensities columns. + if len(spectrum_id) != len(intensity): + raise RelaxError("The spectrum ID list %s has a different number of elements to the intensity column list %s." % (spectrum_id, nr_int_col)) + + # Loop over the data. + for i in range(len(intensity)): + # Sanity check. + if intensity[i] == 0.0: + warn(RelaxWarning("A peak intensity of zero has been encountered for the spin '%s' - this could be fatal later on." % spin_id)) + + # Skip data. + if (X_name and X_name != heteronuc) or (H_name and H_name != proton): + warn(RelaxWarning("Proton and heteronucleus names do not match, skipping the data %s." % line)) + continue + + # Get the spin container. + spin = return_spin(spin_id) + if not spin: + warn(RelaxNoSpinWarning(spin_id)) + continue + + # Skip deselected spins. + if not spin.select: + continue + + # Initialise. + if not hasattr(spin, 'intensities'): + spin.intensities = {} + + # Intensity scaling. + if ncproc != None: + intensity[i] = intensity[i] / float(2**ncproc) + + # Add the data. + spin.intensities[spectrum_id[i]] = intensity[i] + + # Switch the flag. + data_flag = True + + # Append the data for printing out. + data.append([spin_id, repr(intensity[i])]) + # Add the spectrum id (and ncproc) to the relax data store. spectrum_ids = spectrum_id if isinstance(spectrum_id, str): @@ -726,62 +782,6 @@ if ncproc != None: cdp.ncproc[spectrum_ids[i]] = ncproc - # Loop over the peak intensity data. - data = [] - data_flag = False - - for i in range(len(intensity_data)): - # Extract the data. - H_name, X_name, spin_id, intensity, line = intensity_data[i] - - # Convert the intensity data and spectrum IDs to lists if needed. - if not isinstance(intensity, list): - intensity = [intensity] - if not isinstance(spectrum_id, list): - spectrum_id = [spectrum_id] - - # Checks for matching length of spectrum IDs and intensities columns. - if len(spectrum_id) != len(intensity): - raise RelaxError("The spectrum ID list %s has a different number of elements to the intensity column list %s." % (spectrum_id, nr_int_col)) - - # Loop over the data. - for i in range(len(intensity)): - # Sanity check. - if intensity[i] == 0.0: - warn(RelaxWarning("A peak intensity of zero has been encountered for the spin '%s' - this could be fatal later on." % spin_id)) - - # Skip data. - if (X_name and X_name != heteronuc) or (H_name and H_name != proton): - warn(RelaxWarning("Proton and heteronucleus names do not match, skipping the data %s." % line)) - continue - - # Get the spin container. - spin = return_spin(spin_id) - if not spin: - warn(RelaxNoSpinWarning(spin_id)) - continue - - # Skip deselected spins. - if not spin.select: - continue - - # Initialise. - if not hasattr(spin, 'intensities'): - spin.intensities = {} - - # Intensity scaling. - if ncproc != None: - intensity[i] = intensity[i] / float(2**ncproc) - - # Add the data. - spin.intensities[spectrum_id[i]] = intensity[i] - - # Switch the flag. - data_flag = True - - # Append the data for printing out. - data.append([spin_id, repr(intensity[i])]) - # No data. if not data_flag: # Delete all the data.