• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python plot.MapPlot类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyiem.plot.MapPlot的典型用法代码示例。如果您正苦于以下问题:Python MapPlot类的具体用法?Python MapPlot怎么用?Python MapPlot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了MapPlot类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: plotter

def plotter(fdict):
    """ Go """
    import matplotlib
    matplotlib.use('agg')
    from pyiem.plot import MapPlot
    utc = datetime.datetime.utcnow()
    bins = [0, 1, 14, 31, 91, 182, 273, 365, 730, 1460, 2920, 3800]
    pgconn = psycopg2.connect(database='postgis', host='iemdb', user='nobody')
    cursor = pgconn.cursor(cursor_factory=psycopg2.extras.DictCursor)

    phenomena = fdict.get('phenomena', 'TO')
    significance = fdict.get('significance', 'W')

    cursor.execute("""
     select wfo,  extract(days from ('TODAY'::date - max(issue))) as m
     from warnings where significance = %s and phenomena = %s
     GROUP by wfo ORDER by m ASC
    """, (significance, phenomena))
    data = {}
    rows = []
    for row in cursor:
        wfo = row[0] if row[0] != 'JSJ' else 'SJU'
        rows.append(dict(wfo=wfo, days=row[1]))
        data[wfo] = max([row[1], 0])
    df = pd.DataFrame(rows)

    m = MapPlot(sector='nws', axisbg='white', nocaption=True,
                title='Days since Last %s %s by NWS Office' % (
                        vtec._phenDict.get(phenomena, phenomena),
                        vtec._sigDict.get(significance, significance)),
                subtitle='Valid %s' % (utc.strftime("%d %b %Y %H%M UTC"),))
    m.fill_cwas(data, bins=bins, ilabel=True, units='Days',
                lblformat='%.0f')

    return m.fig, df
开发者ID:muthulatha,项目名称:iem,代码行数:35,代码来源:p92.py


示例2: draw_map

def draw_map():
    """make maps, not war."""
    m = MapPlot(sector='conus',
                title='4 March 2019 :: DEP Precip Points')
    update_grid(m.ax)
    m.postprocess(filename='/tmp/map_clipoints.png')
    m.close()
开发者ID:akrherz,项目名称:idep,代码行数:7,代码来源:map_clifile_points.py


示例3: main

def main():
    """Map some CLI data"""
    pgconn = get_dbconn('iem')

    df = read_sql("""
    WITH data as (
        SELECT station, snow_jul1 - snow_jul1_normal as s
        from cli_data where valid = '2019-02-18' and snow_jul1 > 0
        and snow_jul1_normal > 0)

    select station, st_x(geom) as lon, st_y(geom) as lat, c.s as val from
    data c JOIN stations s on (s.id = c.station)
    WHERE s.network = 'NWSCLI'
    """, pgconn, index_col=None)
    df['color'] = '#ff0000'
    df.loc[df['val'] > 0, 'color'] = '#0000ff'

    mp = MapPlot(sector='midwest', axisbg='white',
                 title=("2018-2019 Snowfall Total Departure "
                        "from Average [inches]"),
                 subtitle='18 Feb 2019 Based on NWS CLI Reporting Sites')
    mp.plot_values(
        df['lon'].values, df['lat'].values,
        df['val'].values, fmt='%.1f', textsize=12, color=df['color'].values,
        labelbuffer=1)
    mp.postprocess(filename='test.png')
开发者ID:akrherz,项目名称:DEV,代码行数:26,代码来源:map_cli.py


示例4: test_drawugcs2

def test_drawugcs2():
    """3 filled zones"""
    mp = MapPlot(sector='iowa', title='Zones, 3 filled in Iowa, label',
                 subtitle='test_drawugcs2',
                 nocaption=True)
    mp.fill_ugcs({"IAZ001": 10, "IAZ003": 20, "IAZ005": 30}, ilabel=True)
    return mp.fig
开发者ID:akrherz,项目名称:pyIEM,代码行数:7,代码来源:test_geoplot.py


示例5: test_fillstates

def test_fillstates():
    """Can we fill states"""
    data = {'AK': 10, 'HI': 30, 'IA': 40, 'NY': 80}
    mp = MapPlot(sector='nws', title='Fill AK, HI, IA, NY States',
                 subtitle='test_fillstates', nocaption=True)
    mp.fill_states(data, ilabel=True)
    return mp.fig
开发者ID:akrherz,项目名称:pyIEM,代码行数:7,代码来源:test_geoplot.py


