7.5. Module pyDataReporting

7.5.1. Overview

7.5.2. DataReporter classes

daeDataReporter_t
daeDataReporterLocal
daeNoOpDataReporter
daeDataReporterFile
daeTEXTFileDataReporter
daeBlackHoleDataReporter
daeDelegateDataReporter
class pyDataReporting.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.5.2.1. Data reporters that do not send data to a data receiver and keep data locally (local data reporters)

class pyDataReporting.daeDataReporterLocal

Bases: pyDataReporting.daeDataReporter_t

Process
dictDomains
dictVariables
class pyDataReporting.daeNoOpDataReporter

Bases: pyDataReporting.daeDataReporterLocal

class pyDataReporting.daeDataReporterFile

Bases: pyDataReporting.daeDataReporterLocal

WriteDataToFile((daeDataReporterFile)self) → None
class pyDataReporting.daeTEXTFileDataReporter

Bases: pyDataReporting.daeDataReporterFile

WriteDataToFile((daeTEXTFileDataReporter)self) → None

7.5.2.2. Third-party local data reporters

daePlotDataReporter() Plots the specified variables using Matplotlib (by Caleb Hattingh).
daeMatlabMATFileDataReporter() Saves data in Matlab MAT format format (.mat) using scipy.io.savemat function.
daeExcelFileDataReporter() Saves data in MS Excel format (.xls) using python xlwt library.
daeJSONFileDataReporter() Saves data in JSON text format using python json library.
daeXMLFileDataReporter() Saves data in XML format (.xml) using python xml library.
daeHDF5FileDataReporter() Saves data in HDF5 format using python h5py library.
daePandasDataReporter() Creates pandas DataSet using pandas library.
daeVTKDataReporter() Saves data in the VTK format (.vtk) using pyEVTK module avaialable at https://bitbucket.org/somada141/pyevtk.
class daetools.pyDAE.data_reporters.daePlotDataReporter[source]

Bases: pyDataReporting.daeDataReporterLocal

Plots the specified variables using Matplotlib (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 daetools.pyDAE.data_reporters.daeMatlabMATFileDataReporter[source]

Bases: pyDataReporting.daeDataReporterFile

Saves data in Matlab MAT format format (.mat) using scipy.io.savemat function. Does not need Matlab installed.

WriteDataToFile()[source]
class daetools.pyDAE.data_reporters.daeExcelFileDataReporter[source]

Bases: pyDataReporting.daeDataReporterFile

Saves data in MS Excel format (.xls) using python xlwt library. Does not need Excel installed (works under GNU/Linux too).

WriteDataToFile()[source]
class daetools.pyDAE.data_reporters.daeJSONFileDataReporter[source]

Bases: pyDataReporting.daeDataReporterFile

Saves data in JSON text format using python json library.

WriteDataToFile()[source]
class daetools.pyDAE.data_reporters.daeXMLFileDataReporter[source]

Bases: pyDataReporting.daeDataReporterFile

Saves data in XML format (.xml) using python xml library.

WriteDataToFile()[source]
class daetools.pyDAE.data_reporters.daeHDF5FileDataReporter[source]

Bases: pyDataReporting.daeDataReporterFile

Saves data in HDF5 format using python h5py library.

WriteDataToFile()[source]
class daetools.pyDAE.data_reporters.daePandasDataReporter[source]

Bases: pyDataReporting.daeDataReporterLocal

Creates pandas DataSet using pandas library.

GenerateDataSet()[source]
class daetools.pyDAE.data_reporters.daeVTKDataReporter[source]

Bases: pyDataReporting.daeDataReporterFile

Saves data in the VTK format (.vtk) using pyEVTK module avaialable at https://bitbucket.org/somada141/pyevtk. Install using: “pip install pyevtk”. Nota bene:

It is not an original module available at https://bitbucket.org/pauloh/pyevtk.

Does not require VTK installed.

WriteDataToFile()[source]

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

class pyDataReporting.daeDataReporterRemote

Bases: pyDataReporting.daeDataReporter_t

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

Bases: pyDataReporting.daeDataReporterRemote

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

7.5.2.4. Special-purpose data reporters

class pyDataReporting.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 pyDataReporting.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, (daeDataReporter_t)dataReporter) → None
DataReporters

7.5.2.5. DataReporter data-containers

daeDataReporterDomain
daeDataReporterVariable
daeDataReporterVariableValue
class pyDataReporting.daeDataReporterDomain

Bases: Boost.Python.instance

Name
NumberOfPoints
Points
Type
Units
class pyDataReporting.daeDataReporterVariable

Bases: Boost.Python.instance

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

Bases: Boost.Python.instance

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

7.5.3. DataReceiver classes

daeDataReceiver_t
daeTCPIPDataReceiver
daeTCPIPDataReceiverServer
class pyDataReporting.daeDataReceiver_t

Bases: Boost.Python.instance

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

Bases: pyDataReporting.daeDataReceiver_t

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

Bases: Boost.Python.instance

DataReceivers
IsConnected((daeTCPIPDataReceiverServer)self) → bool
Start((daeTCPIPDataReceiverServer)self) → None
Stop((daeTCPIPDataReceiverServer)self) → None

7.5.3.1. DataReceiver data-containers

daeDataReceiverDomain
daeDataReceiverVariable
daeDataReceiverVariableValue
daeDataReceiverProcess
class pyDataReporting.daeDataReceiverDomain

Bases: Boost.Python.instance

Coordinates
Name
NumberOfPoints
Points
Type
Units
class pyDataReporting.daeDataReceiverVariable

Bases: Boost.Python.instance

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

Bases: Boost.Python.instance

__getitem__((daeDataReceiverVariableValue)self, (int)index) → float
__setitem__((daeDataReceiverVariableValue)self, (int)index, (float)value) → None
Time
class pyDataReporting.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