7.6. Module pyDataReporting

7.6.1. Overview

7.6.2. DataReporter classes

daeDataReporter_t
daeDataReporterLocal
daeNoOpDataReporter
daeDataReporterFile
daeTEXTFileDataReporter
daeBlackHoleDataReporter
daeDelegateDataReporter
class daeDataReporter_t

Bases: Boost.Python.instance

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
ConnectString
Name
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

Bases: pyDataReporting.daeDataReporter_t

Process
dictDomains
dictVariables
class daeNoOpDataReporter

Bases: pyDataReporting.daeDataReporterLocal

class daeDataReporterFile

Bases: pyDataReporting.daeDataReporterLocal

WriteDataToFile((daeDataReporterFile)self) → None
class daeTEXTFileDataReporter

Bases: pyDataReporting.daeDataReporterFile

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
class daePlotDataReporter[source]

Bases: pyDataReporting.daeDataReporterLocal

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]

Bases: pyDataReporting.daeDataReporterFile

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()[source]
class daeExcelFileDataReporter[source]

Bases: pyDataReporting.daeDataReporterFile

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()[source]
class daeJSONFileDataReporter[source]

Bases: pyDataReporting.daeDataReporterFile

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

WriteDataToFile()[source]
class daeXMLFileDataReporter[source]

Bases: pyDataReporting.daeDataReporterFile

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

WriteDataToFile()[source]
class daeHDF5FileDataReporter[source]

Bases: pyDataReporting.daeDataReporterFile

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()[source]
class daePandasDataReporter[source]

Bases: pyDataReporting.daeDataReporterLocal

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

data_frame
class daeVTKDataReporter[source]

Bases: pyDataReporting.daeDataReporterLocal

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]

Bases: pyDataReporting.daeDataReporterFile

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()[source]

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

class daeDataReporterRemote

Bases: pyDataReporting.daeDataReporter_t

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

Bases: pyDataReporting.daeDataReporterRemote

SendMessage((daeTCPIPDataReporter)self, (str)message) → bool

7.6.2.4. Special-purpose data reporters

class daeBlackHoleDataReporter

Bases: pyDataReporting.daeDataReporter_t

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

Bases: pyDataReporting.daeDataReporter_t

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
DataReporters

7.6.2.5. DataReporter data-containers

daeDataReporterDomain
daeDataReporterVariable
daeDataReporterVariableValue
class daeDataReporterDomain

Bases: Boost.Python.instance

Name
NumberOfPoints
Points
Type
Units
class daeDataReporterVariable

Bases: Boost.Python.instance

AddDomain((daeDataReporterVariable)self, (str)domainName) → None
Domains
Name
NumberOfDomains
NumberOfPoints
Units
class daeDataReporterVariableValue

Bases: Boost.Python.instance

__getitem__((daeDataReporterVariableValue)self, (int)index) → float
__setitem__((daeDataReporterVariableValue)self, (int)index, (float)value) → None
Name
NumberOfPoints
Values

7.6.3. DataReceiver classes

daeDataReceiver_t
daeTCPIPDataReceiver
daeTCPIPDataReceiverServer
class daeDataReceiver_t

Bases: Boost.Python.instance

Start((daeDataReceiver_t)self) → bool
Stop((daeDataReceiver_t)self) → bool
Process
class daeTCPIPDataReceiver

Bases: pyDataReporting.daeDataReceiver_t

Start((daeTCPIPDataReceiver)self) → bool
Stop((daeTCPIPDataReceiver)self) → bool
Process
class daeTCPIPDataReceiverServer

Bases: Boost.Python.instance

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

Bases: Boost.Python.instance

Coordinates
Name
NumberOfPoints
Points
Type
Units
class daeDataReceiverVariable

Bases: Boost.Python.instance

AddDomain((daeDataReceiverVariable)self, (daeDataReceiverDomain)domain) → None
AddVariableValue((daeDataReceiverVariable)self, (daeDataReceiverVariableValue)variableValue) → None
Domains
Name
NumberOfPoints
TimeValues
Units
Values
class daeDataReceiverVariableValue

Bases: Boost.Python.instance

__getitem__((daeDataReceiverVariableValue)self, (int)index) → float
__setitem__((daeDataReceiverVariableValue)self, (int)index, (float)value) → None
Time
class daeDataReceiverProcess

Bases: Boost.Python.instance

Domains
FindVariable((daeDataReceiverProcess)self, (str)variableName) → daeDataReceiverVariable
Name
RegisterDomain((daeDataReceiverProcess)self, (daeDataReceiverDomain)domain) → None
RegisterVariable((daeDataReceiverProcess)self, (daeDataReceiverVariable)variable) → None
Variables
dictDomains
dictVariableValues
dictVariables