当前位置: 首页>>代码示例>>Python>>正文


Python MapPlot.hexbin方法代码示例

本文整理汇总了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
开发者ID:akrherz,项目名称:pyIEM,代码行数:14,代码来源:test_geoplot.py

示例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()
开发者ID:KayneWest,项目名称:iem,代码行数:74,代码来源:plot.py


注:本文中的pyiem.plot.MapPlot.hexbin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。