mailr10243 - /1.3/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 18, 2010 - 17:20:
Author: bugman
Date: Mon Jan 18 17:20:45 2010
New Revision: 10243

URL: http://svn.gna.org/viewcvs/relax?rev=10243&view=rev
Log:
The calculate() method now uses _target_fn_setup() and stores the chi2 in the 
cdp.


Modified:
    1.3/specific_fns/n_state_model.py

Modified: 1.3/specific_fns/n_state_model.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/specific_fns/n_state_model.py?rev=10243&r1=10242&r2=10243&view=diff
==============================================================================
--- 1.3/specific_fns/n_state_model.py (original)
+++ 1.3/specific_fns/n_state_model.py Mon Jan 18 17:20:45 2010
@@ -1405,35 +1405,42 @@
         @type sim_index:    None
         """
 
-        # Test if the N-state model has been set up.                         
                                                                              
 
-        if not hasattr(cdp, 'model'):                                        
                                                                              
 
-            raise RelaxNoModelError('N-state')                               
                                                                              
 
-
-        # Init some numpy arrays.
-        num_restraints = len(cdp.noe_restraints)
-        dist = zeros(num_restraints, float64)
-        pot = zeros(num_restraints, float64)
-        lower = zeros(num_restraints, float64)
-        upper = zeros(num_restraints, float64)
-
-        # Loop over the NOEs.
-        for i in range(num_restraints):
-            # Create arrays of the NOEs.
-            lower[i] = cdp.noe_restraints[i][2]
-            upper[i] = cdp.noe_restraints[i][3]
-
-            # Calculate the average distances, using -6 power averaging.
-            dist[i] = self._calc_ave_dist(cdp.noe_restraints[i][0], 
cdp.noe_restraints[i][1], exp=-6)
-
-        # Calculate the quadratic potential.
-        quad_pot(dist, pot, lower, upper)
-
-        # Store the distance and potential information.
-        cdp.ave_dist = []
-        cdp.quad_pot = []
-        for i in range(num_restraints):
-            cdp.ave_dist.append([cdp.noe_restraints[i][0], 
cdp.noe_restraints[i][1], dist[i]])
-            cdp.quad_pot.append([cdp.noe_restraints[i][0], 
cdp.noe_restraints[i][1], pot[i]])
+        # Set up the target function for direct calculation.
+        model, param_vector, data_types, scaling_matrix = 
self._target_fn_setup()
+
+        # Make a function call.
+        chi2 = model.func(param_vector)
+
+        # Store the global chi-squared value.
+        cdp.chi2 = chi2
+
+        # NOE potential.
+        if hasattr(cdp, 'noe_restraints'):
+            # Init some numpy arrays.
+            num_restraints = len(cdp.noe_restraints)
+            dist = zeros(num_restraints, float64)
+            pot = zeros(num_restraints, float64)
+            lower = zeros(num_restraints, float64)
+            upper = zeros(num_restraints, float64)
+
+            # Loop over the NOEs.
+            for i in range(num_restraints):
+                # Create arrays of the NOEs.
+                lower[i] = cdp.noe_restraints[i][2]
+                upper[i] = cdp.noe_restraints[i][3]
+
+                # Calculate the average distances, using -6 power averaging.
+                dist[i] = self._calc_ave_dist(cdp.noe_restraints[i][0], 
cdp.noe_restraints[i][1], exp=-6)
+
+            # Calculate the quadratic potential.
+            quad_pot(dist, pot, lower, upper)
+
+            # Store the distance and potential information.
+            cdp.ave_dist = []
+            cdp.quad_pot = []
+            for i in range(num_restraints):
+                cdp.ave_dist.append([cdp.noe_restraints[i][0], 
cdp.noe_restraints[i][1], dist[i]])
+                cdp.quad_pot.append([cdp.noe_restraints[i][0], 
cdp.noe_restraints[i][1], pot[i]])
 
 
     default_value_doc = """




Related Messages


Powered by MHonArc, Updated Mon Jan 18 17:40:01 2010