Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
VILLASdataprocessing
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ACS
Public
VILLASframework
VILLASdataprocessing
Commits
c3169344
Commit
c3169344
authored
6 years ago
by
Markus Mirz
Browse files
Options
Downloads
Patches
Plain Diff
use dpsim code for simulink csv and .real and .imag
parent
240b3a2e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dataprocessing/readtools.py
+39
-12
39 additions, 12 deletions
dataprocessing/readtools.py
with
39 additions
and
12 deletions
dataprocessing/readtools.py
+
39
−
12
View file @
c3169344
...
...
@@ -56,20 +56,47 @@ def read_timeseries_PLECS(filename, timeseries_names=None):
def
read_timeseries_simulink
(
filename
,
timeseries_names
=
None
):
pd_df
=
pd
.
read_csv
(
filename
)
timeseries_list
=
[]
timeseries_list
=
{}
cmpl_result_columns
=
[]
real_result_columns
=
[]
if
timeseries_names
is
None
:
# No trajectory names specified, thus read in all
timeseries_names
=
list
(
pd_df
.
columns
.
values
)
timeseries_names
.
remove
(
'
time
'
)
for
name
in
timeseries_names
:
timeseries_list
.
append
(
TimeSeries
(
name
,
pd_df
[
'
time
'
].
values
,
pd_df
[
name
].
values
))
# No column names specified, thus read in all and strip off spaces
pd_df
.
rename
(
columns
=
lambda
x
:
x
.
strip
(),
inplace
=
True
)
column_names
=
list
(
pd_df
.
columns
.
values
)
# Remove timestamps column name and store separately
column_names
.
remove
(
'
time
'
)
timestamps
=
pd_df
.
iloc
[:,
0
]
# Find real and complex variable names
real_string
=
'
.real
'
imaginary_string
=
'
.imag
'
for
column
in
column_names
:
if
real_string
in
column
:
tmp
=
column
.
replace
(
real_string
,
''
)
cmpl_result_columns
.
append
(
tmp
)
#print("Found complex variable: " + tmp)
elif
not
imaginary_string
in
column
:
real_result_columns
.
append
(
column
)
#print("Found real variable: " + column)
for
column
in
real_result_columns
:
timeseries_list
[
column
]
=
TimeSeries
(
column
,
timestamps
,
pd_df
[
column
])
for
column
in
cmpl_result_columns
:
timeseries_list
[
column
]
=
TimeSeries
(
column
,
timestamps
,
np
.
vectorize
(
complex
)(
pd_df
[
column
+
real_string
],
pd_df
[
column
+
imaginary_string
]))
else
:
# Read in specified time series
for
name
in
timeseries_names
:
timeseries_list
.
append
(
TimeSeries
(
name
,
pd_df
[
'
time
'
].
values
,
pd_df
[
name
].
values
))
print
(
'
cannot read specified columns yet
'
)
print
(
'
Simulink results column names:
'
+
str
(
timeseries_names
))
print
(
'
Simulink results number:
'
+
str
(
len
(
timeseries_list
)))
print
(
'
Simulink results real column names:
'
+
str
(
real_result_columns
))
print
(
'
Simulink results complex column names:
'
+
str
(
cmpl_result_columns
))
print
(
'
Simulink results variable number:
'
+
str
(
len
(
timeseries_list
)))
print
(
'
Simulink results length:
'
+
str
(
len
(
timestamps
)))
return
timeseries_list
...
...
@@ -95,8 +122,8 @@ def read_timeseries_dpsim(filename, timeseries_names=None):
timestamps
=
pd_df
.
iloc
[:,
0
]
# Find real and complex variable names
real_string
=
'
_
re
'
imaginary_string
=
'
_
im
'
real_string
=
'
.
re
al
'
imaginary_string
=
'
.
im
ag
'
for
column
in
column_names
:
if
real_string
in
column
:
tmp
=
column
.
replace
(
real_string
,
''
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment