mailr19484 - in /branches/relax_disp: ./ pipe_control/spectrum.py user_functions/spectrum.py


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

Header


Content

Posted by edward on April 16, 2013 - 10:56:
Author: bugman
Date: Tue Apr 16 10:56:57 2013
New Revision: 19484

URL: http://svn.gna.org/viewcvs/relax?rev=19484&view=rev
Log:
Merged revisions 19474,19483 via svnmerge from 
svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk

........
  r19474 | bugman | 2013-04-13 18:25:14 +0200 (Sat, 13 Apr 2013) | 5 lines
  
  Added a warning for the spectrum.read user function if a peak intensity of 
zero is encountered.
  
  This value can cause singular matrix failures in certain optimisation.
........
  r19483 | bugman | 2013-04-16 10:51:48 +0200 (Tue, 16 Apr 2013) | 6 lines
  
  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:
    branches/relax_disp/   (props changed)
    branches/relax_disp/pipe_control/spectrum.py
    branches/relax_disp/user_functions/spectrum.py

Propchange: branches/relax_disp/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Apr 16 10:56:57 2013
@@ -1,1 +1,1 @@
-/trunk:1-19463
+/trunk:1-19483

Modified: branches/relax_disp/pipe_control/spectrum.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/pipe_control/spectrum.py?rev=19484&r1=19483&r2=19484&view=diff
==============================================================================
--- branches/relax_disp/pipe_control/spectrum.py (original)
+++ branches/relax_disp/pipe_control/spectrum.py Tue Apr 16 10:56:57 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:
@@ -648,6 +671,10 @@
         # Extract the data.
         H_name, X_name, spin_id, intensity, line = intensity_data[i]
 
+        # Sanity check.
+        if intensity == 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))

Modified: branches/relax_disp/user_functions/spectrum.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/user_functions/spectrum.py?rev=19484&r1=19483&r2=19484&view=diff
==============================================================================
--- branches/relax_disp/user_functions/spectrum.py (original)
+++ branches/relax_disp/user_functions/spectrum.py Tue Apr 16 10:56:57 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




Related Messages


Powered by MHonArc, Updated Tue Apr 16 11:20:02 2013