Exemplo n.º 1
0
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)
Exemplo n.º 2
0
def main():
    """Go Main Go"""
    now = datetime.datetime.now()
    pgconn = get_dbconn("iem", user="******")
    icursor = pgconn.cursor(cursor_factory=psycopg2.extras.DictCursor)

    # Compute normal from the climate database
    sql = """
    SELECT
      s.id, tmpf, dwpf, sknt, drct,  ST_x(s.geom) as lon, ST_y(s.geom) as lat
    FROM
      current c, stations s
    WHERE
      s.network IN ('IA_RWIS') and c.iemid = s.iemid and
      valid + '20 minutes'::interval > now() and
      tmpf > -50 and dwpf > -50
    """

    data = []
    icursor.execute(sql)
    for row in icursor:
        data.append(row)

    mp = MapPlot(
        axisbg="white",
        title="Iowa DOT RWIS Mesoplot",
        subtitle="plot valid %s" % (now.strftime("%-d %b %Y %H:%M %P"),),
    )
    mp.plot_station(data)
    mp.drawcounties(color="#EEEEEE")
    pqstr = "plot c 000000000000 iowa_rwis.png bogus png"
    mp.postprocess(pqstr=pqstr)
    mp.close()
Exemplo n.º 3
0
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()
    mp = 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"),))
    mp.plot_station(data)
    mp.drawcounties()
    pqstr = ("plot c %s rwis_sf.png rwis_sf.png png"
             "") % (datetime.datetime.utcnow().strftime("%Y%m%d%H%M"), )
    mp.postprocess(view=False, pqstr=pqstr)
Exemplo n.º 4
0
def test_stationplot():
    """Testing the plotting of wind barbs"""
    mp = MapPlot(continentalcolor='white', nocaption=True)
    data = [
        dict(lat=41.5, lon=-96, tmpf=50, dwpf=30, id='BOOI4'),
        dict(lat=42.0, lon=-95.5, tmpf=50, dwpf=30, id='CSAI4'),
    ]
    mp.plot_station(data, fontsize=12)
    return mp.fig
Exemplo n.º 5
0
def plot_hilo(valid):
    """ Go Main Go

    Args:
      valid (datetime): The timestamp we are interested in!
    """
    pgconn = get_dbconn("iem", user="******")
    cursor = pgconn.cursor()

    cursor.execute(
        """SELECT max_tmpf, min_tmpf, id, st_x(geom), st_y(geom)
    from summary s JOIN stations t on
    (t.iemid = s.iemid) WHERE s.day = %s
    and t.network in ('IA_COOP', 'NE_COOP', 'MO_COOP', 'IL_COOP', 'WI_COOP',
    'MN_COOP')
    and max_tmpf is not null and max_tmpf >= -30 and
    min_tmpf is not null and min_tmpf < 99 and
    extract(hour from coop_valid) between 5 and 10""",
        (valid.date(),),
    )
    data = []
    for row in cursor:
        data.append(
            dict(lat=row[4], lon=row[3], tmpf=row[0], dwpf=row[1], id=row[2])
        )

    mp = MapPlot(
        title=(r"%s NWS COOP 24 Hour High/Low Temperature [$^\circ$F]")
        % (valid.strftime("%-d %b %Y"),),
        subtitle="Reports valid between 6 and 9 AM",
        axisbg="white",
        figsize=(10.24, 7.68),
    )
    mp.plot_station(data)
    mp.drawcounties()

    pqstr = "plot ac %s0000 coopHighLow.gif coopHighLow.gif gif" % (
        valid.strftime("%Y%m%d"),
    )

    mp.postprocess(pqstr=pqstr)
    mp.close()

    pgconn.close()
Exemplo n.º 6
0
def main():
    """Go Main Go"""
    today = datetime.date.today()
    now = today.replace(year=2000)
    nt = NetworkTable("IACLIMATE")
    nt.sts["IA0200"]["lon"] = -93.6
    nt.sts["IA5992"]["lat"] = 41.65
    coop = get_dbconn("coop", user="******")

    obs = []
    cursor = coop.cursor()
    cursor.execute(
        "SELECT station, max_high, min_low from climate WHERE valid = %s "
        "and substr(station,0,3) = 'IA'",
        (now,),
    )
    for row in cursor:
        sid = row[0]
        if sid[2] == "C" or sid[2:] == "0000" or sid not in nt.sts:
            continue
        obs.append(
            dict(
                id=sid[2:],
                lat=nt.sts[sid]["lat"],
                lon=nt.sts[sid]["lon"],
                tmpf=row[1],
                dwpf=row[2],
            )
        )

    mp = MapPlot(
        title=("Record High + Low Temperature [F] (1893-%s)") % (today.year,),
        subtitle="For Date: %s" % (now.strftime("%d %b"),),
        continentalcolor="white",
    )
    mp.drawcounties()
    mp.plot_station(obs)
    pqstr = (
        "plot ac %s0000 climate/iowa_today_rec_hilo_pt.png "
        "coop_rec_temp.png png"
    ) % (today.strftime("%Y%m%d"),)
    mp.postprocess(view=False, pqstr=pqstr)
    mp.close()
