Python Reports
Graphic Report
This script is an example of the mic module producing a graph with two curves:
Copy
import mic
import numpy as np
mic.graph( 'My Graph', 'X', 'F(X)' )
myx = np.array( [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0 ] )
mic.graph.add( 'X2', myx, myx*myx, marker='o' )
mic.graph.add( 'sin(X)', myx, np.sin(myx), marker='^' )
The results are:
Summary Report
This script produces a summary report with two summaries:
Copy
import mic
import numpy as np
mic.summary( "My Summaries" )
mic.summary.add( "Summary A",
["Label 1:", "Label 2:", "Label 3:"],
["val1", "val2", "val3"] )
mic.summary.add( "Summary B",
["Label 4:", "Label 5:", "Label 6:"],
["val4", "val5", "val6"] )
The result is:
Tabular Report
If more than one column is required, the call mic.table is employed. This script produces a tabular report consisting of two tables.
This script uses the Python package numpy and c-style formatting of the numerical values. |
Copy
import mic
import numpy as np
mic.table( "My Tables" )
mic.table.addtable( "My Set A" )
mic.table.addcolumn( "X", ["1.0", "2.0", "3.0"] )
mic.table.addcolumn( "Y", ["0.5", "1.0", "1.5"] )
x1 = 0.2
x2 = 0.5
x3 = 3.14159/2
mic.table.addtable( "My Set B" )
mic.table.addcolumn( "X", ['{:8.3f}'.format(x1),
'{:8.3f}'.format(x2),
'{:8.3f}'.format(x3)] )
mic.table.addcolumn( "sin(X)", ['{:8.3f}'.format(np.sin(x1)),
'{:8.3f}'.format(np.sin(x2)),
'{:8.3f}'.format(np.sin(x3))] )
mic.table.addcolumn( "cos(X)", ['{:8.3f}'.format(np.cos(x1)),
'{:8.3f}'.format(np.cos(x2)),
'{:8.3f}'.format(np.cos(x3))] )
The result is: