Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
TopFarm2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TOPFARM
TopFarm2
Commits
a8eff8c3
Commit
a8eff8c3
authored
6 years ago
by
Mads M. Pedersen
Browse files
Options
Downloads
Patches
Plain Diff
Optional(default) plot line from initial to current position
parent
8d6edf0f
No related branches found
No related tags found
1 merge request
!94
Handle disabled mpi
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
topfarm/plotting.py
+12
-7
12 additions, 7 deletions
topfarm/plotting.py
with
12 additions
and
7 deletions
topfarm/plotting.py
+
12
−
7
View file @
a8eff8c3
...
...
@@ -23,10 +23,11 @@ def mypause(interval):
class
PlotComp
(
ExplicitComponent
):
colors
=
[
'
b
'
,
'
r
'
,
'
m
'
,
'
c
'
,
'
g
'
,
'
y
'
,
'
orange
'
,
'
indigo
'
,
'
grey
'
]
*
100
def
__init__
(
self
,
memory
=
10
,
delay
=
0.001
):
def
__init__
(
self
,
memory
=
10
,
delay
=
0.001
,
plot_initial
=
True
):
ExplicitComponent
.
__init__
(
self
)
self
.
memory
=
memory
self
.
delay
=
delay
self
.
delay
=
delay
self
.
plot_initial
=
plot_initial
self
.
history
=
[]
self
.
counter
=
0
...
...
@@ -55,6 +56,8 @@ class PlotComp(ExplicitComponent):
def
compute
(
self
,
inputs
,
outputs
):
x
=
inputs
[
'
turbineX
'
]
y
=
inputs
[
'
turbineY
'
]
if
not
hasattr
(
self
,
"
initial
"
):
self
.
initial
=
np
.
array
([
x
,
y
]).
T
cost
=
inputs
[
'
cost
'
]
self
.
history
=
[(
x
.
copy
(),
y
.
copy
())]
+
self
.
history
[:
self
.
memory
]
...
...
@@ -64,7 +67,9 @@ class PlotComp(ExplicitComponent):
history_arr
=
np
.
array
(
self
.
history
)
for
i
,
c
,
x_
,
y_
in
zip
(
range
(
len
(
x
)),
self
.
colors
,
x
,
y
):
plt
.
plot
(
history_arr
[:,
0
,
i
],
history_arr
[:,
1
,
i
],
'
.-
'
,
color
=
c
,
lw
=
1
)
if
self
.
plot_initial
:
plt
.
plot
([
self
.
initial
[
i
,
0
],
x_
],
[
self
.
initial
[
i
,
1
],
y_
],
'
-
'
,
color
=
c
,
lw
=
1
)
plt
.
plot
(
history_arr
[:,
0
,
i
],
history_arr
[:,
1
,
i
],
'
.--
'
,
color
=
c
,
lw
=
1
)
plt
.
plot
(
x_
,
y_
,
'
o
'
,
color
=
c
,
ms
=
5
)
plt
.
plot
(
x_
,
y_
,
'
x
'
+
'
k
'
,
ms
=
4
)
...
...
@@ -73,11 +78,12 @@ class PlotComp(ExplicitComponent):
mypause
(
self
.
delay
)
self
.
counter
+=
1
class
NoPlot
(
PlotComp
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
ExplicitComponent
.
__init__
(
self
)
def
show
(
self
):
pass
...
...
@@ -87,6 +93,5 @@ class NoPlot(PlotComp):
self
.
add_input
(
'
cost
'
,
0.
)
self
.
add_input
(
'
boundary
'
,
np
.
zeros
((
self
.
n_vertices
,
2
)),
units
=
'
m
'
)
def
compute
(
self
,
inputs
,
outputs
):
pass
\ No newline at end of file
pass
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