Python Reports

Graphic Report

This script is an example of the mic module producing a graph with two curves:

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( 'x^2', 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:

import mic
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. NOTE: This script uses the Python package "numpy" and c-style formatting of the numerical values.

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" % x1,
                           "%8.3f" % x2,
                           "%8.3f" % x3 ] )

mic.table.addcolumn( "sin(x)", ["%8.3f" % np.sin(x1),
                                "%8.3f" % np.sin(x2),
                                "%8.3f" % np.sin(x3)] )


mic.table.addcolumn( "cos(x)", ["%8.3f" % np.cos(x1),
                                "%8.3f" % np.cos(x2),
                                "%8.3f" % np.cos(x3)] )

The result is: