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


Python MapPlot.fill_ugcs方法代码示例

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


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

示例1: test_drawugcs2

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

示例2: main

# 需要导入模块: from pyiem.plot import MapPlot [as 别名]
# 或者: from pyiem.plot.MapPlot import fill_ugcs [as 别名]
def main():
    """Do Something"""
    pgconn = get_dbconn('postgis')
    df = read_sql("""
        SELECT ugc, count(*) from warnings_2011 where phenomena = 'TO'
        and significance = 'A' and issue < '2011-05-18'
        GROUP by ugc ORDER by count DESC
    """, pgconn, index_col='ugc')
    mp = MapPlot(sector='nws',
                 title=('1 Jan - 17 May 2011 Number of Storm Prediction Center'
                        ' Tornado Watches by County'),
                 subtitle=('count by county, '
                           'based on unofficial archives maintained by the '
                           'IEM'))
    bins = list(range(0, 19, 2))
    bins[0] = 1
    print(df['count'].max())
    cmap = plt.get_cmap('plasma')
    cmap.set_under('white')
    cmap.set_over('black')
    mp.fill_ugcs(df['count'].to_dict(), bins, cmap=cmap)
    mp.postprocess(filename='test.png')
开发者ID:akrherz,项目名称:DEV,代码行数:24,代码来源:ugc_mapper.py

示例3: as

# 需要导入模块: from pyiem.plot import MapPlot [as 别名]
# 或者: from pyiem.plot.MapPlot import fill_ugcs [as 别名]
  GROUP by ugc),
 u as (SELECT ugc, ST_Area(ST_Transform(geom, 2163)) / 1000000. as area
 from ugcs where substr(ugc,3,1) = 'C' and end_ts is null)

 SELECT data.ugc, data.data, data.data / u.area
 from data JOIN u on (u.ugc = data.ugc)
