Skip to content

Commit

Permalink
SignalTables 0.1.0-dev: Initial version based on ModiaResult.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinOtter committed Jun 18, 2022
0 parents commit 1502e2f
Show file tree
Hide file tree
Showing 16 changed files with 1,291 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CompatHelper
on:
schedule:
- cron: 0 0 * * *
workflow_dispatch:
jobs:
CompatHelper:
runs-on: ubuntu-latest
steps:
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
- name: CompatHelper.main()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
run: julia -e 'using CompatHelper; CompatHelper.main()'
15 changes: 15 additions & 0 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: TagBot
on:
issue_comment:
types:
- created
workflow_dispatch:
jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
ssh: ${{ secrets.DOCUMENTER_KEY }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/Manifest.toml
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021-2022 DLR Institute of System Dynamics and Control

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
22 changes: 22 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name = "SignalTables"
uuid = "3201582d-3078-4276-ba5d-0a1254d79d7c"
authors = ["[email protected] <[email protected]>"]
version = "0.1.0-dev"

[deps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Measurements = "eff96d63-e80a-5855-80a2-b1b0885c5ab7"
MonteCarloMeasurements = "0987c9cc-fe09-11e8-30f0-b96dd679fdca"
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[compat]
julia = "1.7"
DataFrames = "1, 0.22, 0.21, 0.20, 0.19"
Measurements = "2"
MonteCarloMeasurements = "1, 0.10"
OrderedCollections = "1"
Pkg = "1"
Unitful = "1"
97 changes: 97 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# SignalTables

Package [SignalTables](https://github.com/ModiaSim/SignalTables.jl) defines
an [Abstract Signal Table Interface](@ref) and an [Abstract Line Plot Interface](@ref)
together with concrete implementations of these interfaces.
Furthermore, useful functionality is provided on top of these interfaces (see [Functions](@ref)).

A *signal table* is a (dictionary-like) type that supports the [Abstract Signal Table Interface](@ref)
for example [`SignalTable`](@ref). It defines a set of *signals* in tabular format. A *signal* is identified by its *name::String*
and is a representation of the values of a variable ``v`` as a (partial) function ``v(t)``
of the values of independent variable ``t = v_{independent}``.
The values of ``v`` are represented by an array where
`v.values[i,j,k,...]` is element `v[j,k,...]` of variable ``v`` at ``t_i``, i.e. at `t.values[i]`.
If an element is *not defined* at ``t_ì``, it has a value of *missing*.

Example (*Par(..)* are parameters, *motor.w_ref* is a continuous variable,
*motor.w_m* is a clocked variable, *load.r* is a continuous vector variable):

```julia
using SignalTables
using Unitful

t = 0.0:0.1:0.5
sigTable = SignalTable(
"time" => Var(values= t, unit="s", independent=true),
"load.r" => Var(values= [sin.(t) cos.(t) sin.(t)]),
"motor.angle" => Var(values= sin.(t), unit="rad"),
"motor.w_ref" => Var(values= cos.(t), unit="rad/s", info="Reference"),
"motor.w_m" => Var(values= Clocked(0.9*cos.(t),factor=2), unit="rad/s", info="Measured"),
"motor.inertia"=> Par(value = 0.02, unit="kg*m/s^2"),
"attributes" => Par(info = "This is a test signal table")
)

# Abstract Signal Tables Interface
w_m_sig = getSignal( sigTable, "motor.w_ref") # = Var(values=..., unit=..., info=...)
w_ref = getValuesWithUnit(sigTable, "motor.w_ref") # = [0.0, 0.0998, 0.1986, ...]u"rad/s"
w_m = getValues( sigTable, "motor.w_m" ) # = [0.9, missing, missing, 0.859, ...]
inertia = getValueWithUnit( sigTable, "motor.inertia") # = 0.02u"kg*m/s^2"

showInfo(sigTable)
```

results in the following output:

```julia
name unit size eltype kind attributes
───────────────────────────────────────────────────────────────────
time s (6,) Float64 Var independent=true
load.r (6,3) Float64 Var
motor.angle rad (6,) Float64 Var
motor.w_ref rad*s^-1 (6,) Float64 Var info="Reference"
motor.w_m rad*s^-1 (6,) Float64 Var info="Measured"
motor.inertia kg*m/s^2 () Float64 Par
attributes Par info="This is a.."
```

The commands

```julia
# Define Plot Package in startup.jl, e.g. `ENV["SignalTablesPlotPackage"] = "PyPlot"`
# Or in Julia session, e.g. `usePlotPackage("PyPlot")`

@usingModiaPlot # activate plot package
plot(sigTable, [("sigA", "sigB", "sigC"), "r[2:3]"]) # generate line plots
```

generate the following line plot:

![Line plots of SigTable](../resources/images/sigTable-line-plots.png)


*Concrete implementations* of the [Abstract Signal Table Interface](@ref) are provided for:

- [`SignalTable`](@ref) (included in SignalTables.jl).
- [Modia.jl](https://github.com/ModiaSim/Modia.jl) (a modeling and simulation environment)
- [DataFrames.jl](https://github.com/JuliaData/DataFrames.jl)
(tabular data; first column is independent variable; *only scalar variables*))
- [Tables.jl](https://github.com/JuliaData/Tables.jl)
(abstract tables, e.g. [CSV](https://github.com/JuliaData/CSV.jl) tables;
first column is independent variable; *only scalar variables*).

*Concrete implementations* of the [Abstract Line Plot Interface](@ref) are provided for:

- [PyPlot](https://github.com/JuliaPy/PyPlot.jl) (plots with [Matplotlib](https://matplotlib.org/stable/) from Python),
- [GLMakie](https://github.com/JuliaPlots/GLMakie.jl) (interactive plots in an OpenGL window),
- [WGLMakie](https://github.com/JuliaPlots/WGLMakie.jl) (interactive plots in a browser window),
- [CairoMakie](https://github.com/JuliaPlots/CairoMakie.jl) (static plots on file with publication quality).

Furthermore, there is a dummy implementation included in SignalTables that is useful when performing tests with runtests.jl,
in order that no plot package needs to be loaded during the tests:

- SilentNoPlot (= all plot calls are silently ignored).


## Installation

Package is not yet registered
17 changes: 17 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Documenter, SignalTables #, ModiaPlot_PyPlot

makedocs(
sitename = "SignalTables",
authors = "Martin Otter (DLR-SR)",
format = Documenter.HTML(prettyurls = false),
pages = [
"Home" => "index.md",
#"Getting Started" => "GettingStarted.md",
#"Functions" => "Functions.md",
#"Internal" => [
# "internal/AbstractResultInterface.md",
# "internal/AbstractLinePlotInterface.md",
# "internal/UtilityFunctions.md"
],
)

Loading

0 comments on commit 1502e2f

Please sign in to comment.