Exemplo n.º 7
0
def main():
    """Go Main Go"""
    now = datetime.datetime.now() - datetime.timedelta(days=int(sys.argv[1]))
    pgconn = get_dbconn("iem", user="******")
    icursor = pgconn.cursor()

    # Compute normal from the climate database
    sql = """
    SELECT
      s.id as station, max_tmpf, min_tmpf,
      ST_x(s.geom) as lon, ST_y(s.geom) as lat
    FROM
      summary_%s c, stations s
    WHERE
      c.iemid = s.iemid and
      s.network IN ('AWOS', 'IA_ASOS') and
      day = '%s'
      and max_tmpf > -50
    """ % (
        now.year,
        now.strftime("%Y-%m-%d"),
    )

    data = []
    icursor.execute(sql)
    for row in icursor:
        data.append(
            dict(lat=row[4], lon=row[3], tmpf=row[1], dwpf=row[2], id=row[0]))

    mp = MapPlot(
        title="Iowa High & Low Air Temperature",
        axisbg="white",
        subtitle=now.strftime("%d %b %Y"),
    )
    mp.plot_station(data)
    mp.drawcounties()
    if sys.argv[1] == "0":
        pqstr = "plot c 000000000000 summary/asos_hilo.png bogus png"
    else:
        pqstr = "plot a %s0000 bogus hilow.gif png" % (
            now.strftime("%Y%m%d"), )
    mp.postprocess(view=False, pqstr=pqstr)
    mp.close()
Exemplo n.º 8
0
def main():
    """Go Main Go"""
    now = datetime.datetime.now()
    nt = NetworkTable("IACLIMATE")
    nt.sts["IA0200"]["lon"] = -93.6
    nt.sts["IA5992"]["lat"] = 41.65
    coop = get_dbconn("coop", user="******")

    # Compute normal from the climate database
    sql = """
        SELECT station, high, low from climate WHERE valid = '2000-%s'
        and substr(station,0,3) = 'IA'
    """ % (now.strftime("%m-%d"), )

    obs = []
    cursor = coop.cursor(cursor_factory=psycopg2.extras.DictCursor)
    cursor.execute(sql)
    for row in cursor:
        sid = row["station"]
        if sid[2] == "C" or sid[2:] == "0000" or sid not in nt.sts:
            continue
        obs.append(
            dict(
                id=sid[2:],
                lat=nt.sts[sid]["lat"],
                lon=nt.sts[sid]["lon"],
                tmpf=row["high"],
                dwpf=row["low"],
            ))

    mp = MapPlot(
        title=("Average High + Low Temperature [F] (1893-%s)") % (now.year, ),
        subtitle="For Date: %s" % (now.strftime("%d %b"), ),
        axisbg="white",
    )
    mp.drawcounties()
    mp.plot_station(obs)
    pqstr = ("plot ac %s0000 climate/iowa_today_avg_hilo_pt.png "
             "coop_avg_temp.png png") % (now.strftime("%Y%m%d"), )
    mp.postprocess(view=False, pqstr=pqstr)
    mp.close()
Exemplo n.º 9
0
def main():
    """Go Main Go"""
    now = datetime.datetime.now()
    nt = NetworkTable('IACLIMATE')
    nt.sts["IA0200"]["lon"] = -93.6
    nt.sts["IA5992"]["lat"] = 41.65
    coop = get_dbconn('coop', user='******')

    # Compute normal from the climate database
    sql = """
        SELECT station, max_high, min_low from climate WHERE valid = '2000-%s'
        and substr(station,0,3) = 'IA'
    """ % (now.strftime("%m-%d"), )

    obs = []
    cursor = coop.cursor()
    cursor.execute(sql)
    for row in cursor:
        sid = row[0]
        if sid[2] == 'C' or sid[2:] == '0000' or sid not in nt.sts:
            continue
        obs.append(
            dict(id=sid[2:],
                 lat=nt.sts[sid]['lat'],
                 lon=nt.sts[sid]['lon'],
                 tmpf=row[1],
                 dwpf=row[2]))

    mp = MapPlot(title=("Record High + Low Temperature [F] (1893-%s)") %
                 (now.year, ),
                 subtitle="For Date: %s" % (now.strftime("%d %b"), ),
                 continentalcolor='white')
    mp.drawcounties()
    mp.plot_station(obs)
    pqstr = ("plot ac %s0000 climate/iowa_today_rec_hilo_pt.png "
             "coop_rec_temp.png png") % (now.strftime("%Y%m%d"), )
    mp.postprocess(view=False, pqstr=pqstr)
    mp.close()
