mailr15067 - in /branches/frame_order_testing/generic_fns: align_tensor.py pcs.py rdc.py


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

Header


Content

Posted by edward on December 08, 2011 - 14:34:
Author: bugman
Date: Thu Dec  8 14:34:38 2011
New Revision: 15067

URL: http://svn.gna.org/viewcvs/relax?rev=15067&view=rev
Log:
Fixes for the back-calculation of RDC and PCS data - the alignment tensor is 
now correctly returned.


Modified:
    branches/frame_order_testing/generic_fns/align_tensor.py
    branches/frame_order_testing/generic_fns/pcs.py
    branches/frame_order_testing/generic_fns/rdc.py

Modified: branches/frame_order_testing/generic_fns/align_tensor.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/generic_fns/align_tensor.py?rev=15067&r1=15066&r2=15067&view=diff
==============================================================================
--- branches/frame_order_testing/generic_fns/align_tensor.py (original)
+++ branches/frame_order_testing/generic_fns/align_tensor.py Thu Dec  8 
14:34:38 2011
@@ -37,6 +37,7 @@
 from generic_fns import pipes
 from physical_constants import g1H, h_bar, kB, mu0, return_gyromagnetic_ratio
 from relax_errors import RelaxError, RelaxNoTensorError, RelaxStrError, 
RelaxTensorError, RelaxUnknownParamCombError, RelaxUnknownParamError
+from relax_warnings import RelaxWarning
 
 
 def align_data_exists(tensor, pipe=None):
@@ -576,15 +577,17 @@
     return gdo
 
 
-def get_tensor_index(tensor, pipe=None):
+def get_tensor_index(tensor=None, align_id=None, pipe=None):
     """Function for returning the index corresponding to the 'tensor' 
argument.
 
-    @param tensor:  The alignment tensor identification string.
-    @type tensor:   str
-    @param pipe:    The data pipe to search for data in.
-    @type pipe:     str
-    @return:        The index corresponding to the 'tensor' arg.
-    @rtype:         int
+    @keyword tensor:    The alignment tensor identification string.
+    @type tensor:       str or None
+    @keyword align_id:  Alternative to the tensor argument, used to return 
the tensor index for the tensors corresponding to the alignment ID string.  
If more than one tensor exists, then this will fail.
+    @type align_id:     str or None
+    @keyword pipe:      The data pipe to search for data in.
+    @type pipe:         str
+    @return:            The index corresponding to the 'tensor' arg.
+    @rtype:             int
     """
 
     # The data pipe to check.
@@ -596,11 +599,29 @@
 
     # Init.
     index = None
+    count = 0
 
     # Loop over the tensors.
     for i in xrange(len(dp.align_tensors)):
-        if dp.align_tensors[i].name == tensor:
+        # Tensor name match.
+        if tensor and dp.align_tensors[i].name == tensor:
             index = i
+            count += 1
+
+        # Alignment ID match.
+        if align_id and hasattr(dp.align_tensors[i], 'align_id') and 
dp.align_tensors[i].align_id == align_id:
+            index = i
+            count += 1
+
+    # No match.
+    if count == 0:
+        warn(RelaxWarning("No alignment tensors match the tensor name '%s' 
or alignment ID '%s'." % (tensor, align_id)))
+        return None
+
+    # More than one match.
+    if count > 1: 
+        warn(RelaxWarning("More than one alignment tensors matches the 
tensor name '%s' or alignment ID '%s'." % (tensor, align_id)))
+        return None
 
     # Return the index.
     return index

Modified: branches/frame_order_testing/generic_fns/pcs.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/generic_fns/pcs.py?rev=15067&r1=15066&r2=15067&view=diff
==============================================================================
--- branches/frame_order_testing/generic_fns/pcs.py (original)
+++ branches/frame_order_testing/generic_fns/pcs.py Thu Dec  8 14:34:38 2011
@@ -110,7 +110,7 @@
                 spin.pcs_bc = {}
 
             # Calculate the PCSs (in ppm).
-            spin.pcs_bc[id] = ave_pcs_tensor(dj, vect, cdp.N, 
cdp.align_tensors[get_tensor_index(id)].A, weights=weights) * 1e6
+            spin.pcs_bc[id] = ave_pcs_tensor(dj, vect, cdp.N, 
cdp.align_tensors[get_tensor_index(align_id=id)].A, weights=weights) * 1e6
 
 
 def centre(pos=None, atom_id=None, pipe=None, verbosity=1, ave_pos=False, 
force=False):

Modified: branches/frame_order_testing/generic_fns/rdc.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/generic_fns/rdc.py?rev=15067&r1=15066&r2=15067&view=diff
==============================================================================
--- branches/frame_order_testing/generic_fns/rdc.py (original)
+++ branches/frame_order_testing/generic_fns/rdc.py Thu Dec  8 14:34:38 2011
@@ -112,7 +112,7 @@
 
         # Calculate the RDCs.
         for id in align_ids:
-            spin.rdc_bc[id] = ave_rdc_tensor(dj, unit_vect, cdp.N, 
cdp.align_tensors[get_tensor_index(id)].A, weights=weights)
+            spin.rdc_bc[id] = ave_rdc_tensor(dj, unit_vect, cdp.N, 
cdp.align_tensors[get_tensor_index(align_id=id)].A, weights=weights)
 
 
 def convert(value, align_id, to_intern=False):




Related Messages


Powered by MHonArc, Updated Thu Dec 08 15:00:02 2011