Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Simon Bazin
nf26-metar
Commits
26305be1
Commit
26305be1
authored
Jun 23, 2019
by
sim-baz
Browse files
Details
parent
86c8b86e
Changes
4
Hide whitespace changes
Inline
Side-by-side
history.py
View file @
26305be1
...
...
@@ -123,18 +123,24 @@ def plotHistory(station, indicator, dateMin, dateMax):
# Plot, with both measures and season mean
fig
,
ax1
=
plt
.
subplots
()
# Measures on axis 1
ax1
.
plot_date
(
table_mean
.
keys
(),
table_mean
.
values
(),
'-'
,
xdate
=
True
)
ax1
.
plot_date
(
table_mean
.
keys
(),
table_mean
.
values
(),
'-'
,
xdate
=
True
,
label
=
'Evolution'
)
ax1
.
xaxis
.
set_ticks
(
graduation
)
ax2
=
ax1
.
twiny
()
# Seasonal mean
ax2
.
plot
([
elt
[
0
]
for
elt
in
liste
],
[
elt
[
1
]
for
elt
in
liste
],
'-'
,
color
=
"r"
)
ax2
.
plot
([
elt
[
0
]
for
elt
in
liste
],
[
elt
[
1
]
for
elt
in
liste
],
'-'
,
color
=
"r"
,
label
=
'Saison'
)
# Do not show graduation on the top of the plot
ax2
.
xaxis
.
set_ticks
([])
# Set title and labels
plt
.
title
(
f
"Evolution de
{
indicator
}
pour la station
{
station
}
"
)
plt
.
xlabel
(
'Date'
)
plt
.
ylabel
(
indicator
)
ax1
.
set_xlabel
(
'Date'
)
ax1
.
set_ylabel
(
indicator
)
# Legend
h1
,
l1
=
ax1
.
get_legend_handles_labels
()
h2
,
l2
=
ax2
.
get_legend_handles_labels
()
plt
.
legend
(
h1
+
h2
,
l1
+
l2
,
loc
=
'lower right'
)
plt
.
tick_params
(
axis
=
'x'
,
which
=
'both'
,
...
...
kmeans.py
View file @
26305be1
...
...
@@ -135,9 +135,9 @@ def kmeans(startPeriod, endPeriod, indicators_list):
station_with_center
=
applyKmeans
(
table_deciles
,
nb_indicators
,
indicators_list_numeric
,
startPeriod
,
endPeriod
)
if
station_with_center
!=
None
:
file_name
=
f
"
{
startPeriod
}
to
{
endPeriod
}
.html"
file_name
=
f
"
map_kmeans_
{
startPeriod
}
_
to
_
{
endPeriod
}
.html"
# Create map
m
=
folium
.
Map
(
location
=
[
64.2815
,
27.6753
])
m
=
folium
.
Map
(
location
=
[
64.2815
,
27.6753
]
,
zoom_start
=
5
)
# Add Marker for each station
for
key
,
value
in
station_with_center
.
items
():
folium
.
Marker
([
coord
[
key
][
0
],
coord
[
key
][
1
]],
popup
=
f
"<b>
{
key
}
</b>"
,
icon
=
folium
.
Icon
(
color
=
colours
[
value
])).
add_to
(
m
)
...
...
loading.py
View file @
26305be1
...
...
@@ -368,18 +368,18 @@ if __name__ == '__main__':
dict
=
loadata
(
FILE_NAME
)
#
#
--------------------------------------------------------
#
#
A faire seulement 1 fois pour charger les données
#
session.execute(dropTableQuery(table_name_space))
#
print(f"Table {table_name_space} dropped")
#
session.execute(createTableQuery(table_name_space))
#
print(f"Table {table_name_space} created")
#
print(f"Starting inserting datas into table {table_name_space}")
#
for d in dict:
#
session.execute(insertQueryData(d, table_name_space))
#
print(f"Datas inserted into {table_name_space}")
#
#
--------------------------------------------------------
# --------------------------------------------------------
# A faire seulement 1 fois pour charger les données
session
.
execute
(
dropTableQuery
(
table_name_space
))
print
(
f
"Table
{
table_name_space
}
dropped"
)
session
.
execute
(
createTableQuery
(
table_name_space
))
print
(
f
"Table
{
table_name_space
}
created"
)
print
(
f
"Starting inserting datas into table
{
table_name_space
}
"
)
for
d
in
dict
:
session
.
execute
(
insertQueryData
(
d
,
table_name_space
))
print
(
f
"Datas inserted into
{
table_name_space
}
"
)
# --------------------------------------------------------
# --------------------------------------------------------
# A faire seulement 1 fois pour charger les données
...
...
map.py
View file @
26305be1
...
...
@@ -52,9 +52,9 @@ def mapIndicator(date, indicators):
print
(
f
"Aucune donnée pour pour le jour :
{
year
}
-
{
month
}
-
{
day
}
"
)
return
else
:
file_name
=
f
"
{
year
}
-
{
month
}
-
{
day
}
.html"
file_name
=
f
"
map_for_
{
year
}
-
{
month
}
-
{
day
}
.html"
# Create map
m
=
folium
.
Map
(
location
=
[
64.2815
,
27.6753
])
m
=
folium
.
Map
(
location
=
[
64.2815
,
27.6753
]
,
zoom_start
=
5
)
# Add Marker for each station
for
d
in
data
:
text
=
''
...
...
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