mailr6927 - /branches/rdc_analysis/maths_fns/rdc.py


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

Header


Content

Posted by edward on July 09, 2008 - 19:53:
Author: bugman
Date: Wed Jul  9 19:53:41 2008
New Revision: 6927

URL: http://svn.gna.org/viewcvs/relax?rev=6927&view=rev
Log:
Added weights to the average_rdc_tensor() function.


Modified:
    branches/rdc_analysis/maths_fns/rdc.py

Modified: branches/rdc_analysis/maths_fns/rdc.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/rdc_analysis/maths_fns/rdc.py?rev=6927&r1=6926&r2=6927&view=diff
==============================================================================
--- branches/rdc_analysis/maths_fns/rdc.py (original)
+++ branches/rdc_analysis/maths_fns/rdc.py Wed Jul  9 19:53:41 2008
@@ -86,7 +86,7 @@
     return val
 
 
-def average_rdc_tensor(vect, K, A):
+def average_rdc_tensor(vect, K, A, weights=None):
     """Calculate the average RDC for an ensemble set of XH bond vectors, 
using the 3D tensor.
 
     This function calculates the average RDC for a set of XH bond vectors 
from a structural
@@ -116,18 +116,33 @@
     @type K:            int
     @param A:           The alignment tensor.
     @type A:            numpy rank-2 3D tensor
+    @param weights:     The weights for each member of the ensemble.  The 
last weight is assumed to
+                        be missing, and is calculated by this function.  
Hence the length should be
+                        one less than K.
+    @type weights:      numpy rank-1 array
     """
 
     # Initial back-calculated RDC value.
     val = 0.0
 
+    # Averaging factor.
+    if weights == None:
+        c = 1.0 / K
+
     # Loop over the structures k.
     for k in xrange(K):
+        # The weights.
+        if weights != None:
+            if k == K-1: 
+                c = 1.0 - sum(weights, axis=0)
+            else:
+                c = weights[k]
+
         # Back-calculate the RDC.
-        val = val + dot(vect[k], dot(A, vect[k]))
+        val = val + c * dot(vect[k], dot(A, vect[k]))
 
     # Return the average RDC.
-    return val / K
+    return val
 
 
 def maxA(tensor):




Related Messages


Powered by MHonArc, Updated Wed Jul 09 20:00:15 2008