mailr15044 - in /branches/frame_order_testing: generic_fns/align_tensor.py prompt/align_tensor.py


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

Header


Content

Posted by edward on December 07, 2011 - 16:32:
Author: bugman
Date: Wed Dec  7 16:32:01 2011
New Revision: 15044

URL: http://svn.gna.org/viewcvs/relax?rev=15044&view=rev
Log:
Converted the align_tensor.init user function to accept the align_id and 
domain arguments.

The domain argument complements the align_tensor.set_domain user function 
whereas the align_id arg
is new and is used to associate a tensor with an alignment.  This is part of 
a redesign of how
alignment tensors are handled, as there can be multiple tensors per alignment 
if the molecule is
multi-domain.


Modified:
    branches/frame_order_testing/generic_fns/align_tensor.py
    branches/frame_order_testing/prompt/align_tensor.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=15044&r1=15043&r2=15044&view=diff
==============================================================================
--- branches/frame_order_testing/generic_fns/align_tensor.py (original)
+++ branches/frame_order_testing/generic_fns/align_tensor.py Wed Dec  7 
16:32:01 2011
@@ -631,7 +631,7 @@
     return data
 
 
-def init(tensor=None, params=None, scale=1.0, angle_units='deg', 
param_types=0, errors=False):
+def init(tensor=None, params=None, scale=1.0, angle_units='deg', 
param_types=0, align_id=None, domain=None, errors=False):
     """Function for initialising the alignment tensor.
 
     @keyword tensor:        The alignment tensor identification string.
@@ -642,11 +642,13 @@
     @type scale:            float
     @keyword angle_units:   The units for the angle parameters (either 'deg' 
or 'rad').
     @type angle_units:      str
-    @keyword param_types:   The type of parameters supplied.  The flag 
values correspond to, 0:
-                            {Axx, Ayy, Axy, Axz, Ayz}, and 1: {Azz, Axx-yy, 
Axy, Axz, Ayz}.
+    @keyword param_types:   The type of parameters supplied.  The flag 
values correspond to, 0: {Axx, Ayy, Axy, Axz, Ayz}, and 1: {Azz, Axx-yy, Axy, 
Axz, Ayz}.
     @type param_types:      int
-    @keyword errors:        A flag which determines if the alignment tensor 
data or its errors are
-                            being input.
+    @keyword align_id:      The alignment ID string that the tensor 
corresponds to.
+    @type align_id:         str or None
+    @keyword domain:        The domain label.
+    @type domain:           str or None
+    @keyword errors:        A flag which determines if the alignment tensor 
data or its errors are being input.
     @type errors:           bool
     """
 
