7.6. Module pyDataReporting¶
7.6.1. Overview¶
7.6.2. DataReporter classes¶
- 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 daeNoOpDataReporter¶
7.6.2.2. Third-party local data reporters¶
Plots the specified variables using the Matplotlib library (by Caleb Hattingh). |
|
Saves data in Matlab MAT format format (.mat) using scipy.io.savemat function. |
|
Saves data into the Microsoft Excel format (.xlsx) using the openpyxl library (https://openpyxl.readthedocs.io). |
|
Saves data in JSON text format using the Python json library. |
|
Saves data in XML format (.xml) using the Python xml library. |
|
Saves data in HDF5 format using the Python h5py library. |
|
Creates a dataset using the Pandas library (available as data_frame property - the Pandas DataFrame object). |
|
Saves data in the binary VTK format (.vtr) using the pyEVTK module. |
|
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:Instances of daeVariable, or
Lists of daeVariable instances, or
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 supplyingfigRows
andfigCols
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.
- 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.
- class daeJSONFileDataReporter[source]¶
Saves data in JSON text format using the Python json library.
- 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).
- 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
- 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:
The original is available at https://pypi.python.org/pypi/PyEVTK. Install using: “pip install pyevtk”.
It is not an original module available at https://bitbucket.org/pauloh/pyevtk.
Does not require VTK installed.
- 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.
7.6.2.3. Data reporters that do send data to a data receiver (remote data reporters)¶
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 theAddDataReporter()
. The list of containing data reporters is in theDataReporters
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¶
- class daeDataReporterDomain¶
- property Name¶
- property NumberOfPoints¶
- property Points¶
- property Type¶
- property Units¶
7.6.3. DataReceiver classes¶
- 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¶
- 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¶