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


Python MapPlot.postprocess方法代码示例

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


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

示例1: run

# 需要导入模块: from pyiem.plot import MapPlot [as 别名]
# 或者: from pyiem.plot.MapPlot import postprocess [as 别名]
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,代码行数:36,代码来源:wind_power.py

示例2: run

# 需要导入模块: from pyiem.plot import MapPlot [as 别名]
# 或者: from pyiem.plot.MapPlot import postprocess [as 别名]
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,代码行数:32,代码来源:wind_power.py

示例3: compute

# 需要导入模块: from pyiem.plot import MapPlot [as 别名]
# 或者: from pyiem.plot.MapPlot import postprocess [as 别名]
def compute(valid):
    ''' Get me files '''
    prob = None
    for hr in range(-15,0):
        ts = valid + datetime.timedelta(hours=hr)
        fn = ts.strftime("hrrr.ref.%Y%m%d%H00.grib2")
        if not os.path.isfile(fn):
            continue

        grbs = pygrib.open(fn)
        gs = grbs.select(level=1000,forecastTime=(-1 * hr * 60))
        ref = generic_filter(gs[0]['values'], np.max, size=10)
        if prob is None:
            lats, lons = gs[0].latlons()
            prob = np.zeros( np.shape(ref) )
        
        prob = np.where(ref > 29, prob+1, prob)

    prob = np.ma.array(prob / 15. * 100.)
    prob.mask = np.ma.where(prob < 1, True, False)    
    
    m = MapPlot(sector='iowa',
                title='HRRR Composite Forecast 4 PM 20 May 2014 30+ dbZ Reflectivity',
                subtitle='frequency of previous 15 model runs all valid at %s, ~15km smoothed' % (valid.astimezone(pytz.timezone("America/Chicago")).strftime("%-d %b %Y %I:%M %p %Z"),))

    m.pcolormesh(lons, lats, prob, np.arange(0,101,10), units='%',
                     clip_on=False)
    m.map.drawcounties()
    m.postprocess(filename='test.ps')
    m.close()
开发者ID:KayneWest,项目名称:iem,代码行数:32,代码来源:ref_probability.py

示例4: main

# 需要导入模块: from pyiem.plot import MapPlot [as 别名]
# 或者: from pyiem.plot.MapPlot import postprocess [as 别名]
def main():
    """Do Something"""
    cursor = IEM.cursor()
    data = []
    cursor.execute("""SELECT ST_x(geom), ST_y(geom), tsf0, tsf1, tsf2, tsf3,
    id, rwis_subf from current c JOIN stations t on (t.iemid = c.iemid)
    WHERE c.valid > now() - '1 hour'::interval""")
    for row in cursor:
        val = cln(row[2:6])
        if val is None:
            continue
        d = dict(lat=row[1], lon=row[0], tmpf=val, id=row[6])
        if row[7] is not None and not np.isnan(row[7]):
            d['dwpf'] = row[7]
        data.append(d)

    now = datetime.datetime.now()
    m = MapPlot(axisbg='white',
                title='Iowa RWIS Average Pavement + Sub-Surface Temperature',
                subtitle=("Valid: %s (pavement in red, sub-surface in blue)"
                          "") % (now.strftime("%-d %b %Y %-I:%M %p"),))
    m.plot_station(data)
    m.drawcounties()
    pqstr = ("plot c %s rwis_sf.png rwis_sf.png png"
             "") % (datetime.datetime.utcnow().strftime("%Y%m%d%H%M"), )
    m.postprocess(view=False, pqstr=pqstr)
开发者ID:KayneWest,项目名称:iem,代码行数:28,代码来源:plot_rwis_sf.py

示例5: main

# 需要导入模块: from pyiem.plot import MapPlot [as 别名]
# 或者: from pyiem.plot.MapPlot import postprocess [as 别名]
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,代码行数:27,代码来源:bot_warning_plot.py

示例6: draw_map

# 需要导入模块: from pyiem.plot import MapPlot [as 别名]
# 或者: from pyiem.plot.MapPlot import postprocess [as 别名]
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,代码行数:9,代码来源:map_clifile_points.py

示例7: plot

# 需要导入模块: from pyiem.plot import MapPlot [as 别名]
# 或者: from pyiem.plot.MapPlot import postprocess [as 别名]
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,代码行数:30,代码来源:rtma_maxmin.py

示例8: main

# 需要导入模块: from pyiem.plot import MapPlot [as 别名]
# 或者: from pyiem.plot.MapPlot import postprocess [as 别名]
def main():
    """Go Main"""
    grbs = pygrib.open('ds.snow.bin')
    # skip 1-off first field
    total = None
    lats = lons = None
    for grb in grbs[1:]:
        if lats is None:
            lats, lons = grb.latlons()
            total = grb['values']
            continue
        total += grb['values']
    # TODO tz-hack here
    analtime = grb.analDate - datetime.timedelta(hours=5)

    mp = MapPlot(
        sector='custom', west=-100, east=-92, north=45, south=41,
        axisbg='tan',
        title=("NWS Forecasted Accumulated Snowfall "
               "thru 7 PM 12 April 2019"),
        subtitle='NDFD Forecast Issued %s' % (
            analtime.strftime("%-I %p %-d %B %Y"), )
    )
    cmap = nwssnow()
    cmap.set_bad('tan')
    mp.pcolormesh(
        lons, lats, total * 39.3701,
        [0.01, 1, 2, 3, 4, 6, 8, 12, 18, 24, 30, 36],
        cmap=cmap,
        units='inch')

    mp.drawcounties()
    mp.drawcities()
    mp.postprocess(filename='test.png')
    mp.close()
