コード例 #1
0
ファイル: stage4_24h_heavy.py プロジェクト: KayneWest/iem
def doday():
    """
    Create a plot of precipitation stage4 estimates for some day
    """
    sts = mx.DateTime.DateTime(2013,5,25,12)
    ets = mx.DateTime.DateTime(2013,5,31,12)
    interval = mx.DateTime.RelativeDateTime(days=1)
    now = sts
    total = None
    while now < ets:
        fp = "/mesonet/ARCHIVE/data/%s/stage4/ST4.%s.24h.grib" % (
            now.strftime("%Y/%m/%d"), 
            now.strftime("%Y%m%d%H") )
        if os.path.isfile(fp):
            lts = now
            grbs = pygrib.open(fp)

            if total is None:
                g = grbs[1]
                total = g["values"]
                lats, lons = g.latlons()
            else:
                total += grbs[1]["values"]
            grbs.close()
        now += interval
        
    m = MapPlot(sector='iowa', title='NOAA Stage IV & Iowa ASOS Precipitation',
                subtitle='25-30 May 2013')
    m.pcolormesh(lons, lats, total / 25.4, numpy.arange(0,14.1,1), latlon=True,
                 units='inch')
    m.drawcounties()
    m.plot_values(dlons, dlats, dvals, '%.02f')
    m.postprocess(filename='test.svg')
    import iemplot
    iemplot.makefeature('test')
コード例 #2
0
ファイル: thanksgiving.py プロジェクト: KayneWest/iem
  row = ccursor.fetchone()
  days.append( row[1] )
  
import matplotlib.pyplot as plt
import numpy

days = numpy.array( days )

fig = plt.figure()
ax = fig.add_subplot(111)

rects = ax.bar( numpy.arange(1880,2013) - 0.4, days, facecolor='b', edgecolor='b')
for rect in rects:
    if rect.get_height() >= days[-1]:
        rect.set_edgecolor('r')
        rect.set_facecolor('r')
ax.set_xlim(1879.5, 2012.5)
ax.set_ylim(20, 70)
ax.set_ylabel("Average High Temperature $^{\circ}\mathrm{F}$")
ax.set_title("Des Moines [1880-2012] Average High Temperature \n for week before Thanksgiving (inclusive)")
ax.set_xlabel("* 2012 Warmest")
#ax.set_xticks( numpy.arange(1895,2015,5) )
ax.grid(True)

import iemplot
fig.savefig('test.ps')
iemplot.makefeature('test')

#for i in range(7):
#  print i, total_error[i] / 117.0, total_rain[i] / 117.0, total_snow[i] / 117.0
コード例 #3
0
ファイル: corn_cond.py プロジェクト: nbackas/iem
        ax[row, col].set_xticklabels(
            ('May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'))
        ax[row, col].set_xlim(120, 310)
        ax[row, col].grid(True)
        ax[row, col].set_ylim(0, 100)
        if col == 0:
            ax[row, col].set_ylabel("Coverage [%]")
        ax[row, col].set_title(" ")
        ax[row, col].text(126, 85, states[i].capitalize(), size=16)
        i += 1

#ax[0,0].set_title("USDA Weekly Crop Progress Report (1979-2012)\nIowa Corn Planting Progress (6 years highlighted)")

fig.text(
    0.5,
    .91,
    'USDA Weekly Corn Crop Condition Report (1986-2014)\nPercentage of State in Poor & Very Poor Condition\n(2014 thru 24 August)',
    ha='center')

logo = Image.open('../../../htdocs/images/logo_small_white.png')
ax3 = plt.axes([0.12, 0.91, 0.1, 0.1],
               frameon=False,
               axisbg=(0.4471, 0.6235, 0.8117),
               yticks=[],
               xticks=[])
ax3.imshow(logo)

fig.savefig('test.ps')
import iemplot
iemplot.makefeature('test')
コード例 #4
0
vals = []
lats = []
lons = []
icursor.execute("""SELECT id, x(geom) as lon, y(geom) as lat, 
  min(min_tmpf) from summary_2012 s JOIN stations t on (t.iemid = s.iemid)
  WHERE network IN ('IA_ASOS','AWOS') 
  and min_tmpf < 60 and day >= '2012-04-08' and id not in ('CIN', 'TNU')
  GROUP by id, lon, lat ORDER by min DESC""")
for row in icursor:
  vals.append( row[3] )
  lats.append( row[2] )
  lons.append( row[1] )
  print row

cfg = {
 'wkColorMap': 'BlAqGrYeOrRe',
 'nglSpreadColorStart': 2,
 'nglSpreadColorEnd'  : -1,
 '_title'             : "2012 April Minimum Temperature",
 '_valid'             : "April 8th thru 11th",
 '_showvalues'        : True,
 '_format'            : '%.0f',
 'lbTitleString'      : "[F]",
}
# Generates tmp.ps
fp = iemplot.simple_contour(lons, lats, vals, cfg)
#iemplot.postprocess(fp, '','')
import iemplot
iemplot.makefeature(fp)

コード例 #5
0
 "NECLIMATE", "KSCLIMATE", "MOCLIMATE", "KYCLIMATE", "ILCLIMATE", "WICLIMATE",
 "INCLIMATE", "OHCLIMATE", "MICLIMATE"))

ccursor.execute("""
select march.station, march.avg - april.avg as diff from (select station, avg((high+low)/2.0) from alldata WHERE year = 2012 and month = 3 GROUP by station) as march, (select station, avg((high+low)/2.0) from alldata WHERE year = 2012 and month = 4 GROUP by station) as april WHERE march.station = april.station ORDER by diff DESC
""")

vals = []
lats = []
lons = []
for row in ccursor:
    station = row[0]
    if not nt.sts.has_key(station):
        continue
    vals.append( row[1] )
    lats.append( nt.sts[station]['lat'] )
    lons.append( nt.sts[station]['lon'] )
    
cfg = {'_title': "2012 March versus April Average Temperature",
       '_valid': '(preliminary data) Postive values are warmer March than April',
       'lbTitleString': 'F',
#'wkColorMap': 'ViBlGrWhYeOrRe',
'wkColorMap': 'BlWhRe',
 'cnLevelSelectionMode': 'ManualLevels',
  'cnLevelSpacingF'      : 1.0,
 'cnMinLevelValF'       : -8.0,
 'cnMaxLevelValF'       : 8.0,
       '_midwest': True}
tmpfp = iemplot.simple_contour(lons, lats, vals, cfg)
iemplot.makefeature(tmpfp)
コード例 #6
0
ファイル: wx_cycling.py プロジェクト: bthoover/iem
tsigma = np.array(tsigma, "f")
psigma = np.array(psigma, "f")
ax.quiver(
    tsigma[:-1],
    psigma[:-1],
    tsigma[1:] - tsigma[:-1],
    psigma[1:] - psigma[:-1],
    scale_units="xy",
    angles="xy",
    scale=1,
    zorder=1,
    color="tan",
)
for l, t, p, a in zip(lbls, tsigma, psigma, aligns):
    # Manual move label some for readiability
    if l == "7/15":
        t = float(t) + 0.1
        p = float(p) + -0.2
    ax.text(t, p, l, va=a, zorder=2)

ax.set_xlim(-3.5, 3.5)
ax.set_ylabel("Precipitation Departure $\sigma$")
ax.set_xlabel("Temperature Departure $\sigma$")
ax.set_title("26 May 2014 - 8 Sep 2014 Iowa\n 14 Day Trailing Departures plotted every 7 days")
ax.grid(True)

fig.savefig("test.ps")
import iemplot

iemplot.makefeature("test")