Author: bugman Date: Tue Apr 16 10:51:48 2013 New Revision: 19483 URL: http://svn.gna.org/viewcvs/relax?rev=19483&view=rev Log: The spectrum.error_analysis user function can now be performed on a subset of all spectra. The subset argument has been added to allow the error analysis to be restricted to a subset of all loaded spectral data. Modified: trunk/pipe_control/spectrum.py trunk/user_functions/spectrum.py Modified: trunk/pipe_control/spectrum.py URL: http://svn.gna.org/viewcvs/relax/trunk/pipe_control/spectrum.py?rev=19483&r1=19482&r2=19483&view=diff ============================================================================== --- trunk/pipe_control/spectrum.py (original) +++ trunk/pipe_control/spectrum.py Tue Apr 16 10:51:48 2013 @@ -60,9 +60,11 @@ spin.intensity_err = spin.baseplane_rmsd -def __errors_repl(verbosity=0): +def __errors_repl(subset=None, verbosity=0): """Calculate the errors for peak intensities from replicated spectra. + @keyword subset: The list of spectrum ID strings to restrict the analysis to. + @type subset: list of str @keyword verbosity: The amount of information to print. The higher the value, the greater the verbosity. @type verbosity: int """ @@ -82,8 +84,14 @@ cdp.sigma_I = {} cdp.var_I = {} + # The subset. + subset_flag = False + if not subset: + subset_flag = True + subset = cdp.spectrum_ids + # Loop over the spectra. - for id in cdp.spectrum_ids: + for id in subset: # Skip non-replicated spectra. if not repl[id]: continue @@ -172,7 +180,10 @@ # Average across all spectra if there are time points with a single spectrum. if not all_repl: # Print out. - print("\nVariance averaging over all spectra.") + if subset_flag: + print("\nVariance averaging over the spectra subset.") + else: + print("\nVariance averaging over all spectra.") # Initialise. var_I = 0.0 @@ -192,7 +203,7 @@ var_I = var_I / float(num_dups) # Assign the average value to all time points. - for id in cdp.spectrum_ids: + for id in subset: cdp.var_I[id] = var_I # Print out. @@ -213,7 +224,7 @@ spin.intensity_err = cdp.sigma_I -def __errors_volume_no_repl(): +def __errors_volume_no_repl(subset=None): """Calculate the errors for peak volumes when no spectra are replicated.""" # Loop over the spins and set the error to the RMSD of the base plane noise. @@ -365,8 +376,12 @@ del spin.intensities[spectrum_id] -def error_analysis(): - """Determine the peak intensity standard deviation.""" +def error_analysis(subset=None): + """Determine the peak intensity standard deviation. + + @keyword subset: The list of spectrum ID strings to restrict the analysis to. + @type subset: list of str + """ # Test if the current pipe exists pipes.test() @@ -378,6 +393,12 @@ # Test if spectra have been loaded. if not hasattr(cdp, 'spectrum_ids'): raise RelaxError("Error analysis is not possible, no spectra have been loaded.") + + # Check the IDs. + if subset: + for id in subset: + if id not in cdp.spectrum_ids: + raise RelaxError("The spectrum ID '%s' has not been loaded into relax." % id) # Peak height category. if cdp.int_method == 'height': @@ -390,12 +411,14 @@ print("Replicated spectra: Yes.") # Set the errors. - __errors_repl() + __errors_repl(subset=subset) # No replicated spectra. else: # Print out. print("Replicated spectra: No.") + if subset: + print("Spectra ID subset ignored.") # Set the errors. __errors_height_no_repl() @@ -411,7 +434,7 @@ print("Replicated spectra: Yes.") # Set the errors. - __errors_repl() + __errors_repl(subset=subset) # No replicated spectra. else: Modified: trunk/user_functions/spectrum.py URL: http://svn.gna.org/viewcvs/relax/trunk/user_functions/spectrum.py?rev=19483&r1=19482&r2=19483&view=diff ============================================================================== --- trunk/user_functions/spectrum.py (original) +++ trunk/user_functions/spectrum.py Tue Apr 16 10:51:48 2013 @@ -113,9 +113,19 @@ uf = uf_info.add_uf('spectrum.error_analysis') uf.title = "Perform an error analysis for peak intensities." uf.title_short = "Peak intensity error analysis." +uf.add_keyarg( + name = "subset", + py_type = "str_list", + desc_short = "subset spectrum IDs", + desc = "The list of spectrum ID strings to restrict the error analysis to.", + wiz_combo_iter = spectrum.get_ids, + wiz_read_only = True, + can_be_none = True +) # Description. uf.desc.append(Desc_container()) uf.desc[-1].add_paragraph("This user function must only be called after all peak intensities have been loaded and all other necessary spectral information set. This includes the baseplane RMSD and the number of points used in volume integration, both of which are only used if spectra have not been replicated.") +uf.desc[-1].add_paragraph("The error analysis can be restricted to a subset of the loaded spectral data. This is useful, for example, if half the spectra have been collected on one spectrometer and the other half on a different spectrometer.") uf.desc[-1].add_paragraph("Six different types of error analysis are supported depending on whether peak heights or volumes are supplied, whether noise is determined from replicated spectra or the RMSD of the baseplane noise, and whether all spectra or only a subset have been duplicated. These are:") table = uf_tables.add_table(label="table: peak intensity error analysis", caption="The six peak intensity error analysis types.") table.add_headings(["Int type", "Noise source", "Error scope"]) @@ -156,7 +166,7 @@ uf.backend = spectrum.error_analysis uf.menu_text = "&error_analysis" uf.gui_icon = "oxygen.categories.applications-education" -uf.wizard_height_desc = 550 +uf.wizard_height_desc = 530 uf.wizard_size = (1000, 700) uf.wizard_image = WIZARD_IMAGE_PATH + 'spectrum' + sep + 'spectrum_200.png' uf.wizard_apply_button = False