mailr20900 - /branches/relax_disp/specific_analyses/relax_disp/checks.py


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

Header


Content

Posted by edward on September 06, 2013 - 15:21:
Author: bugman
Date: Fri Sep  6 15:21:07 2013
New Revision: 20900

URL: http://svn.gna.org/viewcvs/relax?rev=20900&view=rev
Log:
Created some more specific_analyses.relax_disp.checks.check_*() functions.

This is for better checking of the dispersion data.  The 
check_spectra_id_setup() is useful for
checking that all of the spectrum information is set up.


Modified:
    branches/relax_disp/specific_analyses/relax_disp/checks.py

Modified: branches/relax_disp/specific_analyses/relax_disp/checks.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/relax_disp/specific_analyses/relax_disp/checks.py?rev=20900&r1=20899&r2=20900&view=diff
==============================================================================
--- branches/relax_disp/specific_analyses/relax_disp/checks.py (original)
+++ branches/relax_disp/specific_analyses/relax_disp/checks.py Fri Sep  6 
15:21:07 2013
@@ -27,8 +27,9 @@
 
 # relax module imports.
 from dep_check import C_module_exp_fn
-from lib.errors import RelaxError, RelaxFuncSetupError
+from lib.errors import RelaxError, RelaxFuncSetupError, RelaxNoFrqError, 
RelaxNoPeakIntensityError
 import specific_analyses
+from specific_analyses.relax_disp.variables import EXP_TYPE_CPMG, 
EXP_TYPE_R1RHO
 
 
 def check_c_modules():
@@ -54,7 +55,19 @@
 
     # Test if the curve count exists.
     if not hasattr(cdp, 'dispersion_points'):
-        raise RelaxError("The CPMG frequencies or spin-lock field strengths 
have not been set up.")
+        raise RelaxError("The CPMG frequencies or spin-lock field strengths 
have not been set for any spectra.")
+
+    # Check each spectrum ID.
+    for id in cdp.spectrum_ids:
+        # CPMG data.
+        if cdp.exp_type[id] == EXP_TYPE_CPMG:
+            if id not in cdp.cpmg_frqs:
+                raise RelaxError("The nu_CPMG frequency has not been set for 
the '%s' spectrum." % id)
+
+        # R1rho data.
+        elif cdp.exp_type[id] == EXP_TYPE_R1RHO:
+            if id not in cdp.spin_lock_nu1:
+                raise RelaxError("The spin-lock field strength has not been 
set for the '%s' spectrum." % id)
 
 
 def check_exp_type():
@@ -65,12 +78,12 @@
 
     # Test if the experiment type is set.
     if not hasattr(cdp, 'exp_type'):
-        raise RelaxError("The relaxation dispersion experiment type has not 
been set for any spectra.")
+        raise RelaxError("The relaxation dispersion experiment types have 
not been set for any spectra.")
 
     # Check each spectrum ID.
     for id in cdp.spectrum_ids:
         if id not in cdp.exp_type:
-            raise RelaxError("The relaxation dispersion experiment type has 
not been set for the %s spectrum." % id)
+            raise RelaxError("The relaxation dispersion experiment type has 
not been set for the '%s' spectrum." % id)
 
 
 def check_exp_type_fixed_time():
@@ -138,6 +151,72 @@
         raise 
RelaxFuncSetupError(specific_analyses.setup.get_string(function_type))
 
 
+def check_relax_times():
+    """Check if the spectrometer frequencies have been set up.
+
+    @raises RelaxError: If the spectrometer frequencies have not been set.
+    """
+
+    # Test if the experiment type is set.
+    if not hasattr(cdp, 'relax_times'):
+        raise RelaxError("The relaxation times have not been set for any 
spectra.")
+
+    # Check each spectrum ID.
+    for id in cdp.spectrum_ids:
+        if id not in cdp.relax_times:
+            raise RelaxError("The relaxation time has not been set for the 
'%s' spectrum." % id)
+
+
+def check_spectra_id_setup():
+    """Check that the data for each spectra ID is correctly set up.
+
+    This is an alias for the following checks:
+
+        - check_spectrum_ids()
+        - check_exp_type()
+        - check_spectrometer_frq()
+        - check_disp_points()
+        - check_relax_times()
+
+
+    @raises RelaxError: If data is missing.
+    """
+
+    # Perform the checks.
+    check_spectrum_ids()
+    check_exp_type()
+    check_spectrometer_frq()
+    check_disp_points()
+    check_relax_times()
+
+
+def check_spectrometer_frq():
+    """Check if the spectrometer frequencies have been set up.
+
+    @raises RelaxError: If the spectrometer frequencies have not been set.
+    """
+
+    # Test if the experiment type is set.
+    if not hasattr(cdp, 'spectrometer_frq'):
+        raise RelaxError("The spectrometer frequencies have not been set for 
any spectra.")
+
+    # Check each spectrum ID.
+    for id in cdp.spectrum_ids:
+        if id not in cdp.spectrometer_frq:
+            raise RelaxError("The spectrometer frequency has not been set 
for the '%s' spectrum." % id)
+
+
+def check_spectrum_ids():
+    """Check if spectrum IDs exist.
+
+    @raises RelaxNoPeakIntensityError:  If no spectrum IDs exist.
+    """
+
+    # The spectrum IDs structure.
+    if not hasattr(cdp, 'spectrum_ids') or len(cdp.spectrum_ids) == 0:
+        raise RelaxNoPeakIntensityError
+
+
 def get_times():
     """Create a per-experiment dictionary of relaxation times.
     




Related Messages


Powered by MHonArc, Updated Fri Sep 06 15:40:02 2013