-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpm_5.py
More file actions
36 lines (30 loc) · 901 Bytes
/
pm_5.py
File metadata and controls
36 lines (30 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# -*- coding: utf-8 -*-
"""
pm_5.py
Plot of the hourly temperatures at Saint-Maur averaged over july,August and september
"""
#import libraries
import matplotlib.pylab as py
import openDB as odb
#get the data
#get your connection identifiers
f=open('./identifiers.txt')
mylogin=f.readline().strip('\n')
mypass=f.readline().strip('\n')
#establish the connection
o = odb.OpenDB(base = "Parcelle", user = mylogin, passwd = mypass, host = "localhost")
#write and execute the query
sql = "select hour(date), avg(tairav) from imetos where month(date) in (7,8,9) group by hour(date)"
res = py.array(o.execQuery(sql))
o.close()
#retrieve the results
h = res.transpose()[0]
ta = res.transpose()[1]
#plot the result
fig = py.figure()
py.plot(h, ta, 'ro-')
py.xlabel("Hour of the day", fontsize = 14)
py.ylabel('Average temperature $^oC$', fontsize = 14)
py.axis([0, 24, 10, 25 ])
py.grid(True)
py.show()