(I002) setInputsCSV() - #447
Conversation
bf405db to
56a787c
Compare
|
from PR #404:
I would not do it via a pandas dataframe as this would add the dependency to OMPython; but using the dictionary would work - at the end, the current code just converts the CSV file to a dictionary to apply it to the existing data. @joewa would this work for you? |
|
Yes, that would work for me @syntron . When using tables / DataFrames this helper function proved to be useful too: def toInputs(data: dict[str, list[float]]) -> dict[str, list[tuple[float, float]]]:
"""
Converts a dictionary of lists (from pandas DataFrame.to_dict(orient='list'))
into the OMPython setInputs input format.
Example: mod.setInputs(**toInputs(pdf.to_dict(orient='list')))
Assumes the dictionary contains a key named 'time'.
"""
if "time" not in data:
raise ValueError("The provided data must contain a 'time' key.")
time_series = data["time"]
inputs = {
var_name: list(zip(time_series, values))
for var_name, values in data.items()
if var_name != "time"
}
return inputsShall we add it as well? |
Looks good to me! This can be added as a |
…ut to OMPython input based on code written by joewa (see OpenModelica#447 (comment))
|
Perfect! |
03a50ab to
7822295
Compare
f7d2e68 to
5354c7d
Compare
7e96fd2 to
c9ff882
Compare
…ased on the content of a CSV file
…ut to OMPython input based on code written by joewa (see OpenModelica#447 (comment))
c9ff882 to
d8a554b
Compare
Read content from a CSV file and use it to define the time based input data.
See issue #353 - currently completly untested from my side!
@FaBiasch could you please tests?