mailr6932 - /branches/rdc_analysis/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 July 10, 2008 - 13:26:
Author: bugman
Date: Thu Jul 10 13:26:51 2008
New Revision: 6932

URL: http://svn.gna.org/viewcvs/relax?rev=6932&view=rev
Log:
Wrote the __assemble_scaling_matrix() method for creating a scaling matrix 
for the N-state model.


Modified:
    branches/rdc_analysis/specific_fns/n_state_model.py

Modified: branches/rdc_analysis/specific_fns/n_state_model.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/rdc_analysis/specific_fns/n_state_model.py?rev=6932&r1=6931&r2=6932&view=diff
==============================================================================
--- branches/rdc_analysis/specific_fns/n_state_model.py (original)
+++ branches/rdc_analysis/specific_fns/n_state_model.py Thu Jul 10 13:26:51 
2008
@@ -22,7 +22,7 @@
 
 # Python module imports.
 from math import acos, cos, pi
-from numpy import array, dot, float64, zeros
+from numpy import array, dot, float64, identity, zeros
 from numpy.linalg import norm
 from re import search
 from warnings import warn
@@ -46,6 +46,35 @@
 
 class N_state_model(Common_functions):
     """Class containing functions for the N-state model."""
+
+    def __assemble_scaling_matrix(self, data_type=None):
+        """Create and return the scaling matrix.
+
+        @keyword data_type: The type of data used in the optimisation - 
either 'rdc' or 'tensor'.
+        @type data_type:    str
+        @return:            The square and diagonal scaling matrix.
+        @rtype:             numpy rank-2 array
+        """
+
+        # Alias the current data pipe.
+        cdp = ds[ds.current_pipe]
+
+        # Initialise.
+        scaling_matrix = identity(self.param_num(), float64)
+
+        # Starting point of the populations.
+        pop_start = 0
+        if data_type == 'rdc':
+            pop_start = pop_start + 5*len(cdp.rdc_ids)
+
+        # Loop over the populations, and set the scaling factor.
+        factor = 100.0
+        for i in xrange(pop_start, pop_start + (cdp.N-1)):
+            scaling_matrix[i, i] = factor
+
+        # Return the matrix.
+        return scaling_matrix
+
 
     def __update_model(self):
         """Update the model parameters as necessary."""
@@ -708,6 +737,9 @@
         # Determine if alignment tensors or RDCs are to be used.
         data_type = self.__determine_data_type()
 
+        # Get the scaling matrix.
+        scaling_matrix = self.__assemble_scaling_matrix(data_type=data_type)
+
         # Set up minimisation using alignment tensors.
         if data_type == 'tensor':
             model = self.minimise_setup_tensors(param_vector=param_vector)




Related Messages


Powered by MHonArc, Updated Thu Jul 10 13:40:10 2008