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.
In addition, the module matplotlib needs to be installed through pip3 from the command line:
pip3 install matplotlib
- Returns Plot object.
(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.
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.
# 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("email@example.com", "firstname.lastname@example.org") # Call sendMail when the simulation finishes atexit.register(sendMail)