OMJulia.jl
OMJulia.jl copied to clipboard
Return dataframe from getSolutions
The getSolutions
function behaves very different when setting input name=nothing
. It's not returning solutions but a list of all variables in the result file.
I would expect to get the solution of all variables in that case.
The output format for getSolutions(mod, ["time","a"])
is Vector{Vector{Float64}}
. Why not a data frame?
And I would expect to always get time in the data frame. Otherwise the solution of only a
is useless.
@AnHeuermann
The
getSolutions
function behaves very different when setting inputname=nothing
. It's not returning solutions but a list of all variables in the result file. I would expect to get the solution of all variables in that case.
These API was designed based on the proposal from bernt lie see https://ep.liu.se/ecp/157/072/ecp19157072.pdf, And offcourse in OpenModelica scripting API, readSimulationResults
without any vars gives the result of all variables in the result file, then we have to customize the API
The output format for
getSolutions(mod, ["time","a"])
isVector{Vector{Float64}}
. Why not a data frame? And I would expect to always get time in the data frame. Otherwise the solution of onlya
is useless.
Sure we can convert them, but I hope you can also convert it manually, this was done basically to make the plotting easy in the plot library from julia
I guess we could convert it to a data frame afterwards. But of course users can do it manually as well.
As you see in the paper returning the results in Vector{Float64}
makes it easy for plotting tools, off course there are some other plotting tools which accepts data frame.
Also i am currently working on julia wrapper functions for OpenModelica Scripting API, where we can have most of the settings available, I am trying to write some automation script which generates the API.jl
and it will be easier
I don't think it matters too much if you are using a DataFrame
or something else. All plotting packages I know of work fine with DataFrames and in the end df[!, "time"], df[!,"h"]
is basically the same as two vectors.
DataFrames only offer an improved handling, so you don't need to search for the index of variable h
in the Vector{Vector{Float64}}
. And of yours it keeps data together that needs to be kept together.
time, h = tnk.getSolutions(["time","h"])
plot(time, h)
and
df = tnk.getSolutions(["h", "x", "y"])
plot(Matrix(df)) # Plot everything
plot(df[!,"time"], df[!,"h"]) # plot (t,h)
But yeah, I don't need this right now, so I could close this issue or we leave it open.