Ejemplo n.º 1
0
#output = open('ragbrai.dat', 'w')
for sdate,edate in DATES:
    acursor.execute("""
    SELECT tmpf, dwpf, sknt, drct, valid from t%s WHERE station = 'DSM' and valid BETWEEN '%s 00:00' and '%s 23:59' and tmpf > 0
    and dwpf > 0 and sknt >= 0 and drct >= 0 ORDER by valid ASC
    """ % (sdate.year, sdate.strftime("%Y-%m-%d"), edate.strftime("%Y-%m-%d") ))
    cnt = 0
    tot = 0
    ttot = 0
    utot = 0
    ucnt = 0
    vtot = 0
    for row in acursor:
        ttot += row[0]
        h = mesonet.heatidx(row[0], mesonet.relh(row[0], row[1]))
        if row[4].hour > 5 and row[4].hour < 22:
            u,v = uv(row[2], row[3])
        #output.write("%s,%s,%s,%.1f,%.2f,%.2f\n" % (row[4].strftime("%Y,%m,%d,%H,%M"), row[0], row[1], h, u, v))
            utot += u
            vtot += v
            ucnt += 1
        tot += h
        cnt += 1
    print "%s %3s %4.1f %4.1f %4.1f %4.1f" % (sdate.year, cnt, ttot / float(cnt), tot / float(cnt), utot / float(ucnt), vtot / float(ucnt))
    uwnd[sdate.year-1973] = utot / float(ucnt) * 1.15
    hindex[sdate.year-1973] = tot / float(cnt)
#output.close()

import matplotlib.pyplot as plt
fig = plt.figure()
Ejemplo n.º 2
0
#output = open('ragbrai.dat', 'w')
for sdate, edate in DATES:
    acursor.execute("""
    SELECT tmpf, dwpf, sknt, drct, valid from t%s WHERE station = 'DSM' and valid BETWEEN '%s 00:00' and '%s 23:59' and tmpf > 0
    and dwpf > 0 and sknt >= 0 and drct >= 0 ORDER by valid ASC
    """ % (sdate.year, sdate.strftime("%Y-%m-%d"), edate.strftime("%Y-%m-%d")))
    cnt = 0
    tot = 0
    ttot = 0
    utot = 0
    ucnt = 0
    vtot = 0
    for row in acursor:
        ttot += row[0]
        h = mesonet.heatidx(row[0], mesonet.relh(row[0], row[1]))
        if row[4].hour > 5 and row[4].hour < 22:
            u, v = uv(row[2], row[3])
            #output.write("%s,%s,%s,%.1f,%.2f,%.2f\n" % (row[4].strftime("%Y,%m,%d,%H,%M"), row[0], row[1], h, u, v))
            utot += u
            vtot += v
            ucnt += 1
        tot += h
        cnt += 1
    print "%s %3s %4.1f %4.1f %4.1f %4.1f" % (
        sdate.year, cnt, ttot / float(cnt), tot / float(cnt),
        utot / float(ucnt), vtot / float(ucnt))
    uwnd[sdate.year - 1973] = utot / float(ucnt) * 1.15
    hindex[sdate.year - 1973] = tot / float(cnt)
#output.close()
Ejemplo n.º 3
0
import mx.DateTime
data = {}
sts = mx.DateTime.DateTime(2010,7,1)
ets = mx.DateTime.DateTime(2010,8,17)
interval = mx.DateTime.RelativeDateTime(days=1)

now = sts
while now < ets:
  data[now.strftime("%Y%m%d")] = [0]*24
  now += interval

rs = asos.query("SELECT valid, tmpf, dwpf from t2010 WHERE station = 'DSM' and valid > '2010-07-01' ORDER by valid ASC").dictresult()
for i in range(len(rs)):
  ts = mx.DateTime.strptime(rs[i]['valid'][:16], '%Y-%m-%d %H:%M')
  h = mesonet.heatidx(rs[i]['tmpf'], mesonet.relh(rs[i]['tmpf'], rs[i]['dwpf']))
  data[ ts.strftime("%Y%m%d") ][ ts.hour ] = h

sts = mx.DateTime.DateTime(2010,7,1)
ets = mx.DateTime.DateTime(2010,8,17)
interval = mx.DateTime.RelativeDateTime(days=1)

now = sts
while now < ets:
  lkp = now.strftime("%Y%m%d")
  sz = 24.0
  cln = []
  for v in data[lkp]:
    if v != 0:
      cln.append(v)
  print "%s,%.2f,%.2f,%.2f" % (now.strftime("%Y-%m-%d"), max(cln), sum( cln ) / float(len(cln)), min(cln) )