Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
esm-course
esm-tutorials
Commits
486c4760
Commit
486c4760
authored
Jul 09, 2018
by
sp2668
Browse files
basemap integration
parent
40c77856
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
tutorial-4/solution.tex
deleted
100644 → 0
View file @
40c77856
tutorial-5/solution05-2.ipynb
View file @
486c4760
This diff is collapsed.
Click to expand it.
tutorial-6/tutorial.py
View file @
486c4760
...
...
@@ -11,9 +11,8 @@ from sklearn.cluster import KMeans, SpectralClustering
from
mpl_toolkits.basemap
import
Basemap
### FUNCTIONS
def
plot_clusters
(
network
,
y_pred
,
X
,
lim_fig
=
"None"
):
colors_choice
=
[
'b'
,
'g'
,
'r'
,
'c'
,
'y'
,
'violet'
,
'purple'
,
'k'
,
'chartreuse'
,
'indianred'
,
'pink'
,
'orange'
,
'gray'
,
'yellow'
,
'springgreen'
,
'indigo'
,
'brown'
,
'silver'
,
'aqua'
]
*
(
int
(
max
(
y_pred
)
/
19
)
+
1
)
colors_list
=
[
colors_choice
[
x
]
for
x
in
y_pred
]
...
...
@@ -33,10 +32,10 @@ def plot_clusters(network, y_pred,X,lim_fig="None"):
plt
.
show
()
def
plot_network
(
network
,
option
=
"AC_DC"
,
basemap
=
"no"
):
fig
,
ax
=
plt
.
subplots
()
fig
.
set_size_inches
(
15
,
15
)
if
basemap
==
"yes"
:
long_min
=-
10
long_max
=
30
...
...
@@ -77,6 +76,7 @@ def plot_network(network,option="AC_DC",basemap="no"):
plt
.
legend
(
handles
=
[
blue_line
,
green_line
,
orange_line
,
red_line
,
violet_line
])
def
find_kmeans_busmap
(
n_clusters
,
n
,
n_weightings
,
**
kwargs
):
kmeans
=
KMeans
(
init
=
'k-means++'
,
n_clusters
=
n_clusters
,
**
kwargs
)
kmeans
.
fit
(
n
[[
"x"
,
"y"
]].
values
)
...
...
@@ -104,6 +104,7 @@ def P_nom_re(network,w_s=2.5,w_onw=0.2,w_ofw=0.1):
network
.
generators
.
loc
[
network
.
generators
[
'carrier'
]
==
'offwind'
,
"p_nom"
]
=
network
.
generators
.
loc
[
network
.
generators
[
'carrier'
]
==
'offwind'
,
"weight"
]
*
w_ofw
def
lopf_d_h
(
network
,
day
,
hour
):
network
.
set_snapshots
(
pd
.
DatetimeIndex
(
start
=
hour
.
format
(
day
),
end
=
hour
.
format
(
day
),
freq
=
'H'
))
# solve linear optimal power flow
...
...
@@ -111,6 +112,7 @@ def lopf_d_h(network,day,hour):
solver_name
=
'glpk'
)
def
plot_line_loading
(
network
):
fig
,
ax
=
plt
.
subplots
()
ax
.
set_ylim
([
35
,
72
])
fig
.
set_size_inches
(
15
,
15
)
...
...
@@ -132,6 +134,7 @@ def plot_line_loading(network):
plt
.
colorbar
(
fraction
=
0.01
,
pad
=
0.01
)
def
plot_bus_status
(
network
):
fig
,
ax
=
plt
.
subplots
()
ax
.
set_ylim
([
35
,
72
])
fig
.
set_size_inches
(
15
,
15
)
...
...
@@ -169,6 +172,7 @@ def plot_bus_status(network):
plt
.
colorbar
(
fraction
=
0.01
,
pad
=
0.01
)
def
plot_line_loading_bus_status
(
network
):
fig
,
ax
=
plt
.
subplots
()
ax
.
set_ylim
([
35
,
72
])
fig
.
set_size_inches
(
15
,
15
)
...
...
tutorial-6/tutorial06.ipynb
deleted
100644 → 0
View file @
40c77856
This source diff could not be displayed because it is too large. You can
view the blob
instead.
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment