Skip to content

Commit 73b3205

Browse files
authored
Merge pull request #5 from ModiaSim/Branch_v0.4.0
Branch v0.4.0
2 parents ebd63e6 + 758bc1f commit 73b3205

File tree

16 files changed

+220
-167
lines changed

16 files changed

+220
-167
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SignalTables"
22
uuid = "3201582d-3078-4276-ba5d-0a1254d79d7c"
33
4-
version = "0.3.5"
4+
version = "0.4.0"
55

66
[deps]
77
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"

README.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44

55
Package [SignalTables](https://github.com/ModiaSim/SignalTables.jl) (see [docu](https://modiasim.github.io/SignalTables.jl/stable/index.html))
66
provides abstract and concrete types and functions for *signal tables*.
7+
A *signal table* is basically a table where the table columns can be multi-dimensional arrays with attributes.
78
Typically, simulation results, reference signals, table-based input signals, measurement data,
89
look-up tables can be represented by a signal table.
910

10-
A *signal table* is an *ordered dictionary* of *signals* with string keys that supports the
11-
[Abstract Signal Table Interface](https://modiasim.github.io/SignalTables.jl/stable/Internal/AbstractSignalTableInterface.html).
12-
A *signal* can be defined in two forms:
11+
A *signal table* is an *ordered dictionary* of *signals* with string keys. A *signal* can be defined in the following forms:
1312

14-
- As [Var](https://modiasim.github.io/SignalTables.jl/stable/Functions/Signals.html#SignalTables.Var) *dictionary* that has a required *values* key representing a *signal array* of any element type as function of the independent signal(s) (or is the k-th independent signal). A *signal array* is a *multi-dimensional array* with indices `[i1,i2,...,j1,j2,...]` to hold variable elements `[j1,j2,...]` at the `[i1,i2,...]` independent signal(s). If an element of a signal array is *not defined*, it has a value of *missing*.
15-
- As [Par](https://modiasim.github.io/SignalTables.jl/stable/Functions/Signals.html#SignalTables.Par) *dictionary* that has an optional *value* key representing a constant of any type.
13+
- As [Var](https://modiasim.github.io/SignalTables.jl/stable/Functions/Signals.html#SignalTables.Var) *dictionary* that has a required *values* key
14+
(or an *alias* key) representing a *signal array* of any element type as function of the independent signal(s) (or is the k-th independent signal). A *signal array* is a *multi-dimensional array* with indices `[i1,i2,...,j1,j2,...]` to hold variable elements `[j1,j2,...]` at the `[i1,i2,...]` independent signal(s). If an element of a signal array is *not defined*, it has a value of *missing*.
15+
- As [Par](https://modiasim.github.io/SignalTables.jl/stable/Functions/Signals.html#SignalTables.Par) *dictionary* that has a required *value* key (or and *alias* key) representing a constant of any type.
16+
- As [Map](https://modiasim.github.io/SignalTables.jl/stable/Functions/Signals.html#SignalTables.Map) *dictionary* that has no required keys and collects attributes/meta-data that are associated with a Var, Par, Map, or signal table dictionary.
1617

17-
In both dictionaries, additional attributes can be stored, for example *unit*, *info*, *variability* (continuous, clocked, ...), *alias*, *interpolation*,
18+
In all these dictionaries, additional attributes can be stored, for example *unit*, *info*, *variability* (continuous, clocked, ...), *interpolation*,
1819
*extrapolation*, and user-defined attributes.
1920

2021
This logical view is directly mapped to Julia data structures, but can be also mapped to data structures in other
@@ -33,19 +34,18 @@ t = 0.0:0.1:0.5
3334
sigTable = SignalTable(
3435
"time" => Var(values= t, unit="s", independent=true),
3536
"load.r" => Var(values= [sin.(t) cos.(t) sin.(t)], unit="m"),
36-
"motor.angle" => Var(values= sin.(t), unit="rad", state=true),
37-
"motor.w" => Var(values= cos.(t), unit="rad/s", integral="motor.angle"),
37+
"motor.angle" => Var(values= sin.(t), unit="rad", state=true, der="motor.w"),
38+
"motor.w" => Var(values= cos.(t), unit="rad/s"),
3839
"motor.w_ref" => Var(values= 0.9*[sin.(t) cos.(t)], unit = ["rad", "1/s"],
3940
info="Reference angle and speed"),
4041
"wm" => Var(alias = "motor.w"),
4142
"ref.clock" => Var(values= [true, missing, missing, true, missing, missing],
4243
variability="clock"),
4344
"motor.w_c" => Var(values= [0.8, missing, missing, 1.5, missing, missing],
4445
variability="clocked", clock="ref.clock"),
45-
4646
"motor.inertia"=> Par(value = 0.02f0, unit="kg*m/s^2"),
4747
"motor.data" => Par(value = "resources/motorMap.json"),
48-
"attributes" => Par(info = "This is a test signal table")
48+
"attributes" => Map(experiment=Map(stoptime=0.5, interval=0.01))
4949
)
5050

5151
phi_m_sig = getSignal( sigTable, "motor.angle") # = Var(values=..., unit=..., ...)
@@ -62,17 +62,17 @@ Command `showInfo` generates the following output:
6262
```julia
6363
name unit size eltypeOrType kind attributes
6464
───────────────────────────────────────────────────────────────────────────────────────────────────────
65-
time "s" (6,) Float64 Var independent=true
66-
load.r "m" (6,3) Float64 Var
67-
motor.angle "rad" (6,) Float64 Var state=true, der="motor.w"
68-
motor.w "rad/s" (6,) Float64 Var
69-
motor.w_ref ["rad", "1/s"] (6,2) Float64 Var info="Reference angle and speed"
70-
wm "rad/s" (6,) Float64 Var alias="motor.w"
71-
ref.clock (6,) Union{Missing,Bool} Var variability="clock"
72-
motor.w_c (6,) Union{Missing,Float64} Var variability="clocked", clock="ref.clock"
73-
motor.inertia "kg*m/s^2" () Float32 Par
74-
motor.data String Par
75-
attributes Par info="This is a test signal table"
65+
time "s" [6] Float64 Var independent=true
66+
load.r "m" [6,3] Float64 Var
67+
motor.angle "rad" [6] Float64 Var state=true, der="motor.w"
68+
motor.w "rad/s" [6] Float64 Var
69+
motor.w_ref ["rad", "1/s"] [6,2] Float64 Var info="Reference angle and speed"
70+
wm "rad/s" [6] Float64 Var alias="motor.w"
71+
ref.clock [6] Union{Missing,Bool} Var variability="clock"
72+
motor.w_c [6] Union{Missing,Float64} Var variability="clocked", clock="ref.clock"
73+
motor.inertia "kg*m/s^2" Float32 Par
74+
motor.data String Par
75+
attributes Map experiment=Map(stoptime=0.5, interval=0.01)
7676
```
7777

7878
The various Julia FileIO functions can be directly used to save a signal table
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"_class":"SignalTable","_classVersion":"0.3.5","time":{"_class":"Var","values":[0.0,0.1,0.2,0.3,0.4,0.5],"unit":"s","independent":true},"load.r":{"_class":"Var","values":{"_class":"Array","eltype":"Float64","size":[6,3],"layout":"column-major","values":[0.0,0.09983341664682815,0.19866933079506122,0.29552020666133955,0.3894183423086505,0.479425538604203,1.0,0.9950041652780258,0.9800665778412416,0.955336489125606,0.9210609940028851,0.8775825618903728,0.0,0.09983341664682815,0.19866933079506122,0.29552020666133955,0.3894183423086505,0.479425538604203]},"unit":"m"},"motor.angle":{"_class":"Var","values":[0.0,0.09983341664682815,0.19866933079506122,0.29552020666133955,0.3894183423086505,0.479425538604203],"unit":"rad","state":true,"der":"motor.w"},"motor.w":{"_class":"Var","values":[1.0,0.9950041652780258,0.9800665778412416,0.955336489125606,0.9210609940028851,0.8775825618903728],"unit":"rad/s","state":true,"start":{"_class":"Number","unit":"rad*s^-1","type":"Float64","value":1.0}},"motor.w_ref":{"_class":"Var","values":{"_class":"Array","eltype":"Float64","size":[6,2],"layout":"column-major","values":[0.0,0.08985007498214534,0.1788023977155551,0.2659681859952056,0.35047650807778546,0.4314829847437827,0.9,0.8955037487502232,0.8820599200571175,0.8598028402130454,0.8289548946025966,0.7898243057013355]},"unit":["rad","1/s"],"info":"Reference angle and speed"},"wm":{"_class":"Var","unit":"rad/s","state":true,"start":{"_class":"Number","unit":"rad*s^-1","type":"Float64","value":1.0},"alias":"motor.w"},"ref.clock":{"_class":"Var","values":{"_class":"Array","eltype":"Union{Missing, Bool}","size":[6],"layout":"column-major","values":[true,null,null,true,null,null]},"variability":"clock"},"motor.w_c":{"_class":"Var","values":{"_class":"Array","eltype":"Union{Missing, Float64}","size":[6],"layout":"column-major","values":[0.6,null,null,0.8,null,null]},"variability":"clocked","clock":"ref.clock"},"motor.inertia":{"_class":"Par","value":{"_class":"Number","type":"Float32","value":0.02},"unit":"kg*m/s^2"},"motor.data":{"_class":"Par","value":"resources/motorMap.json"},"attributes":{"_class":"Par","info":"This is a test signal table"}}
1+
{"_class":"SignalTable","_classVersion":"0.3.6","time":{"_class":"Var","values":[0.0,0.1,0.2,0.3,0.4,0.5],"unit":"s","independent":true},"load.r":{"_class":"Var","values":{"_class":"Array","eltype":"Float64","size":[6,3],"layout":"column-major","values":[0.0,0.09983341664682815,0.19866933079506122,0.29552020666133955,0.3894183423086505,0.479425538604203,1.0,0.9950041652780258,0.9800665778412416,0.955336489125606,0.9210609940028851,0.8775825618903728,0.0,0.09983341664682815,0.19866933079506122,0.29552020666133955,0.3894183423086505,0.479425538604203]},"unit":"m"},"motor.angle":{"_class":"Var","values":[0.0,0.09983341664682815,0.19866933079506122,0.29552020666133955,0.3894183423086505,0.479425538604203],"unit":"rad","state":true,"der":"motor.w"},"motor.w":{"_class":"Var","values":[1.0,0.9950041652780258,0.9800665778412416,0.955336489125606,0.9210609940028851,0.8775825618903728],"unit":"rad/s","state":true,"start":{"_class":"Number","unit":"rad*s^-1","type":"Float64","value":1.0}},"motor.w_ref":{"_class":"Var","values":{"_class":"Array","eltype":"Float64","size":[6,2],"layout":"column-major","values":[0.0,0.08985007498214534,0.1788023977155551,0.2659681859952056,0.35047650807778546,0.4314829847437827,0.9,0.8955037487502232,0.8820599200571175,0.8598028402130454,0.8289548946025966,0.7898243057013355]},"unit":["rad","1/s"],"info":"Reference angle and speed"},"wm":{"_class":"Var","unit":"rad/s","state":true,"start":{"_class":"Number","unit":"rad*s^-1","type":"Float64","value":1.0},"alias":"motor.w"},"ref.clock":{"_class":"Var","values":{"_class":"Array","eltype":"Union{Missing, Bool}","size":[6],"layout":"column-major","values":[true,null,null,true,null,null]},"variability":"clock"},"motor.w_c":{"_class":"Var","values":{"_class":"Array","eltype":"Union{Missing, Float64}","size":[6],"layout":"column-major","values":[0.6,null,null,0.8,null,null]},"variability":"clocked","clock":"ref.clock"},"motor.inertia":{"_class":"Par","value":{"_class":"Number","type":"Float32","value":0.02},"unit":"kg*m/s^2"},"motor.data":{"_class":"Par","value":"resources/motorMap.json"},"attributes":{"_class":"Map","experiment":{"_class":"Map","stoptime":0.5,"interval":0.01}}}

docs/resources/examples/fileIO/VariousTypes_prettyPrint.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"_class": "SignalTable",
3-
"_classVersion": "0.3.5",
3+
"_classVersion": "0.3.6",
44
"time": {
55
"_class": "Var",
66
"values": [
@@ -178,7 +178,11 @@
178178
"value": "resources/motorMap.json"
179179
},
180180
"attributes": {
181-
"_class": "Par",
182-
"info": "This is a test signal table"
181+
"_class": "Map",
182+
"experiment": {
183+
"_class": "Map",
184+
"stoptime": 0.5,
185+
"interval": 0.01
186+
}
183187
}
184188
}

docs/src/Functions/OverviewOfFunctions.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ Note, *FileIO* functions (e.g. JSON, HDF5) can be directly used, see [FileIO Exa
2828
| [`Par`](@ref) | Returns a parameter signal definition in form of a dictionary. |
2929
| [`isVar`](@ref) | Returns true, if signal is a [`Var`](@ref). |
3030
| [`isPar`](@ref) | Returns true, if signal is a [`Par`](@ref). |
31-
| [`isSignal`](@ref) | Returns true, if signal is a [`Var`](@ref) or a [`Par`](@ref). |
32-
| [`showSignal`](@ref) | Prints a [`Var`](@ref)(...) or [`Par`](@ref)(...) signal to io. |
31+
| [`isMap`](@ref) | Returns true, if signal is a [`Map`](@ref). |
32+
| [`isSignal`](@ref) | Returns true, if signal is a [`Var`](@ref), [`Par`](@ref) or [`Map`](@ref). |
33+
| [`showSignal`](@ref) | Prints a [`Var`](@ref), [`Par`](@ref) or [`Map`](@ref) signal to io. |
3334
| [`eltypeOrType`](@ref) | Returns eltype(..) of AbstractArray or otherwise typeof(..). |
3435
| [`quantity`](@ref) | Returns `Unitful.Quantity` from numberType and numberUnit, e.g. `quantity(Float64,u"m/s")` |
3536
| [`unitAsParseableString`](@ref) | Returns the unit as a String that can be parsed with `Unitful.uparse`, e.g. "m*s^-1" |
@@ -42,7 +43,7 @@ Note, *FileIO* functions (e.g. JSON, HDF5) can be directly used, see [FileIO Exa
4243
| [`getIndependentSignalNames`](@ref) | Returns the names of the independent signals. |
4344
| [`getSignalNames`](@ref) | Returns a string vector of the signal names that are present in a signal table. |
4445
| [`hasSignal`](@ref) | Returns `true` if a signal is present in a signal table. |
45-
| [`getSignal`](@ref) | Returns signal from a signal table as [`Var`](@ref) or as [`Par`](@ref). |
46+
| [`getSignal`](@ref) | Returns signal from a signal table as [`Var`](@ref), [`Par`](@ref) or [`Map`](@ref). |
4647
| [`getSignalInfo`](@ref) | Returns signal with :\_typeof, :\_size keys instead of :values/:value keys. |
4748
| [`getIndependentSignalsSize`](@ref) | Returns the lengths of the independent signals as Dims. |
4849
| [`getValues`](@ref) | Returns the *values* of a [`Var`](@ref) signal from a signal table. |

docs/src/Functions/SignalTables.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The functions below operate on a *signal table* that implements the [Abstract Si
1818
| [`getIndependentSignalNames`](@ref)| Returns the names of the independent signals. |
1919
| [`getSignalNames`](@ref) | Returns a string vector of the signal names that are present in a signal table. |
2020
| [`hasSignal`](@ref) | Returns `true` if a signal is present in a signal table. |
21-
| [`getSignal`](@ref) | Returns signal from a signal table as [`Var`](@ref) or as [`Par`](@ref). |
21+
| [`getSignal`](@ref) | Returns signal from a signal table as [`Var`](@ref), [`Par`](@ref) or [`Map`](@ref). |
2222
| [`getSignalInfo`](@ref) | Returns signal with :\_typeof, :\_size keys instead of :values/:value keys. |
2323
| [`getIndependentSignalsSize`](@ref)| Returns the lengths of the independent signals as Dims. |
2424
| [`getValues`](@ref) | Returns the *values* of a [`Var`](@ref) signal from a signal table. |

docs/src/Functions/Signals.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,23 @@ The functions below operate on *signals*.
1414
|:--------------------------------|:-------------------------------------------------------------------------------------------|
1515
| [`Var`](@ref) | Returns a variable signal definition in form of a dictionary. |
1616
| [`Par`](@ref) | Returns a parameter signal definition in form of a dictionary. |
17+
| [`Map`](@ref) | Returns an attribute signal definition in form of a dictionary. |
1718
| [`isVar`](@ref) | Returns true, if signal is a [`Var`](@ref). |
1819
| [`isPar`](@ref) | Returns true, if signal is a [`Par`](@ref). |
19-
| [`isSignal`](@ref) | Returns true, if signal is a [`Var`](@ref) or a [`Par`](@ref). |
20-
| [`showSignal`](@ref) | Prints a [`Var`](@ref)(...) or [`Par`](@ref)(...) signal to io. |
21-
| [`eltypeOrType`](@ref) | Returns eltype of an array (but without Missing) and otherwise returns typeof. | |
20+
| [`isMap`](@ref) | Returns true, if signal is a [`Map`](@ref). |
21+
| [`isSignal`](@ref) | Returns true, if signal is a [`Var`](@ref), [`Par`](@ref) or [`Map`](@ref). |
22+
| [`showSignal`](@ref) | Prints a [`Var`](@ref), [`Par`](@ref) or [`Map`](@ref) signal to io. |
23+
| [`eltypeOrType`](@ref) | Returns eltype of an array (but without Missing) and otherwise returns typeof. |
2224
| [`quantity`](@ref) | Returns `Unitful.Quantity` from numberType and numberUnit, e.g. `quantity(Float64,u"m/s")` |
2325
| [`unitAsParseableString`](@ref) | Returns the unit as a String that can be parsed with `Unitful.uparse`, e.g. "m*s^-1" |
2426

2527
```@docs
2628
Var
2729
Par
30+
Map
2831
isVar
2932
isPar
33+
isMap
3034
isSignal
3135
showSignal
3236
eltypeOrType

0 commit comments

Comments
 (0)