7.6. Module pyDataReporting

7.6.1. Overview

7.6.2. DataReporter classes

daeDataReporter_t

daeDataReporterLocal

daeNoOpDataReporter

daeDataReporterFile

daeTEXTFileDataReporter

daeBlackHoleDataReporter

daeDelegateDataReporter

class daeDataReporter_t
Connect((daeDataReporter_t)self, (str)connectionString, (str)processName) bool
Disconnect((daeDataReporter_t)self) bool
IsConnected((daeDataReporter_t)self) bool
StartRegistration((daeDataReporter_t)self) bool
RegisterDomain((daeDataReporter_t)self, (daeDataReporterDomain)domain) bool
RegisterVariable((daeDataReporter_t)self, (daeDataReporterVariable)variable) bool
EndRegistration((daeDataReporter_t)self) bool
StartNewResultSet((daeDataReporter_t)self, (Float)time) bool
SendVariable((daeDataReporter_t)self, (daeDataReporterVariableValue)variableValue) bool
EndOfData((daeDataReporter_t)self) bool
property ConnectString
property Name
property ProcessName

7.6.2.1. Data reporters that do not send data to a data receiver and keep data locally (local data reporters)

class daeDataReporterLocal
property Process
property dictDomains
property dictVariables
class daeNoOpDataReporter
class daeDataReporterFile
WriteDataToFile((daeDataReporterFile)self) None
class daeTEXTFileDataReporter
WriteDataToFile((daeTEXTFileDataReporter)self) None

7.6.2.2. Third-party local data reporters

daePlotDataReporter()

Plots the specified variables using the Matplotlib library (by Caleb Hattingh).

daeMatlabMATFileDataReporter()

Saves data in Matlab MAT format format (.mat) using scipy.io.savemat function.

daeExcelFileDataReporter()

