Plot module

Plot module

The Plot module utilizes the Ascii module (internally) to retrieve ascii data from the .out files. The data will then used to create a plot figure. The ideal usage of this module is together with the Mail module.

This module can be used in combination with *FUNCTION but it's best used post-simulation with atexit.

This module uses the third-party module matplotlib which requires Python 3 to be installed externally.
In addition, the module matplotlib needs to be installed through pip3 from the command line:
pip3 install matplotlib
Module Contents
plot = Plot( )
Returns Plot object.
plot.create_plot( file , entry , dep , dep_value )
This function will create a png plot file and return the path to the file. This works just like ascii.readData() but creates a plot image instead of returning a list of values. The variable file is the .out file and entry is the column (starting from 0) of the desired data to extract. The last two varables are optional and are used to distinguish between different data within the entry. dep is the desired column and dep_value is the targeted value. For example, the part.out might contain more than one part. If no dependency is chosen, the plot functionality will plot all part data as one curve. By adding the dependency, one can aim for specific data from the ascii-file.
Example

The function sendMail() will be executed when the simulation end because of the use of atexit.register(). The example shows how to add energy balance plot image as attachment.

Python script: sendmail.py
# Import atexit module
import atexit
# Import the Mail and Plot modules
from mail import Mail
from plot import Plot

# Function to be executed when the simulation ends
def sendMail():
    mail = Mail("smtp-host-address", 587)
    plot = Plot()
    mail.attach_file(plot.create_plot("energy.out", 25))
    mail.send("recipient@address.com", "sender@address.com")

# Call sendMail when the simulation finishes
atexit.register(sendMail)
# Adding the python file to our input file *SCRIPT_PYTHON
sendmail.py