'''

pcursor.execute("""
WITH data as (
SELECT ugc, count(*) / %s  as data from
 (select distinct ugc, generate_series(issue, expire, '1 minute'::interval)
 from warnings where phenomena in %s and significance = 'W'
 and ugc is not null and (expire - issue) < '1440 minutes'::interval
 and issue > %s and issue < %s) as foo2
 GROUP by ugc),

 u as (SELECT ugc, ST_Area(ST_Transform(geom, 2163)) / 1000000. as area
 from ugcs where substr(ugc,3,1) = 'C' and end_ts is null)

 SELECT data.ugc, data.data, data.data / u.area
 from data JOIN u on (u.ugc = data.ugc)
""", (opts['years'], opts['dbcols'], opts['sdate'], opts['edate']))
data = {}
for row in pcursor:
    data[row[0]] = float(row[2 if opts['normalized'] else 1])

m.fill_ugcs(data, bins, cmap=cmap, units=opts['units'])
m.postprocess(filename=fn)
subprocess.call("xv %s" % (fn,), shell=True)
开发者ID:akrherz,项目名称:DEV,代码行数:32,代码来源:county_mapper.py

示例4: ST_x

# 需要导入模块: from pyiem.plot import MapPlot [as 别名]
# 或者: from pyiem.plot.MapPlot import fill_ugcs [as 别名]
 GROUP by ugc_county ORDER by count DESC
""")

data = {}
for row in icursor:
    data[row[0]] = row[1]

# Query out centroids of counties...
pcursor.execute("""
    SELECT ugc, ST_x(ST_centroid(geom)) as lon,
    ST_y(ST_centroid(geom)) as lat
    from ugcs WHERE state = 'IA' and end_ts is null and
    substr(ugc,3,1) = 'C'
    """)
clons = []
clats = []
cvals = []
for row in pcursor:
    cvals.append(data.get(row[0], 0))
    clats.append(row[2])
    clons.append(row[1])


m = MapPlot(axisbg='white', title='Iowa CoCoRaHS Observers Per County',
            subtitle=("Sites with at least one report in past year "
                      "(Sep 2015-2016)"))
m.fill_ugcs(data, [1, 2, 3, 4, 5, 7, 10, 15, 20])
m.plot_values(clons, clats, cvals, labelbuffer=0)
m.drawcounties()
m.postprocess(filename='test.png')
开发者ID:akrherz,项目名称:DEV,代码行数:32,代码来源:cocorahs_county_count.py

示例5: as

# 需要导入模块: from pyiem.plot import MapPlot [as 别名]
# 或者: from pyiem.plot.MapPlot import fill_ugcs [as 别名]
bins = np.arange(0, 25, 1)
norm = mpcolors.BoundaryNorm(bins, cmap.N)


pcursor.execute("""
WITH data as (
    SELECT ugc, issue at time zone tzname as v
    from warnings w JOIN stations t
    ON (w.wfo = (case when length(t.id) = 4 then substr(t.id, 1, 3) else t.id end))
    WHERE t.network = 'WFO' and
    phenomena = 'SV' and significance = 'W' and issue is not null),
    agg as (
    SELECT ugc, extract(hour from v) as hr, count(*) from data
    GROUP by ugc, hr),
    ranks as (
    SELECT ugc, hr, rank() OVER (PARTITION by ugc ORDER by count DESC)
    from agg)

SELECT ugc, hr from ranks where rank = 1
""")
data = {}
for row in pcursor:
    data[row[0]] = float(row[1])

cl = ['Mid', '', '2 AM', '', '4 AM', '', '6 AM', '', '8 AM', '',
      '10 AM', '', 'Noon',
      '', '2 PM', '', '4 PM', '', '6 PM', '', '8 PM', '', '10 PM', '']
m.fill_ugcs(data, bins, cmap=cmap, units='Hour of Day',
            clevstride=2, clevlabels=cl)
m.postprocess(filename='test.png')
开发者ID:akrherz,项目名称:iem,代码行数:32,代码来源:simple_county.py

示例6: test_drawugcs

# 需要导入模块: from pyiem.plot import MapPlot [as 别名]
# 或者: from pyiem.plot.MapPlot import fill_ugcs [as 别名]
def test_drawugcs():
    """test drawing of UGCS"""
    mp = MapPlot(sector='conus', title='Counties, 3 filled in Iowa',
                 nocaption=True)
    mp.fill_ugcs({"IAC001": 10, "IAC003": 20, "IAC005": 30})
    return mp.fig
开发者ID:akrherz,项目名称:pyIEM,代码行数:8,代码来源:test_geoplot.py

示例7: plotter

# 需要导入模块: from pyiem.plot import MapPlot [as 别名]
# 或者: from pyiem.plot.MapPlot import fill_ugcs [as 别名]

#.........这里部分代码省略.........
            max(issue at time zone 'UTC') from """
                + table
                + """
            WHERE substr(ugc, 1, 2) = %s and phenomena = %s
            and significance = %s and issue >= %s and issue < %s
            GROUP by ugc
            """,
                (state, phenomena, significance, sdate, edate),
            )
        rows = []
        data = {}
        for row in cursor:
            rows.append(dict(count=row[1], year=year, ugc=row[0], minissue=row[2], maxissue=row[3]))
            data[row[0]] = row[1]
        title = "Total between %s and %s" % (sdate.strftime("%d %b %Y"), edate.strftime("%d %b %Y"))
        datavar = "count"
    elif varname == "yearavg":
        table = "warnings"
        if t == "cwa":
            cursor.execute(
                """
            select ugc, count(*), min(issue at time zone 'UTC'),
            max(issue at time zone 'UTC') from """
                + table
                + """
            WHERE wfo = %s and phenomena = %s and significance = %s
            and issue >= %s and issue <= %s
            GROUP by ugc
            """,
                (
                    station if len(station) == 3 else station[1:],
                    phenomena,
                    significance,
                    datetime.date(year, 1, 1),
                    datetime.date(year2 + 1, 1, 1),
                ),
            )
        else:
            cursor.execute(
                """
            select ugc, count(*), min(issue at time zone 'UTC'),
            max(issue at time zone 'UTC') from """
                + table
                + """
            WHERE substr(ugc, 1, 2) = %s and phenomena = %s
            and significance = %s and issue >= %s and issue < %s
            GROUP by ugc
            """,
                (state, phenomena, significance, datetime.date(year, 1, 1), datetime.date(year2 + 1, 1, 1)),
            )
        rows = []
        data = {}
        minv = datetime.datetime(2050, 1, 1)
        maxv = datetime.datetime(1986, 1, 1)
        for row in cursor:
            if row[2] < minv:
                minv = row[2]
            if row[3] > maxv:
                maxv = row[3]
            rows.append(dict(count=row[1], year=year, ugc=row[0], minissue=row[2], maxissue=row[3]))
            data[row[0]] = row[1]
        title = ("Yearly Avg: %s and %s") % (minv.strftime("%d %b %Y"), maxv.strftime("%d %b %Y"))
        datavar = "average"

    if len(rows) == 0:
        return "Sorry, no data found for query!"
    df = pd.DataFrame(rows)
    if varname == "yearavg":
        years = maxv.year - minv.year + 1
        df["average"] = df["count"] / years
        for key in data:
            data[key] = round(data[key] / float(years), 2)
        bins = range(0, int(np.max(df[datavar][:])) + 2, 1)
    else:
        bins = range(np.min(df[datavar][:]), np.max(df[datavar][:]) + 2, 1)
    if len(bins) < 3:
        bins.append(bins[-1] + 1)
    if len(bins) > 8:
        bins = np.linspace(np.min(df[datavar][:]), np.max(df[datavar][:]) + 2, 8, dtype="i")
    subtitle = "based on IEM Archives of NWS WWA"
    if t == "cwa":
        subtitle = "Plotted for %s (%s), %s" % (nt.sts[station]["name"], station, subtitle)
    else:
        subtitle = "Plotted for %s, %s" % (state_names[state], subtitle)
    m = MapPlot(
        sector=("state" if t == "state" else "cwa"),
        state=state,
        cwa=(station if len(station) == 3 else station[1:]),
        axisbg="white",
        title=("%s %s %s (%s.%s)")
        % (title, vtec._phenDict[phenomena], vtec._sigDict[significance], phenomena, significance),
        subtitle=subtitle,
        nocaption=True,
    )
    cmap = plt.get_cmap("Paired")
    cmap.set_over("white")
    cmap.set_under("white")
    m.fill_ugcs(data, bins, cmap=cmap, ilabel=ilabel)

    return m.fig, df
开发者ID:raprasad,项目名称:iem,代码行数:104,代码来源:p90.py

示例8: plotter

# 需要导入模块: from pyiem.plot import MapPlot [as 别名]
# 或者: from pyiem.plot.MapPlot import fill_ugcs [as 别名]

#.........这里部分代码省略.........
            and issue >= %s and issue <= %s
            GROUP by ugc
            """, (station if len(station) == 3 else station[1:],
                  phenomena, significance,
                  sdate, edate))
        else:
            cursor.execute("""
            select ugc, count(*), min(issue at time zone 'UTC'),
            max(issue at time zone 'UTC') from """ + table + """
            WHERE substr(ugc, 1, 2) = %s and phenomena = %s
            and significance = %s and issue >= %s and issue < %s
            GROUP by ugc
            """, (state, phenomena, significance,
                  sdate, edate))
        rows = []
        data = {}
        for row in cursor:
            rows.append(dict(count=row[1], year=year,
                             ugc=row[0], minissue=row[2], maxissue=row[3]))
            data[row[0]] = row[1]
        title = "Total between %s and %s" % (sdate.strftime("%d %b %Y"),
                                             edate.strftime("%d %b %Y"))
        datavar = "count"
    elif varname == 'yearavg':
        table = "warnings"
        if t == 'cwa':
            cursor.execute("""
            select ugc, count(*), min(issue at time zone 'UTC'),
            max(issue at time zone 'UTC') from """ + table + """
            WHERE wfo = %s and phenomena = %s and significance = %s
            and issue >= %s and issue <= %s
            GROUP by ugc
            """, (station if len(station) == 3 else station[1:],
                  phenomena, significance,
                  datetime.date(year, 1, 1), datetime.date(year2 + 1, 1, 1)))
        else:
            cursor.execute("""
            select ugc, count(*), min(issue at time zone 'UTC'),
            max(issue at time zone 'UTC') from """ + table + """
            WHERE substr(ugc, 1, 2) = %s and phenomena = %s
            and significance = %s and issue >= %s and issue < %s
            GROUP by ugc
            """, (state, phenomena, significance,
                  datetime.date(year, 1, 1), datetime.date(year2 + 1, 1, 1)))
        rows = []
        data = {}
        minv = datetime.datetime(2050, 1, 1)
        maxv = datetime.datetime(1986, 1, 1)
        for row in cursor:
            if row[2] < minv:
                minv = row[2]
            if row[3] > maxv:
                maxv = row[3]
            rows.append(dict(count=row[1], year=year,
                             ugc=row[0], minissue=row[2], maxissue=row[3]))
            data[row[0]] = row[1]
        title = ("Yearly Avg: %s and %s"
                 ) % (minv.strftime("%d %b %Y"), maxv.strftime("%d %b %Y"))
        datavar = "average"

    if len(rows) == 0:
        return("Sorry, no data found for query!")
    df = pd.DataFrame(rows)
    if varname == 'yearavg':
        years = maxv.year - minv.year + 1
        df['average'] = df['count'] / years
        for key in data:
            data[key] = round(data[key] / float(years), 2)
        bins = range(0, int(np.max(df[datavar][:]))+2, 1)
    else:
        bins = range(np.min(df[datavar][:]), np.max(df[datavar][:])+2, 1)
    if len(bins) < 3:
        bins.append(bins[-1]+1)
    if len(bins) > 8:
        bins = np.linspace(np.min(df[datavar][:]), np.max(df[datavar][:])+2,
                           8, dtype='i')
    subtitle = "based on IEM Archives of NWS WWA"
    if t == 'cwa':
        subtitle = "Plotted for %s (%s), %s" % (nt.sts[station]['name'],
                                                station, subtitle)
    else:
        subtitle = "Plotted for %s, %s" % (state_names[state],
                                           subtitle)
    m = MapPlot(sector=('state' if t == 'state' else 'cwa'),
                state=state,
                cwa=(station if len(station) == 3 else station[1:]),
                axisbg='white',
                title=('%s %s %s (%s.%s)'
                       ) % (title, vtec._phenDict[phenomena],
                            vtec._sigDict[significance],
                            phenomena, significance),
                subtitle=subtitle, nocaption=True,
                titlefontsize=16
                )
    cmap = plt.get_cmap('Paired')
    cmap.set_over('white')
    cmap.set_under('white')
    m.fill_ugcs(data, bins, cmap=cmap, ilabel=ilabel)

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


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