本文整理汇总了Python中pyiem.plot.MapPlot.hexbin方法的典型用法代码示例。如果您正苦于以下问题:Python MapPlot.hexbin方法的具体用法?Python MapPlot.hexbin怎么用?Python MapPlot.hexbin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyiem.plot.MapPlot
的用法示例。
在下文中一共展示了MapPlot.hexbin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_hexbin
# 需要导入模块: from pyiem.plot import MapPlot [as 别名]
# 或者: from pyiem.plot.MapPlot import hexbin [as 别名]
def test_hexbin():
"""See if we can do hexbin OKish"""
mp = MapPlot(sector='north_america', continentalcolor='white',
nocaption=True)
lons = np.arange(-100, -80, 0.25)
lats = np.arange(40, 50, 0.25)
vals = np.linspace(0, 1, lats.shape[0] * lons.shape[0]
).reshape([lats.shape[0], lons.shape[0]])
lons, lats = np.meshgrid(lons, lats)
mp.hexbin(lons.flatten(), lats.flatten(), vals.flatten(),
np.arange(0, 1, 0.1), cmap='jet')
return mp.fig
示例2: makeplot
# 需要导入模块: from pyiem.plot import MapPlot [as 别名]
# 或者: from pyiem.plot.MapPlot import hexbin [as 别名]
def makeplot(ts, routes='ac'):
"""
Generate two plots for a given time GMT
"""
sql = """
SELECT ST_x(geom), ST_y(geom),
CASE WHEN sm is Null THEN -1 ELSE sm END,
CASE WHEN od is Null THEN -1 ELSE od END from
(SELECT grid_idx, avg(soil_moisture) as sm,
avg(optical_depth) as od
from data WHERE valid > '%s+00'::timestamptz - '6 hours'::interval
and valid < '%s+00'::timestamptz + '6 hours'::interval
GROUP by grid_idx) as foo, grid
WHERE foo.grid_idx = grid.idx
""" % (ts.strftime('%Y-%m-%d %H:%M'),
ts.strftime('%Y-%m-%d %H:%M'))
#sql = """
#SELECT x(geom), y(geom), random(), random() from grid
#"""
scursor.execute( sql )
lats = []
lons = []
sm = []
od = []
for row in scursor:
lats.append( float(row[1]) )
lons.append( float(row[0]) )
sm.append( row[2] * 100.)
od.append( row[3] )
if len(lats) == 0:
#print 'Did not find SMOS data for ts: %s' % (ts,)
return
lats = np.array( lats )
lons = np.array( lons )
sm = np.array( sm )
od = np.array( od )
for sector in ['midwest', 'iowa']:
clevs = np.arange(0,71,5)
m = MapPlot(sector=sector,
title = 'SMOS Satellite: Soil Moisture (0-5cm)',
subtitle="Satelite passes around %s UTC" % (
ts.strftime("%d %B %Y %H"),))
if sector == 'iowa':
m.drawcounties()
cmap = cm.get_cmap('jet_r')
cmap.set_under('#EEEEEE')
cmap.set_over("k")
m.hexbin(lons,lats,sm,clevs,units='%', cmap=cmap)
pqstr = "plot %s %s00 smos_%s_sm%s.png smos_%s_sm%s.png png" % (
routes, ts.strftime("%Y%m%d%H"), sector, ts.strftime("%H"),
sector, ts.strftime("%H"))
m.postprocess(pqstr=pqstr)
m.close()
for sector in ['midwest', 'iowa']:
clevs = np.arange(0,1.001,0.05)
m = MapPlot(sector=sector,
title = 'SMOS Satellite: Land Cover Optical Depth (microwave L-band)',
subtitle="Satelite passes around %s UTC" % (
ts.strftime("%d %B %Y %H"),))
if sector == 'iowa':
m.drawcounties()
cmap = cm.get_cmap('jet')
cmap.set_under('#EEEEEE')
cmap.set_over("k")
m.hexbin(lons,lats,od,clevs, cmap=cmap)
pqstr = "plot %s %s00 smos_%s_od%s.png smos_%s_od%s.png png" % (
routes, ts.strftime("%Y%m%d%H"), sector, ts.strftime("%H"),
sector, ts.strftime("%H"))
m.postprocess(pqstr=pqstr)
m.close()