开发者ID:akrherz,项目名称:DEV,代码行数:37,代码来源:plot_ndfd.py

示例9: main

# 需要导入模块: from pyiem.plot import MapPlot [as 别名]
# 或者: from pyiem.plot.MapPlot import postprocess [as 别名]
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,代码行数:31,代码来源:nws_warning_plot.py

示例10: do_month

# 需要导入模块: from pyiem.plot import MapPlot [as 别名]
# 或者: from pyiem.plot.MapPlot import postprocess [as 别名]
def do_month(year, month, routes):
    """ Generate a MRMS plot for the month!"""

    sts = datetime.datetime(year,month,1)
    ets = sts + datetime.timedelta(days=35)
    ets = ets.replace(day=1)

    today = datetime.datetime.now()
    if ets > today:
        ets = today

    idx0 = iemre.daily_offset(sts)
    idx1 = iemre.daily_offset(ets)

    nc = netCDF4.Dataset("/mesonet/data/iemre/%s_mw_mrms_daily.nc" % (year,),
                          'r')

    lats = nc.variables['lat'][:]
    lons = nc.variables['lon'][:]
    p01d = np.sum(nc.variables['p01d'][idx0:idx1,:,:],0) / 24.5
    nc.close()

    m = MapPlot(sector='iowa', title='MRMS %s - %s Total Precipitation' % (
            sts.strftime("%-d %b"), 
            (ets - datetime.timedelta(days=1)).strftime("%-d %b %Y")),
            subtitle='Data from NOAA MRMS Project')
    x,y = np.meshgrid(lons, lats)
    bins = [0.01, 0.1, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 7, 8, 12, 16, 20]
    m.pcolormesh(x, y, p01d, bins, units='inches')
    m.drawcounties()
    currentfn = "summary/iowa_mrms_q3_month.png"
    archivefn = sts.strftime("%Y/%m/summary/iowa_mrms_q3_month.png")
    pqstr = "plot %s %s00 %s %s png" % (
                routes, sts.strftime("%Y%m%d%H"), currentfn, archivefn)
    m.postprocess(pqstr=pqstr)
开发者ID:KayneWest,项目名称:iem,代码行数:37,代码来源:mrms_monthly_plot.py

示例11: run

# 需要导入模块: from pyiem.plot import MapPlot [as 别名]
# 或者: from pyiem.plot.MapPlot import postprocess [as 别名]
def run(base, ceil, now, fn):
    """ Generate the plot """
    # Compute normal from the climate database
    sql = """SELECT station,
       sum(gddxx(%s, %s, high, low)) as gdd
       from alldata_ia WHERE year = %s and month in (5,6,7,8,9,10)
       and station != 'IA0000' and substr(station,2,1) != 'C'
       GROUP by station""" % (base, ceil, now.year)

    lats = []
    lons = []
    gdd50 = []
    ccursor.execute(sql)
    for row in ccursor:
        if row[0] not in nt.sts:
            continue
        lats.append(nt.sts[row[0]]['lat'])
        lons.append(nt.sts[row[0]]['lon'])
        gdd50.append(float(row[1]))

    m = MapPlot(title=("Iowa 1 May - %s GDD Accumulation"
                       ) % (now.strftime("%-d %B %Y"), ),
                subtitle="base %s" % (base,))
    bins = np.linspace(min(gdd50)-1, max(gdd50)+1, num=10, dtype=np.int)
    m.contourf(lons, lats, gdd50, bins)
    m.drawcounties()

    pqstr = "plot c 000000000000 summary/%s.png bogus png" % (fn,)
    m.postprocess(pqstr=pqstr)
开发者ID:KayneWest,项目名称:iem,代码行数:31,代码来源:plot_gdd.py

示例12: main

# 需要导入模块: from pyiem.plot import MapPlot [as 别名]
# 或者: from pyiem.plot.MapPlot import postprocess [as 别名]
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,代码行数:30,代码来源:wfo_mapper.py

示例13: main

# 需要导入模块: from pyiem.plot import MapPlot [as 别名]
# 或者: from pyiem.plot.MapPlot import postprocess [as 别名]
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,代码行数:28,代码来源:map_cli.py

示例14: main

# 需要导入模块: from pyiem.plot import MapPlot [as 别名]
# 或者: from pyiem.plot.MapPlot import postprocess [as 别名]
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,代码行数:31,代码来源:wfo_mapper.py

示例15: plot

# 需要导入模块: from pyiem.plot import MapPlot [as 别名]
# 或者: from pyiem.plot.MapPlot import postprocess [as 别名]
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,代码行数:29,代码来源:rtma_spread.py


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