示例6: runYear

def runYear(year):
    # Grab the data
    sql = """SELECT station, sum(precip) as total, max(day)
           from alldata_ia WHERE year = %s and
           station != 'IA0000' and
           substr(station,3,1) != 'C' and
           precip is not null GROUP by station""" % (year,)

    lats = []
    lons = []
    vals = []
    labels = []
    ccursor.execute( sql )
    for row in ccursor:
        sid = row['station']
        if not nt.sts.has_key(sid):
            continue
        labels.append( sid[2:] )
        lats.append( nt.sts[sid]['lat'] )
        lons.append( nt.sts[sid]['lon'] )
        vals.append( row['total'] )
        maxday = row['max']

    m = MapPlot(title="Total Precipitation [inch] (%s)" % (year,),
                subtitle='1 January - %s' % (maxday.strftime("%d %B"),),
                axisbg='white')
    m.plot_values(lons, lats, vals, labels=labels, fmt='%.2f',
                  labeltextsize=8, labelcolor='tan')
    pqstr = "plot m %s bogus %s/summary/total_precip.png png" % (
                                        now.strftime("%Y%m%d%H%M"), year,)
    m.postprocess(pqstr=pqstr)
开发者ID:KayneWest,项目名称:iem,代码行数:31,代码来源:yearly_precip.py


示例7: plot

def plot():
    """Do plotting work"""
    cmap1 = plt.get_cmap('inferno_r')
    colors = list(cmap1(np.arange(10) / 10.))
    cmap2 = plt.get_cmap('Pastel1')
    colors.extend(list(cmap2(np.arange(2) / 2.)))
    cmap = ListedColormap(colors)
    
    cmap.set_under('tan')
    cmap.set_over('white')
    minval = np.load('minval.npy')
    maxval = np.load('maxval.npy')
    diff = maxval - minval
    lons = np.load('lons.npy')
    lats = np.load('lats.npy')
    mp = MapPlot(sector='midwest', statebordercolor='white',
                 title=(r"Diff between coldest wind chill and warmest "
                        "air temp 29 Jan - 3 Feb 2019"),
                 subtitle=("based on hourly NCEP Real-Time Mesoscale Analysis "
                           "(RTMA) ending midnight CST"))

    levels = list(range(0, 101, 10))
    levels.extend([105, 110])
    mp.pcolormesh(lons, lats, diff, levels,
                  cmap=cmap, clip_on=False,
                  units=r"$^\circ$F", spacing='proportional')
    mp.postprocess(filename='test.png')
开发者ID:akrherz,项目名称:DEV,代码行数:27,代码来源:rtma_spread.py


示例8: test_contourf

def test_contourf():
    ''' Test the contourf plot with labels specified '''
    mp = MapPlot(sector='iowa', nocaption=True)
    mp.contourf(np.arange(-94, -89), np.arange(40, 45),
                np.arange(5), np.arange(5),
                clevlabels=['a', 'b', 'c', 'd', 'e'])
    return mp.fig
开发者ID:akrherz,项目名称:pyIEM,代码行数:7,代码来源:test_geoplot.py


示例9: test_michigan