@@ -661,6 +663,10 @@
     valid_types = ['deg', 'rad']
     if not angle_units in valid_types:
         raise RelaxError("The alignment tensor 'angle_units' argument " + 
repr(angle_units) + " should be either 'deg' or 'rad'.")
+
+    # Check that the domain is defined.
+    if domain and (not hasattr(cdp, 'domain') or domain not in 
cdp.domain.keys()):
+        raise RelaxError("The domain '%s' has not been defined.  Please use 
the domain user function." % domain)
 
     # Add the tensor ID to the current data pipe.
     if not hasattr(cdp, 'align_ids'):
@@ -828,6 +834,12 @@
     # Unknown parameter combination.
     else:
         raise RelaxUnknownParamCombError('param_types', param_types)
+
+    # Set the domain and alignment ID.
+    if domain:
+        set_domain(tensor=tensor, domain=domain)
+    if align_id:
+        set_domain(tensor=tensor, align_id=align_id)
 
 
 def map_bounds(param):
@@ -1789,6 +1801,28 @@
 """
 
 
+def set_align_id(tensor=None, align_id=None):
+    """Set the align ID string for the given tensor.
+
+    @keyword tensor:    The alignment tensor label.
+    @type tensor:       str
+    @keyword align_id:  The alignment ID string.
+    @type align_id:     str
+    """
+
+    # Loop over the tensors.
+    match = False
+    for tensor_cont in cdp.align_tensors:
+        # Find the matching tensor and then store the ID.
+        if tensor_cont.name == tensor:
+            tensor_cont.align_id = align_id
+            match = True
+
+    # The tensor label doesn't exist.
+    if not match:
+        raise RelaxNoTensorError('alignment', tensor)
+
+
 def set_domain(tensor=None, domain=None):
     """Set the domain label for the given tensor.
 

Modified: branches/frame_order_testing/prompt/align_tensor.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_testing/prompt/align_tensor.py?rev=15044&r1=15043&r2=15044&view=diff
==============================================================================
--- branches/frame_order_testing/prompt/align_tensor.py (original)
+++ branches/frame_order_testing/prompt/align_tensor.py Wed Dec  7 16:32:01 
2011
@@ -185,32 +185,48 @@
         align_tensor.fix(id=id, fixed=fixed)
 
 
-    def init(self, tensor=None, params=None, scale=1.0, angle_units='deg', 
param_types=0, errors=False):
-        """Function for initialising the alignment tensor.
-
-        Keyword Arguments
-        ~~~~~~~~~~~~~~~~~
-
-        tensor:  The alignment tensor identification string.
-
-        params:  The alignment tensor data.
-
-        scale:  The alignment tensor eigenvalue scaling value.
-
-        angle_units:  The units for the angle parameters.
-
-        param_types:  A flag to select different parameter combinations.
-
-        errors:  A flag which determines if the alignment tensor data or its 
errors are being input.
-
-
-        Description
-        ~~~~~~~~~~~
-
-        Using this function, the alignment tensor data can be set up.  The 
params argument should be
-        a tuple of floating point numbers (a list surrounded by round 
brakets).  These correspond to
-        the parameters of the tensor, which can be specified by the 
param_types argument, where the
-        values correspond to
+    def init(self, tensor=None, params=None, scale=1.0, angle_units='deg', 
param_types=0, align_id=None, domain=None, errors=False):
+        # Function intro text.
+        if self._exec_info.intro:
+            text = self._exec_info.ps3 + "align_tensor.init("
+            text = text + "tensor=" + repr(tensor)
+            text = text + ", params=" + repr(params)
+            text = text + ", scale=" + repr(scale)
+            text = text + ", angle_units=" + repr(angle_units)
+            text = text + ", param_types=" + repr(param_types)
+            text = text + ", align_id=" + repr(align_id)
+            text = text + ", domain=" + repr(domain)
+            text = text + ", errors=" + repr(errors) + ")"
+            print(text)
+
+        # The argument checks.
+        arg_check.is_str(tensor, 'tensor')
+        arg_check.is_num_tuple(params, 'alignment tensor parameters', size=5)
+        arg_check.is_float(scale, 'scale')
+        arg_check.is_str(angle_units, 'angle units')
+        arg_check.is_int(param_types, 'parameter types')
+        arg_check.is_str(align_id, 'errors flag', can_be_none=True)
+        arg_check.is_str(domain, 'domain', can_be_none=True)
+        arg_check.is_bool(errors, 'errors flag')
+
+        # Execute the functional code.
+        align_tensor.init(tensor=tensor, params=params, scale=scale, 
angle_units=angle_units, param_types=param_types, align_id=align_id, 
domain=domain, errors=errors)
+
+    # The function doc info.
+    init._doc_title = "Initialise the alignment tensor."
+    init._doc_title_short = "Alignment tensor initialisation."
+    init._doc_args = [
+        ["tensor", "The alignment tensor identification string."],
+        ["params", "The alignment tensor data."],
+        ["scale", "The alignment tensor eigenvalue scaling value."],
+        ["angle_units", "The units for the angle parameters."],
+        ["param_types", "A flag to select different parameter 
combinations."],
+        ["align_id", "The alignment ID string."],
+        ["domain", "The domain ID string."],
+        ["errors", "A flag which determines if the alignment tensor data or 
its errors are being input."]
+    ]
+    init._doc_desc = """
+        This allows an alignment tensor data to be set up.  The params 
argument should be a tuple of floating point numbers (a list surrounded by 
round brakets).  These correspond to the parameters of the tensor, which can 
be specified by the param_types argument, where the values correspond to
 
             0:  {Sxx, Syy, Sxy, Sxz, Syz}  (unitless),
             1:  {Szz, Sxx-yy, Sxy, Sxz, Syz}  (Pales default format),
@@ -221,8 +237,7 @@
             6:  {Pxx, Pyy, Pxy, Pxz, Pyz}  (unitless),
             7:  {Pzz, Pxx-yy, Pxy, Pxz, Pyz}  (unitless),
 
-        Other formats may be added later.  The relationship between the 
Saupe order matrix S and the
-        alignment tensor A is
+        Other formats may be added later.  The relationship between the 
Saupe order matrix S and the alignment tensor A is
 
             S = 3/2 A.
 
@@ -230,13 +245,9 @@
 
             A = P - 1/3 I,
 
-        where I is the identity matrix.  For the alignment tensor to be 
supplied in Hertz, the bond
-        vectors must all be of equal length.
-
-
-        Examples
-        ~~~~~~~~
-
+        where I is the identity matrix.  For the alignment tensor to be 
supplied in Hertz, the bond vectors must all be of equal length.
+        """
+    init._doc_examples = """
         To set a rhombic tensor to the run 'CaM', type one of:
 
         relax> align_tensor.init('super media', (-8.6322e-05, -5.5786e-04, 
-3.1732e-05, 2.2927e-05,
@@ -244,28 +255,7 @@
         relax> align_tensor.init(tensor='super media', params=(-8.6322e-05, 
-5.5786e-04,
                                  -3.1732e-05, 2.2927e-05, 2.8599e-04), 
param_types=1)
         """
-
-        # Function intro text.
-        if self._exec_info.intro:
-            text = self._exec_info.ps3 + "align_tensor.init("
-            text = text + "tensor=" + repr(tensor)
-            text = text + ", params=" + repr(params)
-            text = text + ", scale=" + repr(scale)
-            text = text + ", angle_units=" + repr(angle_units)
-            text = text + ", param_types=" + repr(param_types)
-            text = text + ", errors=" + repr(errors) + ")"
-            print(text)
-
-        # The argument checks.
-        arg_check.is_str(tensor, 'tensor')
-        arg_check.is_num_tuple(params, 'alignment tensor parameters', size=5)
-        arg_check.is_float(scale, 'scale')
-        arg_check.is_str(angle_units, 'angle units')
-        arg_check.is_int(param_types, 'parameter types')
-        arg_check.is_bool(errors, 'errors flag')
-
-        # Execute the functional code.
-        align_tensor.init(tensor=tensor, params=params, scale=scale, 
angle_units=angle_units, param_types=param_types, errors=errors)
+    _build_doc(init)
 
 
     def matrix_angles(self, basis_set=0, tensors=None):




Related Messages


Powered by MHonArc, Updated Wed Dec 07 16:40:02 2011