Saves data into the Microsoft Excel format (.xlsx) using the openpyxl library (https://openpyxl.readthedocs.io).

daeJSONFileDataReporter()

Saves data in JSON text format using the Python json library.

daeXMLFileDataReporter()

Saves data in XML format (.xml) using the Python xml library.

daeHDF5FileDataReporter()

Saves data in HDF5 format using the Python h5py library.

daePandasDataReporter()

Creates a dataset using the Pandas library (available as data_frame property - the Pandas DataFrame object).

daeVTKDataReporter()

Saves data in the binary VTK format (.vtr) using the pyEVTK module.

daePickleDataReporter()

Saves data as the Python pickle which can be opened in DAE Plotter or unpickled directly:

class daePlotDataReporter[source]

Plots the specified variables using the Matplotlib library (by Caleb Hattingh).

Plot(*args, **kwargs)[source]

args can be either:

  1. Instances of daeVariable, or

  2. Lists of daeVariable instances, or

  3. A mixture of both.

Each arg will get its own subplot. The subplots are all automatically arranged such that the resulting figure is as square-like as possible. You can however override the shape by supplying figRows and figCols as keyword args.

Basic Example:

# Create Log, Solver, DataReporter and Simulation object
log = daePythonStdOutLog()
daesolve = daeIDAS()
from daetools.pyDAE.data_reporters import daePlotDataReporter
datareporter = daePlotDataReporter()
simulation = simTutorial()

simulation.m.SetReportingOn(True)
simulation.ReportingInterval = 20
simulation.TimeHorizon = 500

simName = simulation.m.Name + strftime(" [%d.%m.%Y %H:%M:%S]", localtime())
if(datareporter.Connect("", simName) == False):
    sys.exit()

simulation.Initialize(daesolver, datareporter, log)

simulation.m.SaveModelReport(simulation.m.Name + ".xml")
simulation.m.SaveRuntimeModelReport(simulation.m.Name + "-rt.xml")

simulation.SolveInitial()
simulation.Run()

simulation.Finalize()
datareporter.Plot(
    simulation.m.Ci,                       # Subplot 1
    [simulation.m.L, simulation.m.event],  # Subplot 2 (2 sets)
    simulation.m.Vp,                       # Subplot 3
    [simulation.m.L, simulation.m.Vp]      # Subplot 4 (2 sets)
    )
class daeMatlabMATFileDataReporter[source]

Saves data in Matlab MAT format format (.mat) using scipy.io.savemat function. Every variable is saved as numpy array (variable names are stripped from illegal characters). In addition, time and domain points for every variable are saved as ‘varName.Times’ and ‘varName.Domains’. Does not require Matlab installed.

WriteDataToFile((daeDataReporterFile)self) None[source]

WriteDataToFile( (daeDataReporterFile)self) -> None

class daeExcelFileDataReporter[source]

Saves data into the Microsoft Excel format (.xlsx) using the openpyxl library (https://openpyxl.readthedocs.io). Does not require Excel installed and works on all operating systems.

WriteDataToFile((daeDataReporterFile)self) None[source]

WriteDataToFile( (daeDataReporterFile)self) -> None

class daeJSONFileDataReporter[source]

Saves data in JSON text format using the Python json library.

WriteDataToFile((daeDataReporterFile)self) None[source]

WriteDataToFile( (daeDataReporterFile)self) -> None

class daeXMLFileDataReporter[source]

Saves data in XML format (.xml) using the Python xml library. The numerical data are saved as json strings (for easier parsing).

WriteDataToFile((daeDataReporterFile)self) None[source]

WriteDataToFile( (daeDataReporterFile)self) -> None

class daeHDF5FileDataReporter[source]

Saves data in HDF5 format using the Python h5py library. A separate group is created for every variable and contain the following data sets: - Values: multidimensional array with the variable values - Times: 1d array with the time points - DomainNames: names of the domains that the variable is distributed on - Domains: multidimensional array with the domain points - Units: variable units as a string

WriteDataToFile((daeDataReporterFile)self) None[source]

WriteDataToFile( (daeDataReporterFile)self) -> None

class daePandasDataReporter[source]

Creates a dataset using the Pandas library (available as data_frame property - the Pandas DataFrame object).

property data_frame
class daeVTKDataReporter[source]

Saves data in the binary VTK format (.vtr) using the pyEVTK module. pyEVTK is included in the daetools installation (daetools.ext_libs.pyevtk). A separate file is written into the specified directory for every time point. In addition, the ‘variableName.visit’ files are written for use with the VisIt software. Notate bene:

Does not require VTK installed.

WriteFiles()[source]
class daePickleDataReporter[source]

Saves data as the Python pickle which can be opened in DAE Plotter or unpickled directly:

f = open(filename, 'rb')
process = pickle.load(f)
f.close()

where process is the dataReceiverProcess instance identical to the daeDataReceiverProcess objects used in the other data reporters below.

WriteDataToFile((daeDataReporterFile)self) None[source]

WriteDataToFile( (daeDataReporterFile)self) -> None

7.6.2.3. Data reporters that do send data to a data receiver (remote data reporters)

class daeDataReporterRemote
SendMessage((daeDataReporterRemote)self, (str)message) bool
class daeTCPIPDataReporter
SendMessage((daeTCPIPDataReporter)self, (str)message) bool

7.6.2.4. Special-purpose data reporters

class daeBlackHoleDataReporter

Data reporter that does not process any data and all function calls simply return True. Could be used when no results from the simulation are needed.

class daeDelegateDataReporter

A container-like data reporter, which does not process any data but forwards (delegates) all function calls (Disconnect(), IsConnected(), StartRegistration(), RegisterDomain(), RegisterVariable(), EndRegistration(), StartNewResultSet(), SendVariable(), EndOfData()) to data reporters in the containing list of data reporters. Data reporters can be added by using the AddDataReporter(). The list of containing data reporters is in the DataReporters attribute.

Connect((daeDataReporter_t)self, (str)connectionString, (str)processName) Boolean

Does nothing. Always returns True.

AddDataReporter((daeDelegateDataReporter)self, (object)dataReporter) None
property DataReporters

7.6.2.5. DataReporter data-containers

daeDataReporterDomain

daeDataReporterVariable

daeDataReporterVariableValue

class daeDataReporterDomain
property Name
property NumberOfPoints
property Points
property Type
property Units
class daeDataReporterVariable
AddDomain((daeDataReporterVariable)self, (str)domainName) None
property Domains
property Name
property NumberOfDomains
property NumberOfPoints
property Units
class daeDataReporterVariableValue
__getitem__((daeDataReporterVariableValue)self, (int)index) float
__setitem__((daeDataReporterVariableValue)self, (int)index, (float)value) None
property Name
property NumberOfPoints
property Values

7.6.3. DataReceiver classes

daeDataReceiver_t

daeTCPIPDataReceiver

daeTCPIPDataReceiverServer

class daeDataReceiver_t
Start((daeDataReceiver_t)self) bool
Stop((daeDataReceiver_t)self) bool
Process
class daeTCPIPDataReceiver
Start((daeTCPIPDataReceiver)self) bool
Stop((daeTCPIPDataReceiver)self) bool
Process
class daeTCPIPDataReceiverServer
property DataReceivers
IsConnected((daeTCPIPDataReceiverServer)self) bool
Start((daeTCPIPDataReceiverServer)self) None
Stop((daeTCPIPDataReceiverServer)self) None

7.6.3.1. DataReceiver data-containers

daeDataReceiverDomain

daeDataReceiverVariable

daeDataReceiverVariableValue

daeDataReceiverProcess

class daeDataReceiverDomain
property Coordinates
property Name
property NumberOfPoints
property Points
property Type
property Units
class daeDataReceiverVariable
AddDomain((daeDataReceiverVariable)self, (daeDataReceiverDomain)domain) None
AddVariableValue((daeDataReceiverVariable)self, (daeDataReceiverVariableValue)variableValue) None
property Domains
property Name
property NumberOfPoints
property TimeValues
property Units
property Values
class daeDataReceiverVariableValue
__getitem__((daeDataReceiverVariableValue)self, (int)index) float
__setitem__((daeDataReceiverVariableValue)self, (int)index, (float)value) None
property Time
class daeDataReceiverProcess
property Domains
FindVariable((daeDataReceiverProcess)self, (str)variableName) daeDataReceiverVariable
property Name
RegisterDomain((daeDataReceiverProcess)self, (daeDataReceiverDomain)domain) None
RegisterVariable((daeDataReceiverProcess)self, (daeDataReceiverVariable)variable) None
property Variables
property dictDomains
property dictVariableValues
property dictVariables