return chr(234); } if ($sknt < 45) { return chr(235); } if ($sknt < 50) { return chr(236); } if ($sknt < 55) { return chr(237); } if ($sknt < 60) { return chr(238); } } $iem = new IEMAccess(); $sts = array(); if (isset($st)) { foreach ($st as $key => $value) { if (strlen($value) > 0 && $value != "ahack") { $o = $iem->getSingleSite($value); $sts[$value] = $o; } } } if (strlen($network) > 0) { $sts = $iem->getNetwork($network); } $varDef = array("tmpf" => "Temperatures", "tsf0" => "Pavement Temp #1", "tsf1" => "Pavement Temp #2", "tsf2" => "Pavement Temp #3", "tsf3" => "Pavement Temp #4", "dwpf" => "Dew Points", "vsby" => "Visibility", "sknt" => "Wind [knots]", "alti" => "Altimeter", "pres" => "Pressure", "barb" => "Wind Barbs", "max_tmpf" => "Maximum Temperature", "max_dwpf" => "Maximum Dew Point", "min_tmpf" => "Minimum Temperature", "gust" => "Peak Wind Gust [knots]", "relh" => "Relative Humidity", "phour" => "Hourly Rainfall", "pday" => "Today Rainfall", "pmonth" => "Rainfall This Month", "snow" => "Today Snowfall", "snowd" => "Today Snow Depth", "snoww" => "Snow Water Equivalent", "max_sknt" => "Peak Gust Today [knots]", "max_gust" => "Peak Gust Today [knots]", "feel" => "Feels Like"); $rnd = array("alti" => 2, "phour" => 2, "vsby" => 1, "tmpf" => 0, "dwpf" => 0, "pday" => 2, "pmonth" => 2, "pres" => 2, "snoww" => 2); $lats = array();
*/ include "../../config/settings.inc.php"; include "../../include/mlib.php"; include "../../include/network.php"; $nt = new NetworkTable("AWOS"); $cities = $nt->table; function fancy($v, $floor, $ceil, $p) { if ($v < $floor || $v > $ceil) { return ""; } return sprintf("%{$p}.1f", $v); } include "../../include/iemaccess.php"; include "../../include/iemaccessob.php"; $iem = new IEMAccess(); $mydata = $iem->getNetwork("AWOS"); $rwis = fopen('/tmp/wxc_ia_awos.txt', 'w'); fwrite($rwis, "Weather Central 001d0300 Surface Data\n 13\n 5 Station\n 52 CityName\n 2 State\n 7 Lat\n 8 Lon\n 2 Day\n 4 Hour\n 5 AirTemp\n 5 AirDewp\n 4 Wind Direction Degrees\n 4 Wind Direction Text\n 4 Wind Speed\n 5 Today Precipitation\n"); $now = time(); while (list($key, $val) = each($mydata)) { $tdiff = $now - $val->db["ts"]; if ($tdiff > 3600) { continue; } if ($val->db['pday'] < 0) { $val->db['pday'] = 0; } $s = sprintf("%5s %52s %2s %7s %8s %2s %4s %5s %5s %4s %4s %4s %5s\n", $key, $cities[$key]['name'], 'IA', round($cities[$key]['lat'], 2), round($cities[$key]['lon'], 2), date('d', $val->db['ts'] + 6 * 3600), date('H', $val->db['ts'] + 6 * 3600), $val->db['tmpf'], $val->db['dwpf'], $val->db['drct'], drct2txt($val->db['drct']), $val->db['sknt'], $val->db['pday']); fwrite($rwis, $s); }
$rs = pg_prepare($pgconn, "SELECT", "SELECT * from current_shef\n \t\t\twhere station = \$1 ORDER by physical_code ASC"); $rs = pg_execute($pgconn, "SELECT", array($station)); $table .= "<table class=\"table table-striped\">\n\t\t\t<thead><tr><th>Physical Code</th><th>Duration</th><th>Extremum</th>\n\t\t\t<th>Valid</th><th>Value</th></thead>"; for ($i = 0; $row = @pg_fetch_assoc($rs, $i); $i++) { $ts = strtotime($row["valid"]); $depth = ""; if ($row["depth"] > 0) { $depth = sprintf("%d inch", $row["depth"]); } $table .= sprintf("<tr><td>[%s] %s %s</td><td>[%s] %s</td><td>[%s] %s</td><td>%s</td><td>%s</td></tr>", $row["physical_code"], $shefcodes[$row["physical_code"]], $depth, $row["duration"], $durationcodes[$row["duration"]], $row["extremum"] == 'Z' ? '-' : $row['extremum'], $extremumcodes[$row["extremum"]], date('d M Y g:i A', $ts), $row["value"]); } $table .= "</table>"; } else { include "../../include/iemaccess.php"; include "../../include/iemaccessob.php"; $iem = new IEMAccess($metadata["tzname"]); $iemob = $iem->getSingleSite($station); $rs = $iemob->db; $vardict = array("lvalid" => "Observation Time", "tmpf" => "Air Temp [F]", "max_tmpf" => "Maximum Air Temperature [F]", "min_tmpf" => "Minimum Air Temperature [F]", "dwpf" => "Dew Point [F]", "relh" => "Relative Humidity [%]", "drct" => "Wind Direction", "sknt" => "Wind Speed [knots]", "srad" => "Solar Radiation", "alti" => "Altimeter [inches]", "pday" => "Daily Precipitation [inches]", "pmonth" => "Monthly Precipitation [inches]", "gust" => "Wind Gust [knots]", "raw" => "Raw Observation/Product"); $table = "<table class=\"table table-striped\">"; foreach ($vardict as $key => $value) { if (array_key_exists($key, $rs) && $rs[$key] != "" && $rs[$key] != -99) { if ($key == "lvalid") { $t2 = date("d M Y, g:i A", strtotime($rs[$key])); $table .= '<tr><td><b>' . $value . '</b></td><td>' . $t2 . '</td></tr>'; } else { $table .= '<tr><td><b>' . $value . '</b></td><td>' . $rs[$key] . '</td></tr>'; } // End if } // End if
echo 'Title: KELO WeatherNet Refresh: 1 Color: 200 200 255 IconFile: 1, 18, 32, 2, 31, "http://www.tornadocentral.com/grlevel3/windbarbs.png" IconFile: 2, 15, 15, 8, 8, "http://www.tornadocentral.com/grlevel3/cloudcover.png" Font: 1, 11, 1, "Courier New" '; include "../../../config/settings.inc.php"; include "{$rootpath}/include/iemaccess.php"; include "{$rootpath}/include/iemaccessob.php"; include "{$rootpath}/include/mlib.php"; include "{$rootpath}/include/network.php"; $nt = new NetworkTable("KELO"); $cities = $nt->table; $iem = new IEMAccess(); $snet = $iem->getNetwork("KELO"); function s2icon($s) { if ($s < 2.5) { return "1,21"; } if ($s < 5) { return "1,1"; } if ($s < 10) { return "1,2"; } if ($s < 15) { return "1,3"; }
<?php include "../../../../config/settings.inc.php"; // mesoplot/plot.php // - Replace GEMPAK mesoplots!!! include_once "../../../../include/iemmap.php"; include "../../../../include/mlib.php"; include "../../../../include/iemaccess.php"; include "../../../../include/iemaccessob.php"; include "../../../../include/network.php"; $network = isset($_GET['network']) ? $_GET['network'] : 'KCCI'; $nt = new NetworkTable($network); $Scities = $nt->table; $titles = array("KCCI" => "KCCI SchoolNet8", "KELO" => "KELO WeatherNet", "KIMT" => "KIMT StormNet"); $iem = new IEMAccess(); $data = $iem->getNetwork($network); function skntChar($sknt) { if ($sknt < 2) { return chr(0); } if ($sknt < 5) { return chr(227); } if ($sknt < 10) { return chr(228); } if ($sknt < 15) { return chr(229); } if ($sknt < 20) {
define("IEM_APPID", 40); $sortcol = isset($_GET["sortcol"]) ? $_GET["sortcol"] : "peak"; $metar = isset($_GET["metar"]) ? $_GET['metar'] : "no"; $sorder = isset($_GET["sorder"]) ? $_GET["sorder"] : "desc"; $wfo = isset($_REQUEST["wfo"]) ? $_REQUEST["wfo"] : 'DMX'; $t->refresh = "<meta http-equiv=\"refresh\" content=\"60;\">"; $t->title = "Obs by NWS Forecast Office"; $t->thispage = "current-sort"; include "../../include/mlib.php"; include "../../include/network.php"; $nt = new NetworkTable("WFO"); include "../../include/forms.php"; include "../../include/station.php"; include "../../include/iemaccess.php"; include "../../include/iemaccessob.php"; $iem = new IEMAccess(); $asos = $iem->getWFO($wfo); $vals = array("tmpf" => "Air Temperature [F]", "dwpf" => "Dew Point Temp [F]", "sknt" => "Wind Speed [knots]", "drct" => "Wind Direction [deg]", "alti" => "Altimeter [mb]", "peak" => "Today's Wind Gust [knots]", "peak_ts" => "Time of Peak Gust", "relh" => "Relative Humidity", "feel" => "Feels Like [F]", "vsby" => "Visibility [miles]", "ts" => "Observation Time", "phour" => "Last Hour Rainfall [inch]", "min_tmpf" => "Today's Low Temperature", "max_tmpf" => "Today's High Temperature", "pday" => "Today Rainfall [inch]"); $t->current_network = "By NWS WFO"; $wselect = "<select name=\"wfo\">"; while (list($key, $value) = each($nt->table)) { $wselect .= "<option value=\"{$key}\" "; if ($wfo == $key) { $wselect .= "SELECTED"; } $wselect .= ">[" . $key . "] " . $nt->table[$key]["name"] . "\n"; } $wselect .= "</select>"; function aSortBySecondIndex($multiArray, $secondIndex) { global $sorder;
include "../../config/settings.inc.php"; function dwp($tmpf, $relh) { if ($relh == 0) { return ""; } $tmpk = 273.15 + 5.0 / 9.0 * ($tmpf - 32.0); $dwpk = $tmpk / (1 + 0.000425 * $tmpk * -log10($relh / 100.0)); return round(($dwpk - 273.15) * 9.0 / 5.0 + 32, 0); } include "../../include/mlib.php"; include "../../include/iemaccess.php"; include "../../include/iemaccessob.php"; $station = isset($_GET["station"]) ? substr($_GET["station"], 0, 5) : 'SSAS2'; $iemdb = new IEMAccess(); $myOb = $iemdb->getSingleSite($station); //print_r($myOb); $tmpf = $myOb->db["tmpf"]; $relh = $myOb->db["relh"]; $alti = $myOb->db["alti"]; $pday = $myOb->db["pday"]; $drct = drct2txt($myOb->db["drct"]); $gust = round($myOb->db["max_gust"] * 1.15, 0); $sped = round($myOb->db["sknt"] * 1.15, 0); $feel = feels_like($tmpf, $relh, $sped); $time = "Valid: " . date("d M Y h:i a", $myOb->db["ts"]); $dwpf = $myOb->db["dwpf"]; $gustDir = drct2txt($myOb->db["max_drct"]); $maxTemp = $myOb->db["max_tmpf"]; $minTemp = $myOb->db["min_tmpf"];
<?php /* * Generates a Weather Central formatted station datafile with the IEM * processed SHEF (COOP) data included. Why? This dataset is difficult * to process and I'd like to think I do a great job at it :) */ include '../../config/settings.inc.php'; include '../../include/network.php'; $nt = new NetworkTable("IA_COOP"); $cities = $nt->table; $coop = fopen('/tmp/wxc_coop.txt', 'w'); fwrite($coop, "Weather Central 001d0300 Surface Data\n 12\n 5 Station\n 52 CityName\n 2 State\n 7 Lat\n 9 Lon\n 2 Day\n 2 Hour\n 4 24hr High Temp\n 4 24hr Low Temp\n 6 Precipitation\n 6 Snowfall\n 6 Snowfall Depth\n"); include '../../include/iemaccess.php'; include '../../include/iemaccessob.php'; $iem = new IEMAccess(); $net = $iem->getNetwork("IA_COOP"); $now = time(); while (list($key, $iemob) = each($net)) { if ((double) $iemob->db["max_tmpf"] < -50) { $iemob->db["max_tmpf"] = " "; } if ((double) $iemob->db["min_tmpf"] > 90) { $iemob->db["min_tmpf"] = " "; } if ((double) $iemob->db["min_tmpf"] < -90) { $iemob->db["min_tmpf"] = " "; } if ((double) $iemob->db["snow"] < 0) { $iemob->db["snow"] = " "; }
$pgconn = iemdb("access"); $rad = isset($_GET['rad']) ? $_GET['rad'] : 'DMX'; $tv = isset($_GET['rad']) ? strtoupper(substr($_GET['tv'], 0, 4)) : 'KCCI'; $station = isset($_GET['station']) ? $_GET['station'] : ''; $sortcol = isset($_GET['sortcol']) ? $_GET['sortcol'] : 'p15m'; $rs = pg_prepare($pgconn, "SELECT", "SELECT * from events WHERE network = \$1\n\tand valid > (now() - '15 minutes'::interval)"); $t->refresh = "<meta http-equiv=\"refresh\" content=\"60\">"; $t->title = "SchoolNet - Where's it raining?"; $t->thispage = "networks-schoolnet"; $ar = array("KCCI" => "KCCI-TV Des Moines", "KELO" => "KELO-TV Sioux Falls", "KIMT" => "KIMT-TV Mason City"); $tvselect = make_select("tv", $tv, $ar); $ar = array("ABR" => "[ABR] Aberdeen, SD", "ARX" => "[ARX] LaCrosse, WI", "DMX" => "[DMX] Des Moines, IA", "DMXA" => "[DMX] Des Moines, IA (North)", "DMXB" => "[DMX] Des Moines, IA (Central)", "DMXC" => "[DMX] Des Moines, IA (South)", "DVN" => "[DVN] Davenport, IA", "EAX" => "[EAX] Pleasant Hill, MO", "FSD" => "[FSD] Sioux Falls, SD", "MPX" => "[MPX] Minneapolis, MN", "OAX" => "[OAX] Omaha, NE", "UDX" => "[UDX] Rapid City, SD"); $radselect = make_select("rad", $rad, $ar); $nt = new NetworkTable($tv); $stbl = $nt->table; $iemdb = new IEMAccess(); $iemdata = $iemdb->getNetwork($tv); $data = array(); while (list($key, $iemob) = each($iemdata)) { $data[$key] = $iemob->db; $data[$key]["p15m"] = 0; } $rs = pg_execute($pgconn, "SELECT", array($tv)); for ($i = 0; $row = @pg_fetch_array($rs, $i); $i++) { $data[$row["station"]]["p15m"] = $row["magnitude"]; } function mktitle($map, $imgObj, $titlet) { $layer = $map->getLayerByName("credits"); // point feature with text for location $point = ms_newpointobj();
echo 'Title: KIMT StormNet Refresh: 1 Color: 200 200 255 IconFile: 1, 18, 32, 2, 31, "http://www.tornadocentral.com/grlevel3/windbarbs.png" IconFile: 2, 15, 15, 8, 8, "http://www.tornadocentral.com/grlevel3/cloudcover.png" Font: 1, 11, 1, "Courier New" '; include "../../../config/settings.inc.php"; include "{$rootpath}/include/iemaccess.php"; include "{$rootpath}/include/iemaccessob.php"; include "{$rootpath}/include/mlib.php"; include "{$rootpath}/include/network.php"; $nt = new NetworkTable("KIMT"); $cities = $nt->table; $iem = new IEMAccess(); $snet = $iem->getNetwork("KIMT"); function s2icon($s) { if ($s < 2.5) { return "1,21"; } if ($s < 5) { return "1,1"; } if ($s < 10) { return "1,2"; } if ($s < 15) { return "1,3"; }
<?php /* * Dumps IA and IL CoCoRaHS data to a Weather Central formatted file */ include "../../config/settings.inc.php"; include "../../include/mlib.php"; include "../../include/network.php"; $nt = new NetworkTable(array("IACOCORAHS", "ILCOCORAHS")); include "../../include/iemaccess.php"; include "../../include/iemaccessob.php"; $iem = new IEMAccess(); $rwis = fopen('/tmp/wxc_cocorahs.txt', 'w'); fwrite($rwis, sprintf("Weather Central 001d0300 Surface Data timestamp=%s\n 10\n 12 Station\n 52 CityName\n 2 State\n 7 Lat\n 8 Lon\n 2 Day\n 4 Hour\n 6 Precip Total\n 6 Snow Total\n 6 Snow Depth\n", date("Y.m.d.H.I"))); $states = array("IA", "IL"); reset($states); $now = time(); while (list($k, $state) = each($states)) { $mydata = $iem->getNetwork("{$state}COCORAHS"); while (list($key, $val) = each($mydata)) { $tdiff = $now - $val->db["ts"]; if ($tdiff > 86400) { continue; } if ($val->db['pday'] < 0) { $val->db["pday"] = " "; } if ($val->db['pday'] == 0.0001) { $val->db["pday"] = "T"; } if ($val->db['snowd'] < 0) {
<?php /* Generate a JSON file of network observations */ header("Content-type: application/vnd.geo+json"); require_once 'Zend/Json.php'; include "../../config/settings.inc.php"; include "../../include/database.inc.php"; include "../../include/iemaccess.php"; include "../../include/iemaccessob.php"; include "../../include/network.php"; include "../../include/mlib.php"; $network = isset($_REQUEST["network"]) ? $_REQUEST["network"] : "IA_ASOS"; $callback = isset($_REQUEST["callback"]) ? $_REQUEST["callback"] : null; $iem = new IEMAccess(); $asos = $iem->getNetwork($network); $nt = new NetworkTable($network); $cities = $nt->table; $mydata = array(); while (list($key, $iemob) = each($asos)) { $mydata[$key] = $iemob->db; unset($mydata[$key]['geom']); unset($mydata[$key]['max_sknt_ts']); unset($mydata[$key]['max_gust_ts']); unset($mydata[$key]['day']); $mydata[$key]["valid"] = gmstrftime('%Y-%m-%dT%H:%MZ', $iemob->ts); $mydata[$key]["sname"] = $cities[$key]["name"]; $mydata[$key]["lat"] = $cities[$key]["lat"]; $mydata[$key]["lon"] = $cities[$key]["lon"]; $mydata[$key]["sped"] = $mydata[$key]["sknt"] * 1.15078; $mydata[$key]["relh"] = relh(f2c($mydata[$key]["tmpf"]), f2c($mydata[$key]["dwpf"])); $mydata[$key]["feel"] = feels_like($mydata[$key]["tmpf"], $mydata[$key]["relh"], $mydata[$key]["sped"]);
echo 'Title: Iowa AWOS Only Refresh: 5 Color: 200 200 255 IconFile: 1, 18, 32, 2, 31, "http://www.tornadocentral.com/grlevel3/windbarbs.png" IconFile: 2, 15, 15, 8, 8, "http://www.tornadocentral.com/grlevel3/cloudcover.png" Font: 1, 11, 1, "Courier New" '; include "../../../config/settings.inc.php"; include "{$rootpath}/include/iemaccess.php"; include "{$rootpath}/include/iemaccessob.php"; include "{$rootpath}/include/mlib.php"; include "{$rootpath}/include/network.php"; $nt = new NetworkTable("AWOS"); $cities = $nt->table; $iem = new IEMAccess(); function s2icon($s) { if ($s < 2.5) { return "1,21"; } if ($s < 5) { return "1,1"; } if ($s < 10) { return "1,2"; } if ($s < 15) { return "1,3"; } if ($s < 20) {
Refresh: 5 Color: 200 200 255 IconFile: 1, 18, 32, 2, 31, "http://www.tornadocentral.com/grlevel3/windbarbs.png" IconFile: 2, 15, 15, 8, 8, "http://www.tornadocentral.com/grlevel3/cloudcover.png" IconFile: 3, 25, 25, 12, 12, "http://mesonet.agron.iastate.edu/request/grx/rwis_cr.png" Font: 1, 11, 1, "Courier New" '; include "../../../config/settings.inc.php"; include "{$rootpath}/include/iemaccess.php"; include "{$rootpath}/include/iemaccessob.php"; include "{$rootpath}/include/mlib.php"; include "{$rootpath}/include/network.php"; $nt = new NetworkTable("IA_RWIS"); $cities = $nt->table; $iem = new IEMAccess(); $snet = $iem->getNetwork("IA_RWIS"); function pcolor($tmpf) { if ($tmpf == "M") { return "1"; } if ($tmpf >= 35) { return "2"; } if ($tmpf >= 34) { return "3"; } if ($tmpf >= 33) { return "4"; }
// Inspiration: http://grlevel3.tornadocentral.com/metars.php?state=IA echo 'Title: KCCI SchoolNet8 Refresh: 1 Color: 200 200 255 IconFile: 1, 18, 32, 2, 31, "http://www.tornadocentral.com/grlevel3/windbarbs.png" IconFile: 2, 15, 15, 8, 8, "http://www.tornadocentral.com/grlevel3/cloudcover.png" Font: 1, 11, 1, "Courier New" '; include "../../../config/settings.inc.php"; include "../../../include/iemaccess.php"; include "../../../include/iemaccessob.php"; include "../../../include/mlib.php"; include "../../../include/network.php"; $nt = new NetworkTable("KCCI"); $iem = new IEMAccess(); $snet = $iem->getNetwork("KCCI"); function s2icon($s) { if ($s < 2.5) { return "1,21"; } if ($s < 5) { return "1,1"; } if ($s < 10) { return "1,2"; } if ($s < 15) { return "1,3"; }
include "../../config/settings.inc.php"; include "../../include/mlib.php"; include "../../include/network.php"; $nt = new NetworkTable("IA_RWIS"); $cities = $nt->table; function fancy($v, $floor, $ceil, $p) { if ($v < $floor || $v > $ceil) { return ""; } return sprintf("%{$p}.1f", $v); } include "../../include/iemaccess.php"; include "../../include/iemaccessob.php"; $iem = new IEMAccess(); /* Lets also get the traffic data, please */ $rs = pg_query($iem->dbconn, "select l.nwsli, t.* from rwis_traffic t, \n\trwis_locations l where l.id = t.location_id and lane_id < 4"); $traffic = array(); for ($i = 0; $row = @pg_fetch_array($rs, $i); $i++) { if (!array_key_exists($row["nwsli"], $traffic)) { $traffic[$row["nwsli"]] = array("avgspeed0" => "M", "avgspeed1" => "M", "avgspeed2" => "M", "avgspeed3" => "M"); } $traffic[$row["nwsli"]][sprintf("avgspeed%s", $row["lane_id"])] = round($row["avg_speed"], 0); } $tstamp = gmdate("Y-m-d\\TH:i:s"); $mydata = $iem->getNetwork("IA_RWIS"); $rwis = fopen('/tmp/wxc_iadot.txt', 'w'); fwrite($rwis, "Weather Central 001d0300 Surface Data TimeStamp={$tstamp}\n 22\n 5 Station\n 52 CityName\n 2 State\n 7 Lat\n 8 Lon\n 2 Day\n 4 Hour\n 5 AirTemp\n 5 AirDewp\n 4 Wind Direction Degrees\n 4 Wind Direction Text\n 4 Wind Speed\n 4 SubSurface Temp\n 4 P1 Temp\n 4 P2 Temp\n 4 P3 Temp\n 4 P4 Temp\n 4 Pave Ave Temp\n 3 Sensor 0 Average Speed\n 3 Sensor 1 Average Speed\n 3 Sensor 2 Average Speed\n 3 Sensor 3 Average Speed\n"); $now = time(); while (list($key, $val) = each($mydata)) {