mailr9073 - /branches/frame_order/maths_fns/frame_order.py


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

Header


Content

Posted by edward on June 17, 2009 - 20:03:
Author: bugman
Date: Wed Jun 17 20:03:58 2009
New Revision: 9073

URL: http://svn.gna.org/viewcvs/relax?rev=9073&view=rev
Log:
Added a function for printing out the 2nd degree Frame Order matrix.


Modified:
    branches/frame_order/maths_fns/frame_order.py

Modified: branches/frame_order/maths_fns/frame_order.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order/maths_fns/frame_order.py?rev=9073&r1=9072&r2=9073&view=diff
==============================================================================
--- branches/frame_order/maths_fns/frame_order.py (original)
+++ branches/frame_order/maths_fns/frame_order.py Wed Jun 17 20:03:58 2009
@@ -24,3 +24,43 @@
 """Module for the handling of Frame Order."""
 
 
+def print_frame_order_2nd_degree(matrix, name=None):
+    """Nicely print out the Frame Order matrix of the 2nd degree.
+
+    @param matrix:  The 3D, rank-4 Frame Order matrix.
+    @type name:     numpy 3D, rank-4 array
+    @keyword name:  The name of the matrix.
+    @type name:     None or str
+    """
+
+    # Default name.
+    if not name:
+        name = 'Frame Order matrix, 2nd degree'
+
+    # Header and first row start.
+    stdout.write("\n%s:\n" % name)
+    stdout.write('[[')
+
+    # Loop over the rows.
+    for i in range(len(matrix)):
+        # 2nd to last row start.
+        if i != 0:
+            stdout.write(' [')
+
+        # Row end character.
+        char2 = ','
+        if i == len(matrix) - 1:
+            char2 = ']'
+
+        # Loop over the columns.
+        for j in range(len(matrix[i])):
+            # Column end character.
+            char1 = ','
+            if j == len(matrix[i]) - 1:
+                char1 = ']%s\n' % char2
+
+            # Write out the elements.
+            if matrix[i, j]:
+                stdout.write("%10.4f%s" % (matrix[i, j], char1))
+            else:
+                stdout.write("%10s%s" % (0, char1))




Related Messages


Powered by MHonArc, Updated Wed Jun 17 20:20:04 2009