Commit 5fb58114 authored by {}'s avatar {}

Plot Data + Spain Import

parent 6dabbbad
......@@ -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")
......
......@@ -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 = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment