-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Column access defined - Restricting JLD2 to version smaller 0.4.37
- Loading branch information
1 parent
f93ebd4
commit 35b6f27
Showing
6 changed files
with
82 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# | ||
# Copyright (c) 2023 Andreas Heuermann | ||
# Licensed under the MIT license. See LICENSE file in the project root for details. | ||
# | ||
|
||
using FMIImport: FMUSolution | ||
|
||
# Declare that FMUSolution is a table | ||
Tables.istable(::Type{<:FMUSolution}) = true | ||
|
||
# TODO: Define [optional] schema | ||
|
||
# Column interface | ||
Tables.columnaccess(table) = true | ||
|
||
function Tables.columns(solution::FMUSolution) | ||
return solution | ||
end | ||
|
||
""" | ||
Retrieve a column by index. | ||
""" | ||
function Tables.getcolumn(solution::FMUSolution, i::Int)::Vector{Float64} | ||
if i == 1 # Time | ||
return solution.values.t | ||
end | ||
# Variables | ||
return [val[i-1] for val in solution.values.saveval] | ||
end | ||
|
||
""" | ||
Retrieve a column by name. | ||
""" | ||
function Tables.getcolumn(solution::FMUSolution, nm::Symbol) | ||
if nm == :time # Time | ||
return solution.values.t | ||
end | ||
# Variables | ||
vr = first(fmi2StringToValueReference(solution.component.fmu, string(nm))) | ||
idx = findfirst(idx -> idx == vr, solution.valueReferences) | ||
return [val[idx] for val in solution.values.saveval] | ||
end | ||
|
||
""" | ||
Return column names for a table as an indexable collection. | ||
""" | ||
function Tables.columnnames(solution::FMUSolution) | ||
names = Symbol[] | ||
push!(names, Symbol("time")) | ||
for i in 1:length(solution.values.saveval[1]) | ||
var = fmi2ValueReferenceToString(solution.component.fmu, solution.valueReferences[i]) | ||
append!(names, Symbol.(var)) | ||
end | ||
return unique(names) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
[compat] | ||
julia = "1.6" | ||
|
||
[deps] | ||
CSV="336ed68f-0bac-5ca0-87d4-7b16caf5d00b" | ||
DataFrames="a93c6f00-e57d-5684-b7b6-d8193f3e46c0" | ||
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" | ||
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" | ||
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa" | ||
FMIZoo = "724179cf-c260-40a9-bd27-cccc6fe2f195" | ||
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" | ||
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819" | ||
MAT="23992714-dd62-5051-b70f-ba57cb901cac" | ||
MAT = "23992714-dd62-5051-b70f-ba57cb901cac" | ||
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" | ||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" | ||
|
||
[compat] | ||
julia = "1.6" | ||
Tables = "1" | ||
JLD2 = "< 0.4.37" | ||
|
||
[extras] | ||
CPUSummary = "2a0fbf3d-bb9c-48f3-b0a9-814d99fd7ab9" |