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

Save simulation results to CSV / MAT #148

Closed
AnHeuermann opened this issue Sep 19, 2022 · 5 comments · Fixed by #168
Closed

Save simulation results to CSV / MAT #148

AnHeuermann opened this issue Sep 19, 2022 · 5 comments · Fixed by #168
Assignees
Labels
enhancement New feature or request

Comments

@AnHeuermann
Copy link

Feature Request

Is there a (simple) way to save the simulation results to a *.csv or *.mat file? I couldn't find one.

I can create a DataFrame and save it myself, but it is very inconvenient. An API function would be very nice.

My Workaround

using FMI
using DataFrames
using CSV

outputVars = ["outputs[1]", "outputs[2]", "outputs[3]", "outputs[4]", "outputs[5]", "outputs[6]", "outputs[7]", "outputs[8]"]
result = fmiSimulate(fmu, 0.0, 10.0; recordValues=outputVars)

df = DataFrame(time = result.values.t)
for i in 1:length(result.values.saveval[1])
  df[!, Symbol(names[i])] = [val[i] for val in result.values.saveval]
end
CSV.write(resultFile, df)
@ThummeTo
Copy link
Owner

We could add this as weak dependency using Requires.jl.
There is already a command fmiSaveSolution, we could make a "dispatch" for file formats other than JLD2 (only if MAT.jl or CSV.jl is imported).

I will add this soon.

@ThummeTo ThummeTo self-assigned this Oct 13, 2022
@ThummeTo ThummeTo added the enhancement New feature or request label Oct 13, 2022
@JoKircher
Copy link
Contributor

@ThummeTo should I handle this or is it of rather low priority?

@AnHeuermann
Copy link
Author

Julia 1.9 can now handle package extensions similar to Requires.jl:
https://pkgdocs.julialang.org/dev/creating-packages/#Conditional-loading-of-code-in-packages-(Extensions)

@ThummeTo
Copy link
Owner

will be closed with #175

@ThummeTo
Copy link
Owner

closed in v0.12.1

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

Successfully merging a pull request may close this issue.

3 participants