Exemplo n.º 10
0
def plot_hilo(valid):
    """ Go Main Go

    Args:
      valid (datetime): The timestamp we are interested in!
    """
    pgconn = psycopg2.connect(database='iem', host='iemdb', user='******')
    cursor = pgconn.cursor()

    cursor.execute("""SELECT max_tmpf, min_tmpf, id, st_x(geom), st_y(geom)
    from summary s JOIN stations t on
    (t.iemid = s.iemid) WHERE s.day = %s
    and t.network in ('IA_COOP', 'NE_COOP', 'MO_COOP', 'IL_COOP', 'WI_COOP',
    'MN_COOP')
    and max_tmpf is not null and max_tmpf >= -30 and
    min_tmpf is not null and min_tmpf < 99 and
    extract(hour from coop_valid) between 5 and 10""", (valid.date(),))
    data = []
    for row in cursor:
        data.append(dict(lat=row[4], lon=row[3], tmpf=row[0],
                         dwpf=row[1], id=row[2]))

    m = MapPlot(title=('%s NWS COOP 24 Hour High/Low Temperature [$^\circ$F]'
                       ) % (valid.strftime("%-d %b %Y"),),
                subtitle='Reports valid between 6 and 9 AM',
                axisbg='white', figsize=(10.24, 7.68))
    m.plot_station(data)
    m.drawcounties()

    pqstr = "plot ac %s0000 coopHighLow.gif coopHighLow.gif gif" % (
                                                    valid.strftime("%Y%m%d"),)

    m.postprocess(pqstr=pqstr)
    m.close()

    pgconn.close()
Exemplo n.º 11
0
nt = NetworkTable('IACLIMATE')
nt.sts["IA0200"]["lon"] = -93.6
nt.sts["IA5992"]["lat"] = 41.65
import psycopg2.extras
coop = psycopg2.connect(database='coop', host='iemdb', user='******')

# Compute normal from the climate database
sql = """SELECT station, high, low from climate WHERE valid = '2000-%s'
    and substr(station,0,3) = 'IA'""" % (now.strftime("%m-%d"),)

obs = []
c = coop.cursor(cursor_factory=psycopg2.extras.DictCursor)
c.execute(sql)
for row in c:
    sid = row['station']
    if sid[2] == 'C' or sid[2:] == '0000' or sid not in nt.sts:
        continue
    obs.append(dict(id=sid[2:], lat=nt.sts[sid]['lat'],
                    lon=nt.sts[sid]['lon'], tmpf=row['high'],
                    dwpf=row['low']))

m = MapPlot(title="Average High + Low Temperature [F] (1893-%s)" % (now.year,),
            subtitle="For Date: %s" % (now.strftime("%d %b"),),
            axisbg='white')
m.drawcounties()
m.plot_station(obs)
pqstr = ("plot ac %s0000 climate/iowa_today_avg_hilo_pt.png "
         "coop_avg_temp.png png") % (now.strftime("%Y%m%d"), )
m.postprocess(view=False, pqstr=pqstr)
m.close()
Exemplo n.º 12
0
from pyiem.datatypes import direction, speed
import pyiem.meteorology as meteorology
IEM = psycopg2.connect(database='iem', host='iemdb', user='******')
icursor = IEM.cursor(cursor_factory=psycopg2.extras.DictCursor)

# Compute normal from the climate database
sql = """
SELECT 
  s.id, tmpf, dwpf, sknt, drct,  ST_x(s.geom) as lon, ST_y(s.geom) as lat
FROM 
  current c, stations s 
WHERE
  s.network IN ('IA_RWIS') and c.iemid = s.iemid and 
  valid + '20 minutes'::interval > now() and
  tmpf > -50 and dwpf > -50
"""

data = []
icursor.execute(sql)
for row in icursor:
    data.append(row)

m = MapPlot(axisbg='white',
            title='Iowa DOT RWIS Mesoplot',
            subtitle='plot valid %s' % (now.strftime("%-d %b %Y %H:%M %P"), ))
m.plot_station(data)
m.drawcounties(color='#EEEEEE')
pqstr = "plot c 000000000000 iowa_rwis.png bogus png"
m.postprocess(pqstr=pqstr)
m.close()