mailr2738 - in /1.2: dx/isosurface_3D.py generic_fns/model_selection.py specific_fns/hybrid.py specific_fns/model_free.py


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

Header


Content

Posted by edward . dauvergne on November 04, 2006 - 08:05:
Author: bugman
Date: Sat Nov  4 08:04:42 2006
New Revision: 2738

URL: http://svn.gna.org/viewcvs/relax?rev=2738&view=rev
Log:
Fix for bug #7616 (https://gna.org/bugs/index.php?7616).

This fixes the failure of the model selection between the global diffusion 
models when the local tm
models are included.  This is a very important bug fix.

The 'model_statistics()' function in the model-free and hybrid files have 
been modified.  The
'min_instances' argument to the function was not being utilised at all since 
r2516
(https://mail.gna.org/public/relax-commits/2006-07/msg00010.html) which 
introduced this bug.  The
argument has been renamed to 'global_stats'.  This 'global_stats' argument is 
feed in solely by the
model selection code.  That code decides if global statistics (which are 
summed for the local tm
models) should be utilised using the test:

    if self.num_instances[j] > self.min_instances or self.num_instances[j] == 
1:

The model selection function, if the global stats argument is 1 and 
'self.param_set' is equal to
'local_tm', will sum the chi2 values of the individual local tm models and 
return that value.

To fix an issue with the OpenDX code causing a failure of the test suite, the 
'min_instances'
argument in the call to the model statistics function has been dropped.


Modified:
    1.2/dx/isosurface_3D.py
    1.2/generic_fns/model_selection.py
    1.2/specific_fns/hybrid.py
    1.2/specific_fns/model_free.py

Modified: 1.2/dx/isosurface_3D.py
URL: 
http://svn.gna.org/viewcvs/relax/1.2/dx/isosurface_3D.py?rev=2738&r1=2737&r2=2738&view=diff
==============================================================================
--- 1.2/dx/isosurface_3D.py (original)
+++ 1.2/dx/isosurface_3D.py Sat Nov  4 08:04:42 2006
@@ -104,7 +104,7 @@
                     self.calculate(run=self.run, res_num=self.res_num, 
print_flag=0)
 
                     # Get the minimisation statistics for the model.
-                    k, n, chi2 = self.model_stats(run=self.run, 
instance=self.index, min_instances=1)
+                    k, n, chi2 = self.model_stats(run=self.run, 
instance=self.index)
 
                     # Set maximum value to 1e20 to stop the OpenDX server 
connection from breaking.
                     if chi2 > 1e20:

Modified: 1.2/generic_fns/model_selection.py
URL: 
http://svn.gna.org/viewcvs/relax/1.2/generic_fns/model_selection.py?rev=2738&r1=2737&r2=2738&view=diff
==============================================================================
--- 1.2/generic_fns/model_selection.py (original)
+++ 1.2/generic_fns/model_selection.py Sat Nov  4 08:04:42 2006
@@ -207,8 +207,14 @@
                     if self.skip_function[run](run=run, instance=i, 
min_instances=self.min_instances, num_instances=self.num_instances[j]):
                         continue
 
+                    # Global stats.
+                    if self.num_instances[j] > self.min_instances or 
self.num_instances[j] == 1:
+                        global_stats = 1
+                    else:
+                        global_stats = 0
+
                     # Get the model statistics.
-                    k, n, chi2 = self.model_statistics[run](run=run, 
instance=i, min_instances=self.min_instances)
+                    k, n, chi2 = self.model_statistics[run](run=run, 
instance=i, global_stats=global_stats)
 
                     # Missing data sets.
                     if k == None or n == None or chi2 == None:

Modified: 1.2/specific_fns/hybrid.py
URL: 
http://svn.gna.org/viewcvs/relax/1.2/specific_fns/hybrid.py?rev=2738&r1=2737&r2=2738&view=diff
==============================================================================
--- 1.2/specific_fns/hybrid.py (original)
+++ 1.2/specific_fns/hybrid.py Sat Nov  4 08:04:42 2006
@@ -89,7 +89,7 @@
         self.relax.data.hybrid_runs[hybrid] = runs
 
 
-    def model_statistics(self, run=None, instance=None, min_instances=None):
+    def model_statistics(self, run=None, instance=None, global_stats=None):
         """Function for returning the values k, n, and chi2 of the hybrid.
 
         k - number of parameters.
@@ -116,7 +116,7 @@
             # Loop over the instances.
             for i in xrange(num):
                 # Get the statistics.
-                k, n, chi2 = model_statistics(run, instance=i)
+                k, n, chi2 = model_statistics(run, instance=i, 
global_stats=global_stats)
 
                 # Bad stats.
                 if k == None or n == None or chi2 == None:

Modified: 1.2/specific_fns/model_free.py
URL: 
http://svn.gna.org/viewcvs/relax/1.2/specific_fns/model_free.py?rev=2738&r1=2737&r2=2738&view=diff
==============================================================================
--- 1.2/specific_fns/model_free.py (original)
+++ 1.2/specific_fns/model_free.py Sat Nov  4 08:04:42 2006
@@ -2505,7 +2505,7 @@
             self.relax.data.res[run][i].params = params
 
 
-    def model_statistics(self, run=None, instance=None, min_instances=None):
+    def model_statistics(self, run=None, instance=None, global_stats=None):
         """Function for returning k, n, and chi2.
 
         k - number of parameters.
@@ -2517,11 +2517,12 @@
         self.run = run
 
         # Determine if local or global statistics will be returned.
-        global_stats = 1
-        for i in xrange(len(self.relax.data.res[self.run])):
-            if hasattr(self.relax.data.res[self.run][i], 'chi2') and 
self.relax.data.res[self.run][i].chi2 != None:
-                global_stats = 0
-                break
+        if global_stats == None:
+            global_stats = 1
+            for i in xrange(len(self.relax.data.res[self.run])):
+                if hasattr(self.relax.data.res[self.run][i], 'chi2') and 
self.relax.data.res[self.run][i].chi2 != None:
+                    global_stats = 0
+                    break
 
         # Determine the parameter set type.
         self.param_set = self.determine_param_set_type()
@@ -2554,6 +2555,7 @@
 
             # Count the number of data points.
             n = 0
+            chi2 = 0
             for i in xrange(len(self.relax.data.res[self.run])):
                 # Skip unselected residues.
                 if not self.relax.data.res[self.run][i].select:
@@ -2565,8 +2567,13 @@
 
                 n = n + len(self.relax.data.res[self.run][i].relax_data)
 
+                # Local tm models.
+                if self.param_set == 'local_tm':
+                    chi2 = chi2 + self.relax.data.res[self.run][i].chi2
+
             # The chi2 value.
-            chi2 = self.relax.data.chi2[self.run]
+            if self.param_set != 'local_tm':
+                chi2 = self.relax.data.chi2[self.run]
 
         # Return the data.
         return k, n, chi2




Related Messages


Powered by MHonArc, Updated Sat Nov 04 08:20:08 2006