Skip to content

Latest commit

 

History

History
99 lines (60 loc) · 3.82 KB

README.md

File metadata and controls

99 lines (60 loc) · 3.82 KB

ModiaResult

Stable The MIT License

ModiaResult is part of ModiaSim. See also the ModiaResult documentation.

ModiaResult defines an abstract interface for simulation results and provides overloaded methods for:

  • Dictionaries,

  • DataFrame tables,

  • Tables (for example CSV), and

  • ModiaResult.ResultDict (special dictionary with all features of the interface).

Additionally, operations on simulation results are provided, especially to produce line plots in a convenient way based on

  • GLMakie (interactive plots in an OpenGL window),
  • WGLMakie (interactive plots in a browser window),
  • CairoMakie (static plots on file with publication quality),
  • PyPlot (plots with Matplotlib from Python) and
  • NoPlot (= all plot calls are ignored; NoPlot is a module in ModiaResult), or
  • SilentNoPlot (= NoPlot without messages; SilentNoPlot is a module in ModiaResult).

More details:

Installation

All packages are registered and are installed with:

julia> ]add ModiaResult
        add ModiaPlot_GLMakie       # if plotting with GLMakie desired
        add ModiaPlot_WGLMakie      # if plotting with WGLMakie desired
        add ModiaPlot_CairoMakie    # if plotting with CairoMakie desired
        add ModiaPlot_PyPlot        # if plotting with PyPlot desired

If you have trouble installing ModiaPlot_PyPlot, see Installation of PyPlot.jl

Example

Assume that the result data structure is available, then the following commands

import ModiaResult

# Define plotting software globally
ModiaResult.activate("PyPlot") # or ENV["MODIA_PLOT"] = "PyPlot"

# Execute "using ModiaPlot_<globally defined plot package>"
ModiaResult.@usingModiaPlot   # = "using ModiaPlot_PyPlot"

# Generate line plots                     
plot(result, [("sigA", "sigB", "sigC"), "r[2:3]"])

generate the following plot:

SegmentedSignalsPlot

Abstract Result Interface

For every result data structure a few access functions have to be defined (for details see Abstract Interface). Most importantly:

(timeSignal, signal, signalType) = ModiaResult.rawSignal(result, name)

Given the result data structure result and a variable name::AbstractString, return the result values of the independent variable (= timeSignal), the corresponding result values of the variable (= signal) and the type of the signal. The following figure sketches the returned timeSignal and signal data structures:

SignalDefinition

Other signal types might be mapped to this basic signal type by introducing views.

Main developer

Martin Otter, DLR - Institute of System Dynamics and Control