Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Romain Creuzenet
nf26_projet
Commits
5fb58114
Commit
5fb58114
authored
Jun 13, 2019
by
{}
Browse files
Plot Data + Spain Import
parent
6dabbbad
Changes
2
Hide whitespace changes
Inline
Side-by-side
main.py
View file @
5fb58114
...
...
@@ -63,40 +63,7 @@ class Manager:
x
=
[]
y
=
[]
saisons
=
{
'spring'
:
{
'n'
:
0
,
'somme'
:
0
,
'month'
:
[
3
,
4
,
5
],
# March - May
'end'
:
lambda
dt
:
datetime
(
dt
.
year
,
6
,
1
)
-
timedelta
(
days
=
1
),
'legend'
:
False
,
'color'
:
'r'
},
'summer'
:
{
'n'
:
0
,
'somme'
:
0
,
'month'
:
[
6
,
7
,
8
],
# June - August
'end'
:
lambda
dt
:
datetime
(
dt
.
year
,
9
,
1
)
-
timedelta
(
days
=
1
),
'legend'
:
False
,
'color'
:
'y'
},
'automne'
:
{
'n'
:
0
,
'somme'
:
0
,
'month'
:
[
9
,
10
,
11
],
# September - November
'end'
:
lambda
dt
:
datetime
(
dt
.
year
,
12
,
1
)
-
timedelta
(
days
=
1
),
'legend'
:
False
,
'color'
:
'm'
},
'winter'
:
{
'n'
:
0
,
'somme'
:
0
,
'month'
:
[
12
,
1
,
2
],
# December - Febrarie
'end'
:
lambda
dt
:
datetime
(
dt
.
year
+
1
,
3
,
1
)
-
timedelta
(
days
=
1
),
'legend'
:
False
,
'color'
:
'k'
}
}
query
=
"SELECT * FROM {} WHERE station={}"
.
format
(
self
.
table
,
station
.
__repr__
())
for
row
in
execute_query
(
query
):
value
=
getattr
(
row
,
attr
)
...
...
@@ -104,34 +71,15 @@ class Manager:
continue
x
.
append
(
datetime
(
*
list
(
row
.
time
)))
y
.
append
(
value
)
# For saison
for
saison
,
d
in
saisons
.
items
():
if
row
.
time
[
1
]
in
d
[
'month'
]:
d
[
'n'
]
+=
1
d
[
'somme'
]
+=
value
break
date
,
last_date
=
x
[
0
],
x
[
-
1
]
# first date and last date, initialisation
x
=
np
.
array
(
x
)
y
=
np
.
array
(
y
)
plt
.
plot
(
x
,
y
,
label
=
attr
)
# Mark saison
while
date
<
last_date
:
for
saison
,
d
in
saisons
.
items
():
if
date
.
month
in
d
[
'month'
]:
next_date
=
min
(
last_date
,
d
[
'end'
](
date
))
moyenne
=
d
[
'somme'
]
/
d
[
'n'
]
if
d
[
'legend'
]:
plt
.
plot
([
date
,
next_date
],
[
moyenne
,
moyenne
],
d
[
'color'
],
linewidth
=
4
)
else
:
plt
.
plot
([
date
,
next_date
],
[
moyenne
,
moyenne
],
d
[
'color'
],
label
=
saison
,
linewidth
=
4
)
d
[
'legend'
]
=
True
date
=
next_date
+
timedelta
(
days
=
1
)
break
plt
.
title
(
station
)
plt
.
title
(
"Donnees de "
+
str
(
value
)
+
" pour la station : "
+
station
)
plt
.
legend
()
plt
.
show
()
plt
.
savefig
(
'plot.png'
)
def
map
(
self
):
print
(
"Cette fonction n'est pas implémentée"
)
...
...
parameters.py
View file @
5fb58114
...
...
@@ -7,7 +7,7 @@ from collections import OrderedDict
import
os
import
datetime
# Can be specified
KEY_SPACE
=
"
nf26
"
KEY_SPACE
=
"
lhamadac_projet
"
TABLE
=
"Spain"
# Don't change
...
...
@@ -22,12 +22,17 @@ COLUMNS = OrderedDict([
(
'lon'
,
float
),
(
'lat'
,
float
),
(
'tmpf'
,
float
),
(
'tmpc'
,
float
),
(
'dwpf'
,
float
),
(
'dwpc'
,
float
),
(
'relh'
,
float
),
(
'drct'
,
float
),
(
'sknt'
,
float
),
(
'sped'
,
float
),
(
'alti'
,
float
),
(
'mslp'
,
float
),
# ('p01m',float), all null
# ('p01i',float), all null
(
'vsby'
,
float
),
(
'gust'
,
float
),
(
'skyc1'
,
str
),
...
...
@@ -45,8 +50,7 @@ COLUMNS = OrderedDict([
# ('peak_wind_gust', ), all null
# ('peak_wind_drct', ), all null
# ('peak_wind_time', ), all null
(
'feel'
,
float
),
(
'metar'
,
str
)
(
'feel'
,
float
)
])
# Name of table -> Primary key
TABLES
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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