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
9a993726
Commit
9a993726
authored
7 years ago
by
Markus Mirz
Browse files
Options
Downloads
Patches
Plain Diff
cleaned function and removed unecessary prints
parent
b5c1ae4c
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
+17
-29
17 additions, 29 deletions
dataprocessing/readtools.py
with
17 additions
and
29 deletions
dataprocessing/readtools.py
+
17
−
29
View file @
9a993726
...
...
@@ -46,46 +46,35 @@ def read_timeseries_PLECS(filename, timeseries_names=None):
timeseries_list
.
append
(
TimeSeries
(
name
,
pd_df
[
'
Time
'
].
values
,
pd_df
[
name
].
values
))
return
timeseries_list
def
read_timeseries_dpsim_real
(
filename
,
header
=
None
,
timeseries_names
=
None
):
def
read_timeseries_dpsim_real
(
filename
,
timeseries_names
=
None
):
"""
Reads real time series data from DPsim log file which may have a header.
Timeseries names are assigned according to the header names if available.
:param filename: name of the csv file that has the data
:param header: specifies if the log file has a header
:param timeseries_names: column names which should be read
:return: list of Timeseries objects
"""
timeseries_list
=
[]
if
header
is
True
:
pd_df
=
pd
.
read_csv
(
filename
)
else
:
pd_df
=
pd
.
read_csv
(
filename
,
header
=
None
)
pd_df
=
pd
.
read_csv
(
filename
)
if
timeseries_names
is
None
:
# No trajectory names specified, thus read in all
# No column names specified, thus read in all and strip spaces
pd_df
.
rename
(
columns
=
lambda
x
:
x
.
strip
(),
inplace
=
True
)
column_names
=
list
(
pd_df
.
columns
.
values
)
print
(
'
DPsim results column names:
'
+
str
(
column_names
))
print
(
'
DPsim results number:
'
+
str
(
len
(
timeseries_list
)))
# Remove timestamps column name and store separately
column_names
.
remove
(
0
)
column_names
.
remove
(
'
time
'
)
timestamps
=
pd_df
.
iloc
[:,
0
]
if
header
is
True
:
for
name
in
column_names
:
timeseries_list
.
append
(
TimeSeries
(
name
,
timestamps
,
pd_df
[
name
].
values
))
else
:
node_number
=
int
(
len
(
column_names
))
node_index
=
1
for
column
in
column_names
:
ts_name
=
'
node
'
+
str
(
node_index
)
timeseries_list
.
append
(
TimeSeries
(
ts_name
,
timestamps
,
pd_df
.
iloc
[:,
column
]))
node_index
=
node_index
+
1
else
:
# Read in specified time series
print
(
'
no column names specified yet
'
)
print
(
'
DPsim results file length:
'
)
print
(
len
(
timeseries_list
))
for
result
in
timeseries_list
:
print
(
result
.
name
)
return
timeseries_list
def
read_timeseries_dpsim_cmpl
(
filename
,
timeseries_names
=
None
):
...
...
@@ -99,21 +88,24 @@ def read_timeseries_dpsim_cmpl(filename, timeseries_names=None):
timeseries_list
=
[]
if
timeseries_names
is
None
:
# No
trajectory
names specified, thus read in all
# 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
)
print
(
column_names
)
print
(
'
DPsim results column names:
'
+
str
(
column_names
))
print
(
'
DPsim results number:
'
+
str
(
len
(
timeseries_list
)))
# Remove timestamps column name and store separately
column_names
.
remove
(
'
time
'
)
print
(
column_names
)
timestamps
=
pd_df
.
iloc
[:,
0
]
# Calculate number of network nodes since array is [real, imag]
node_number
=
int
(
len
(
column_names
)
/
2
)
node_index
=
1
for
column
in
column_names
:
if
node_index
<=
node_number
:
ts_name
=
'
node
'
+
str
(
node_index
)
timeseries_list
.
append
(
TimeSeries
(
ts_name
,
timestamps
,
np
.
vectorize
(
complex
)(
pd_df
.
iloc
[:,
node_index
],
pd_df
.
iloc
[:,
node_index
+
node_number
])))
ts_name
=
'
n
'
+
str
(
node_index
)
timeseries_list
.
append
(
TimeSeries
(
ts_name
,
timestamps
,
np
.
vectorize
(
complex
)(
pd_df
.
iloc
[:,
node_index
],
pd_df
.
iloc
[:,
node_index
+
node_number
])))
else
:
break
node_index
=
node_index
+
1
...
...
@@ -121,10 +113,6 @@ def read_timeseries_dpsim_cmpl(filename, timeseries_names=None):
# Read in specified time series
print
(
'
cannot read specified columns yet
'
)
print
(
'
DPsim results file length:
'
)
print
(
len
(
timeseries_list
))
for
result
in
timeseries_list
:
print
(
result
.
name
)
return
timeseries_list
def
read_timeseries_dpsim_cmpl_separate
(
filename
,
timeseries_names
=
None
):
...
...
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