Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return dataframe from getSolutions #101

Open
AnHeuermann opened this issue Sep 7, 2023 · 5 comments
Open

Return dataframe from getSolutions #101

AnHeuermann opened this issue Sep 7, 2023 · 5 comments

Comments

@AnHeuermann
Copy link
Member

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.

@arun3688
Copy link
Contributor

arun3688 commented Sep 7, 2023

@AnHeuermann

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.

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"]) 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.

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

@AnHeuermann
Copy link
Member Author

AnHeuermann commented Sep 7, 2023

I guess we could convert it to a data frame afterwards. But of course users can do it manually as well.

@arun3688
Copy link
Contributor

arun3688 commented Sep 7, 2023

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.

@arun3688
Copy link
Contributor

arun3688 commented Sep 7, 2023

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

@AnHeuermann
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants