mailr4866 - /branches/N_state_model/specific_fns/n_state_model.py


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

Header


Content

Posted by edward on January 21, 2008 - 12:42:
Author: bugman
Date: Mon Jan 21 12:42:35 2008
New Revision: 4866

URL: http://svn.gna.org/viewcvs/relax?rev=4866&view=rev
Log:
Completed the set_non_spin_params() method (maybe).


Modified:
    branches/N_state_model/specific_fns/n_state_model.py

Modified: branches/N_state_model/specific_fns/n_state_model.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/N_state_model/specific_fns/n_state_model.py?rev=4866&r1=4865&r2=4866&view=diff
==============================================================================
--- branches/N_state_model/specific_fns/n_state_model.py (original)
+++ branches/N_state_model/specific_fns/n_state_model.py Mon Jan 21 12:42:35 
2008
@@ -30,7 +30,7 @@
 from float import isNaN, isInf
 from maths_fns.n_state_model import N_state_opt
 from minfx.generic import generic_minimise
-from relax_errors import RelaxInfError, RelaxNaNError, RelaxNoModelError
+from relax_errors import RelaxError, RelaxInfError, RelaxNaNError, 
RelaxNoModelError
 from specific_fns.base_class import Common_functions
 
 
@@ -527,8 +527,8 @@
     def set_non_spin_params(self, value=None, param=None):
         """Function for setting all the N-state model parameter values.
 
-        @param value:   The parameter values.
-        @type value:    None, number, or list of numbers
+        @param value:   The parameter values (for defaults supply [None]).
+        @type value:    list of numbers or [None]
         @param param:   The parameter names.
         @type param:    None, str, or list of str
         """
@@ -539,6 +539,37 @@
         # Test if the N-state model has been set up.
         if not hasattr(cdp, 'N'):
             raise RelaxNoModelError, 'N-state'
+
+        # Get the model parameters if param is None.
+        if param == None:
+            param = cdp.params
+
+        # Test that the parameter and value lists are the same size.
+        if type(param) == list and value[0] != None and len(param) != 
len(value):
+            raise RelaxError, "The length of " + `len(value)` + " of the 
value array must be equal to the length of the parameter array, " + `param` + 
"."
+
+        # Convert param to a list (if it is a string).
+        if type(param) == str:
+            param = [param]
+
+        # If no value is supplied (i.e. value == [None]), then get the 
default values.
+        if value == [None]:
+            value = []
+            for i in xrange(len(param)):
+                value.append(self.default_value(param[i]))
+
+        # Set the parameter values.
+        for i in xrange(len(param)):
+            # Get the object name and the parameter index.
+            object_name, index = self.return_data_name(param[i], index=True)
+            if not object_name:
+                raise RelaxError, "The data type " + `param[i]` + " does not 
exist."
+
+            # Get the object.
+            object = getattr(cdp, object_name)
+
+            # Set the parameter value.
+            object[index] = value[i]
 
 
     def set_type(self, tensor=None, red=None):




Related Messages


Powered by MHonArc, Updated Mon Jan 21 13:00:24 2008