mailr22055 - /trunk/lib/frame_order/format.py


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

Header


Content

Posted by edward on January 28, 2014 - 11:20:
Author: bugman
Date: Tue Jan 28 11:20:07 2014
New Revision: 22055

URL: http://svn.gna.org/viewcvs/relax?rev=22055&view=rev
Log:
The frame order matrix printing function can now output the matrix to any 
precision.

The lib.frame_order.format.print_frame_order_2nd_degree() function now 
accepts the 'places' argument
which allows for higher precision printouts.


Modified:
    trunk/lib/frame_order/format.py

Modified: trunk/lib/frame_order/format.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/lib/frame_order/format.py?rev=22055&r1=22054&r2=22055&view=diff
==============================================================================
--- trunk/lib/frame_order/format.py (original)
+++ trunk/lib/frame_order/format.py Tue Jan 28 11:20:07 2014
@@ -30,13 +30,15 @@
 from lib.float import isNaN
 
 
-def print_frame_order_2nd_degree(daeg, name=None, epsilon=1e-15, 
integer=False, dot=False, comma=True, file=None):
+def print_frame_order_2nd_degree(daeg, name=None, places=4, epsilon=1e-15, 
integer=False, dot=False, comma=True, file=None):
     """Nicely print out the Frame Order matrix of the 2nd degree.
 
     @param daeg:        The 3D, rank-4 Frame Order matrix.
     @type daeg:         numpy 3D, rank-4 array
     @keyword name:      The name of the matrix.
     @type name:         None or str
+    @keyword places:    The number of decimal places to print.
+    @type places:       int
     @keyword epsilon:   The minimum value, below which is considered zero.
     @type epsilon:      float
     @keyword integer:   A flag which if true will only print the integer 
part of the number.
@@ -92,30 +94,30 @@
                 # Integer printout.
                 if integer:
                     val = int(daeg[i, j])
-                    format = "%4i%s"
+                    format = "%" + repr(places) + "i%s"
 
                 # Float printout.
                 else:
                     val = daeg[i, j]
-                    format = "%10.4f%s"
+                    format = "%" + repr(places+6) + "." + repr(places) + 
"f%s"
 
             # NaN.
             elif isNaN(daeg[i, j]):
                 val = 'NaN'
                 if integer:
-                    format = "%4i%s"
+                    format = "%" + repr(places) + "i%s"
                 else:
-                    format = "%10s%s"
+                    format = "%" + repr(places+6) + "s%s"
 
             # Write out the zero elements.
             else:
                 # Integer printout.
                 if integer:
-                    format = "%4s%s"
+                    format = "%" + repr(places) + "s%s"
 
                 # Float printout.
                 else:
-                    format = "%10s%s"
+                    format = "%" + repr(places+6) + "s%s"
 
                 # The character.
                 if dot:




Related Messages


Powered by MHonArc, Updated Tue Jan 28 11:40:01 2014