/
consec80.py
executable file
·49 lines (40 loc) · 1.31 KB
/
consec80.py
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
37
38
39
40
41
42
43
44
45
46
47
48
import mx.DateTime
import sys
import numpy
import iemdb
COOP = iemdb.connect("coop", bypass=True)
ccursor = COOP.cursor()
ccursor.execute("""SELECT month, high, year, day from alldata
WHERe station = 'IA2203' and day >= '1893-01-01' and month = 12
ORDER by day ASC""" )
running = 0
biggest = 0
for row in ccursor:
if row[1] >= 50:
running += 1
if running >= biggest:
biggest = running
if running > 3 and row[3].day > 20:
print running, row
else:
running = 0
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
bars = ax.bar(numpy.arange(1,13) - 0.4, biggest , fc='r', ec='r')
for i in range(len(bars)):
bar = bars[i]
year = years[i]
if bar.get_height() > 0:
ax.text(i+1, bar.get_height()+1, "%.0f" % (years[i],),ha='center')
ax.text(i+1, bar.get_height()- 1.0, "%.0f" % (biggest[i],), ha='center')
ax.set_xlim(0.5,12.5)
ax.set_xticks( numpy.arange(1,13))
ax.set_xticklabels(('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec') )
ax.set_ylabel("Consecuative Days")
ax.set_title("Ames Consecuative Days with highs over 80$^{\circ}\mathrm{F}$\nMaximum by month, last year occurred [1893-2011]")
ax.set_xlabel("*2011 Total thru 3 Oct")
ax.grid(True)
fig.savefig('test.ps')
import iemplot
iemplot.makefeature('test')