def test_michigan():
    """See what we do with Michigan"""
    mp = MapPlot(sector='state', state='MI', nocaption=True)
    mp.contourf(np.arange(-84, -75), np.arange(36, 45), np.arange(9),
                np.arange(9),
                clevlabels=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'])
    return mp.fig
开发者ID:akrherz,项目名称:pyIEM,代码行数:7,代码来源:test_geoplot.py


示例10: main

def main():
    """Go Main"""
    df = get_database_data()
    print(df)
    vals = {}
    labels = {}
    for wfo, row in df.iterrows():
        if wfo == 'JSJ':
            wfo = 'SJU'
        vals[wfo] = row['percent']
        labels[wfo] = '%.0f%%' % (row['percent'], )
        #if row['count'] == 0:
        #    labels[wfo] = '-'

    bins = np.arange(0, 101, 10)    
    #bins = [1, 25, 50, 75, 100, 125, 150, 200, 300]
    #bins = [-50, -25, -10, -5, 0, 5, 10, 25, 50]
    # bins[0] = 1
    #clevlabels = ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW', 'N']
    cmap = plt.get_cmap('PuOr')
    mp = MapPlot(sector='nws', continentalcolor='white', figsize=(12., 9.),
                 title=("2018 Percentage of Time with 1+ Flood Warning Active"),
                 subtitle=('1 January - 30 September 2018, based on IEM archives'))
    mp.fill_cwas(vals, bins=bins, lblformat='%s', labels=labels,
                 cmap=cmap, ilabel=True,  # clevlabels=clevlabels,
                 units='percent')
    
    mp.postprocess(filename='test.png')
开发者ID:akrherz,项目名称:DEV,代码行数:28,代码来源:wfo_mapper.py


示例11: main

def main():
    """Go MAin"""
    df = pd.read_csv('flood_emergencies.csv')
    df2 = df[['source', 'eventid', 'phenomena', 'significance', 'year']
             ].drop_duplicates()
    gdf = df2.groupby('source').count()
    vals = {}
    labels = {}
    for wfo, row in gdf.iterrows():
        if wfo == 'TJSJ':
            wfo = 'SJU'
        else:
            wfo = wfo[1:]
        vals[wfo] = int(row['eventid'])
        labels[wfo] = "%s" % (row['eventid'], )

    bins = list(range(0, 31, 3))
    bins[0] = 1.
    cmap = plt.get_cmap('plasma_r')
    cmap.set_over('black')
    cmap.set_under('white')
    mp = MapPlot(sector='nws', continentalcolor='white', figsize=(12., 9.),
                 title=("2003-2018 Flash Flood Emergency Events"),
                 subtitle=('based on unofficial IEM archives, searching '
                           '"FFS", "FLW", "FFS".'))
    mp.fill_cwas(vals, bins=bins, lblformat='%s', labels=labels,
                 cmap=cmap, ilabel=True,  # clevlabels=month_abbr[1:],
                 units='count')
    mp.postprocess(filename='test.png')
开发者ID:akrherz,项目名称:DEV,代码行数:29,代码来源:wfo_mapper.py


示例12: main

def main():
    """Go Main"""
    pgconn = get_dbconn('postgis')
    df = read_postgis("""
    select geom, issue from bot_warnings where wfo = 'PUB'
    """, pgconn, geom_col='geom', crs={'init': 'epsg:4326', 'no_defs': True})

    bounds = df['geom'].total_bounds
    # bounds = [-102.90293903,   40.08745967,  -97.75622311,   43.35172981]
    bbuf = 0.25
    mp = MapPlot(sector='custom', west=bounds[0] - bbuf,
                 south=bounds[1] - bbuf,
                 east=bounds[2] + bbuf, north=bounds[3] + bbuf,
                 continentalcolor='white',
                 title='Bot Issued Tornado Warnings [2008-2018] for PUB',
                 subtitle='%s warnings plotted' % (len(df.index), ))
    crs_new = ccrs.Mercator()
    crs = ccrs.PlateCarree()
    new_geometries = [crs_new.project_geometry(ii, src_crs=crs)
                      for ii in df['geom'].values]
    mp.draw_cwas()
    mp.ax.add_geometries(new_geometries, crs=crs_new,
                         edgecolor='r', facecolor='None', alpha=1., lw=0.5,
                         zorder=10)
    mp.postprocess(filename='test.png')
开发者ID:akrherz,项目名称:DEV,代码行数:25,代码来源:bot_warning_plot.py


示例13: run

def run(ts, routes):
    """ Run for a given UTC timestamp """
    fn = ts.strftime(("/mesonet/ARCHIVE/data/%Y/%m/%d/model/rtma/%H/"
                      "rtma.t%Hz.awp2p5f000.grib2"))
    if not os.path.isfile(fn):
        print 'wind_power.py missing', fn
        return

    grb = pygrib.open(fn)
    try:
        u = grb.select(name='10 metre U wind component')[0]
        v = grb.select(name='10 metre V wind component')[0]
    except:
        print('Missing u/v wind for wind_power.py\nFN: %s' % (fn,))
        return
    mag = (u['values']**2 + v['values']**2)**.5

    mag = (mag * 1.35)**3 * 0.002641
    # 0.002641

    lats, lons = u.latlons()
    lts = ts.astimezone(pytz.timezone("America/Chicago"))
    pqstr = ("plot %s %s00 midwest/rtma_wind_power.png "
             "midwest/rtma_wind_power_%s00.png png"
             ) % (routes, ts.strftime("%Y%m%d%H"), ts.strftime("%H"))
    m = MapPlot(sector='midwest',
                title=(r'Wind Power Potential :: '
                       '(speed_mps_10m * 1.35)$^3$ * 0.002641'),
                subtitle=('valid: %s based on NOAA Realtime '
                          'Mesoscale Analysis'
                          ) % (lts.strftime("%d %b %Y %I %p")))
    m.pcolormesh(lons, lats, mag, numpy.array(levels), units='MW')

    m.postprocess(pqstr=pqstr)
开发者ID:muthulatha,项目名称:iem,代码行数:34,代码来源:wind_power.py


示例14: run

def run(ts, routes):
    """ Run for a given UTC timestamp """
    fn = ts.strftime("/mesonet/ARCHIVE/data/%Y/%m/%d/model/rtma/%H/rtma.t%Hz.awp2p5f000.grib2")
    if not os.path.isfile(fn):
        print "wind_power.py missing", fn
        return

    grb = pygrib.open(fn)
    u = grb.select(name="10 metre U wind component")[0]
    v = grb.select(name="10 metre V wind component")[0]
    mag = (u["values"] ** 2 + v["values"] ** 2) ** 0.5

    mag = (mag * 1.35) ** 3 * 0.002641
    # 0.002641

    lats, lons = u.latlons()
    lts = ts.astimezone(pytz.timezone("America/Chicago"))
    pqstr = "plot %s %s00 midwest/rtma_wind_power.png midwest/rtma_wind_power_%s00.png png" % (
        routes,
        ts.strftime("%Y%m%d%H"),
        ts.strftime("%H"),
    )
    m = MapPlot(
        sector="midwest",
        title=r"Wind Power Potential :: (speed_mps_10m * 1.35)$^3$ * 0.002641",
        subtitle="valid: %s based on NOAA Realtime Mesoscale Analysis" % (lts.strftime("%d %b %Y %I %p")),
    )
    m.pcolormesh(lons, lats, mag, numpy.array(levels), units="MW")

    m.postprocess(pqstr=pqstr)
开发者ID:bthoover,项目名称:iem,代码行数:30,代码来源:wind_power.py


示例15: test_drawiowawfo

def test_drawiowawfo():
    """Iowa Contour Plot"""
    mp = MapPlot(sector='iowawfo', title='Iowa Contour plot', nocaption=True)
    mp.contourf(np.arange(-94, -85), np.arange(36, 45), np.arange(9),
                np.arange(9),
                clevlabels=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'])
    return mp.fig
开发者ID:akrherz,项目名称:pyIEM,代码行数:7,代码来源:test_geoplot.py


示例16: main

def main():
    """Go Main"""
    pgconn = get_dbconn('postgis')
    df = read_postgis("""
    select geom, issue from sbw where wfo = 'PUB' and phenomena = 'TO'
    and significance = 'W' and status = 'NEW' and issue > '2007-10-01'
    and issue < '2019-01-01'
    """, pgconn, geom_col='geom', crs={'init': 'epsg:4326', 'no_defs': True})

    bounds = df['geom'].total_bounds
    # bounds = [-102.90293903,   40.08745967,  -97.75622311,   43.35172981]
    bbuf = 0.25
    mp = MapPlot(
        sector='custom', west=bounds[0] - bbuf,
        south=bounds[1] - bbuf,
        east=bounds[2] + bbuf, north=bounds[3] + bbuf,
        continentalcolor='white',  # '#b3242c',
        title='NWS Pueblo Issued Tornado Warnings [2008-2018]',
        subtitle='%s warnings plotted' % (len(df.index), ))
    crs_new = ccrs.Mercator()
    crs = ccrs.PlateCarree()
    new_geometries = [crs_new.project_geometry(ii, src_crs=crs)
                      for ii in df['geom'].values]
    # mp.draw_cwas()
    mp.ax.add_geometries(new_geometries, crs=crs_new, lw=0.5,
                         edgecolor='red', facecolor='None', alpha=1,
                         zorder=5)
    mp.drawcounties()
    mp.postprocess(filename='test.png')
开发者ID:akrherz,项目名称:DEV,代码行数:29,代码来源:nws_warning_plot.py


示例17: plot

def plot():
    """Do plotting work"""
    cmap = plt.get_cmap('inferno_r')
    # cmap.set_under('black')
    # cmap.set_over('red')
    minval = (np.load('minval.npy') * units.degK).to(units.degF)
    maxval = (np.load('maxval.npy') * units.degK).to(units.degF)
    diff = maxval - minval
    lons = np.load('lons.npy')
    lats = np.load('lats.npy')
    mp = MapPlot(sector='conus',
                 title=(r"Difference between warmest 3 Oct and coldest 4 "
                        "Oct 2m Temperature"),
                 subtitle=("based on hourly NCEP Real-Time Mesoscale Analysis "
                           "(RTMA) ending midnight CDT"))
    mp.ax.text(0.5, 0.97,
               (r"Pixel Difference Range: %.1f$^\circ$F to %.1f$^\circ$F, "
                r"Domain Analysis Range: %.1f$^\circ$F to %.1f$^\circ$F"
                ) % (np.min(diff).magnitude,
                     np.max(diff).magnitude,
                     np.min(minval).magnitude,
                     np.max(maxval).magnitude),
               transform=mp.ax.transAxes, fontsize=12, ha='center',
               bbox=dict(pad=0, color='white'), zorder=50)
    mp.pcolormesh(lons, lats, diff, range(0, 61, 5),
                  cmap=cmap, clip_on=False,
                  units=r"$^\circ$F")
    mp.postprocess(filename='test.png')
开发者ID:akrherz,项目名称:DEV,代码行数:28,代码来源:rtma_maxmin.py


示例18: main

def main():
    """Go Main Go"""
    cursor = POSTGIS.cursor()
    cursor2 = POSTGIS.cursor()

    phenomena = 'WS'

    cursor.execute("""
    SELECT ugc, issue, init_expire, wfo from warnings where phenomena = %s and
    significance = 'A' and issue > '2005-10-01' ORDER by issue ASC
    """, (phenomena, ))
    total = cursor.rowcount
    print('Events is %s' % (total, ))

    hits = {}
    hits2 = {}
    totals = {}
    misses = 0
    for row in tqdm(cursor, total=total):
        wfo = row[3]
        if wfo not in hits:
            hits[wfo] = {}
        if wfo not in totals:
            totals[wfo] = 0
        totals[wfo] += 1
        cursor2.execute("""
        SELECT distinct phenomena, significance from warnings
        where ugc = %s and expire > %s and issue < %s and wfo = %s
        """, (row[0], row[1], row[2], wfo))
        for row2 in cursor2:
            key = "%s.%s" % (row2[0], row2[1])
            if key not in hits[wfo]:
                hits[wfo][key] = 0
            hits[wfo][key] += 1
            if key not in hits2:
                hits2[key] = 0
            hits2[key] += 1
        if cursor2.rowcount == 0:
            misses += 1

    data = {}
    for wfo in hits:
        data[wfo] = hits[wfo].get(
                    '%s.W' % (phenomena,), 0) / float(totals[wfo]) * 100.0

    mp = MapPlot(sector='nws', axisbg='white',
                 title=("Conversion [%] of Winter Storm Watch "
                        "Counties/Parishes into Winter Storm Warnings"),
                 titlefontsize=14,
                 subtitle=('1 Oct 2005 - 29 Mar 2018, Overall %s/%s %.1f%%'
                           ) % (hits2['%s.W' % (phenomena, )], total,
                                hits2['%s.W' % (phenomena, )] / float(total) * 100.))
    mp.fill_cwas(data, ilabel=True, lblformat='%.0f')
    mp.postprocess(filename='test.png')

    print('Misses %s %.1f%%' % (misses, misses / float(total) * 100.0))
    for key in hits2:
        print('%s %s %.1f%%' % (key, hits2[key],
                                hits2[key] / float(total) * 100.0))
开发者ID:akrherz,项目名称:DEV,代码行数:59,代码来源:watch_into_warnings.py


示例19: test_drawcities

def test_drawcities():
    """Draw Cities"""
    mp = MapPlot(title='Fill and Draw Cities',
                 subtitle="This is my subtitle",
                 continentalcolor='blue',
                 sector='iowa', nocaption=True)
    mp.drawcities()
    return mp.fig
开发者ID:akrherz,项目名称:pyIEM,代码行数:8,代码来源:test_geoplot.py


示例20: test_scatter

def test_scatter():
    """ Test scatter plots """
    mp = MapPlot(sector='midwest', title='Should see 100 dots',
                 subtitle='test_scatter', nocaption=True)
    mp.scatter(np.linspace(-99, -94, 100),
               np.linspace(40, 45, 100), np.arange(100),
               np.arange(0, 101, 10))
    return mp.fig
开发者ID:akrherz,项目名称:pyIEM,代码行数:8,代码来源:test_geoplot.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.get_autoplot_context函数代码示例发布时间:2022-05-25
下一篇:
Python vtec.vtecparser函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap