mailr16668 - /1.3/generic_fns/relax_data.py


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

Header


Content

Posted by edward on June 05, 2012 - 15:17:
Author: bugman
Date: Tue Jun  5 15:17:58 2012
New Revision: 16668

URL: http://svn.gna.org/viewcvs/relax?rev=16668&view=rev
Log:
Added checks for the proton frq for the relax_data.read and 
relax_data.back_calc user functions.

This is in response to the problems seen by Martin Ballaschk <ballaschk att 
fmp-berlin dott de> and
reported at http://www.mail-archive.com/relax-users@xxxxxxx/msg01179.html 
(Message-Id:
<533CDA92-36FE-4E36-8925-7536EFF2608E@xxxxxxxxxxxxx>).

If the frequency is not exact or is less than 1 MHz, warnings are now given 
to the user.


Modified:
    1.3/generic_fns/relax_data.py

Modified: 1.3/generic_fns/relax_data.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/generic_fns/relax_data.py?rev=16668&r1=16667&r2=16668&view=diff
==============================================================================
--- 1.3/generic_fns/relax_data.py (original)
+++ 1.3/generic_fns/relax_data.py Tue Jun  5 15:17:58 2012
@@ -25,6 +25,7 @@
 
 # Python module imports.
 from copy import deepcopy
+from math import modf
 from numpy import array, float64, int32, ones, zeros
 import string
 import sys
@@ -77,6 +78,9 @@
     # Check if the type is valid.
     if ri_type and ri_type not in VALID_TYPES:
         raise RelaxError("The relaxation data type '%s' must be one of %s." 
% (ri_type, VALID_TYPES))
+
+    # Frequency checks.
+    frq_checks(frq)
 
     # Initialise the global data for the current pipe if necessary.
     if not hasattr(cdp, 'frq'):
@@ -505,6 +509,27 @@
 
     # Print the data.
     value.write_data(param=ri_id, file=sys.stdout, return_value=return_value)
+
+
+def frq_checks(frq):
+    """Perform a number of checks on the given frequency.
+
+    @param frq:     The proton frequency value.
+    @type frq:      float or None
+    """
+
+    # No frequency given.
+    if frq == None:
+        return
+
+    # Make sure the precise value has been supplied.
+    frac, integer = modf(frq / 1e6)
+    if frac == 0.0 or frac > 0.99999:
+        warn(RelaxWarning("The precise spectrometer frequency should be 
suppled, a value such as 500000000 or 5e8 for a 500 MHz machine is not 
acceptable.  Please see the 'sfrq' parameter in the Varian procpar file or 
the 'SFO1' parameter in the Bruker acqus file."))
+
+    # Check that Hz have been supplied.
+    if frq < 1e6:
+        warn(RelaxWarning("The proton frequency of %s should be in Hz, but 
it seems to be in MHz." % frq))
 
 
 def frq_loop():
@@ -793,6 +818,9 @@
     if ri_type not in VALID_TYPES:
         raise RelaxError("The relaxation data type '%s' must be one of %s." 
% (ri_type, VALID_TYPES))
 
+    # Frequency checks.
+    frq_checks(frq)
+
     # Loop over the file data to create the data structures for packing.
     values = []
     errors = []




Related Messages


Powered by MHonArc, Updated Tue Jun 05 16:00:01 2012