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
cf5a85ab
Commit
cf5a85ab
authored
7 years ago
by
Jan Dinkelbach
Browse files
Options
Downloads
Patches
Plain Diff
improved input handling and added comments
parent
7c0dd646
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dataprocessing/plottools.py
+25
-7
25 additions, 7 deletions
dataprocessing/plottools.py
dataprocessing/readtools.py
+8
-4
8 additions, 4 deletions
dataprocessing/readtools.py
with
33 additions
and
11 deletions
dataprocessing/plottools.py
+
25
−
7
View file @
cf5a85ab
...
...
@@ -3,20 +3,38 @@ import numpy as np
from
.timeseries
import
*
def
plot_timeseries
(
figure_id
,
timeseries
,
plt_linestyle
=
'
-
'
):
def
plot_timeseries
(
figure_id
,
timeseries
,
plt_linestyle
=
'
-
'
,
plt_linewidth
=
2
,
plt_color
=
None
):
"""
This function plots either a single timeseries or several timeseries in the figure defined by figure_id.
Several timeseries (handed over in a list) are plotted in several subplots.
In order to plot several timeseries in one plot, the function is to be called several times (hold is activated).
"""
plt
.
figure
(
figure_id
)
if
not
isinstance
(
timeseries
,
list
):
plt
.
plot
(
timeseries
.
time
,
timeseries
.
values
,
linestyle
=
plt_linestyle
,
label
=
timeseries
.
label
)
if
plt_color
:
plt
.
plot
(
timeseries
.
time
,
timeseries
.
values
,
linestyle
=
plt_linestyle
,
label
=
timeseries
.
label
,
linewidth
=
plt_linewidth
,
color
=
plt_color
)
else
:
plt
.
plot
(
timeseries
.
time
,
timeseries
.
values
,
linestyle
=
plt_linestyle
,
label
=
timeseries
.
label
,
linewidth
=
plt_linewidth
)
plt
.
gca
().
autoscale
(
axis
=
'
x
'
,
tight
=
True
)
plt
.
legend
()
else
:
for
ts
in
timeseries
:
plt
.
subplot
(
len
(
timeseries
),
1
,
timeseries
.
index
(
ts
)
+
1
)
plt
.
plot
(
ts
.
time
,
ts
.
values
,
linestyle
=
plt_linestyle
,
label
=
ts
.
label
)
if
plt_color
:
plt
.
plot
(
ts
.
time
,
ts
.
values
,
linestyle
=
plt_linestyle
,
label
=
ts
.
label
,
linewidth
=
plt_linewidth
,
color
=
plt_color
)
else
:
plt
.
plot
(
ts
.
time
,
ts
.
values
,
linestyle
=
plt_linestyle
,
label
=
ts
.
label
,
linewidth
=
plt_linewidth
)
plt
.
gca
().
autoscale
(
axis
=
'
x
'
,
tight
=
True
)
plt
.
legend
()
def
set_time_series_labels
(
timeseries_list
,
time_series_labels
):
for
ts
in
timeseries_list
:
ts
.
label
=
time_series_labels
[
timeseries_list
.
index
(
ts
)]
def
set_timeseries_labels
(
timeseries
,
timeseries_labels
):
"""
Sets label attribute of timeseries, later used in plotting functions.
Suitable for single timeseries as well as for several timeseries (handed over in a list).
"""
if
not
isinstance
(
timeseries
,
list
):
timeseries
.
label
=
timeseries_labels
else
:
for
ts
in
timeseries
:
ts
.
label
=
timeseries_labels
[
timeseries
.
index
(
ts
)]
\ No newline at end of file
This diff is collapsed.
Click to expand it.
dataprocessing/readtools.py
+
8
−
4
View file @
cf5a85ab
...
...
@@ -2,18 +2,22 @@ import numpy as np
import
pandas
as
pd
from
.timeseries
import
*
def
read_timeseries_Modelica
(
filename
,
timeseries_names
=
None
):
from
modelicares
import
SimRes
sim
=
SimRes
(
filename
)
timeseries_list
=
[]
if
timeseries_names
is
None
:
# No trajectory names specified, thus read in all
print
(
'
TBD
'
)
else
:
# Read in specified time series
for
name
in
timeseries_names
:
timeseries_list
.
append
(
TimeSeries
(
name
,
sim
(
name
).
times
(),
sim
(
name
).
values
()))
return
timeseries_list
if
not
isinstance
(
timeseries_names
,
list
):
timeseries
=
TimeSeries
(
timeseries_names
,
sim
(
timeseries_names
).
times
(),
sim
(
timeseries_names
).
values
())
else
:
for
name
in
timeseries_names
:
timeseries
=
[]
timeseries
.
append
(
TimeSeries
(
name
,
sim
(
name
).
times
(),
sim
(
name
).
values
()))
return
timeseries
def
read_timeseries_PLECS
(
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