function get_iemprop($propname) { $dbconn = iemdb("mesosite"); $rs = pg_prepare($dbconn, "SELECT321" . $propname, "SELECT * from properties where\n propname = \$1"); $rs = pg_execute($dbconn, "SELECT321" . $propname, array($propname)); if (pg_num_rows($rs) < 1) { return null; } $row = pg_fetch_array($rs, 0); return $row["propvalue"]; }
function neighbors($station, $lat, $lon) { $con = iemdb("mesosite"); $rs = pg_prepare($con, "_SELECT", "SELECT *,\n ST_distance(ST_transform(geom,3857), \n ST_transform(ST_GeomFromEWKT('SRID=4326;POINT(" . $lon . " " . $lat . ")'), 3857)) /1000.0 as dist from stations \n WHERE ST_point_inside_circle(geom, " . $lon . ", " . $lat . ", 0.25) \n and id != \$1 ORDER by dist ASC"); $result = pg_execute($con, "_SELECT", array($station)); $s = "<table class=\"table table-striped\">\n <thead><tr><th>Distance [km]</th><th>Network</th><th>Station Name</th></tr></thead>"; for ($i = 0; $row = @pg_fetch_assoc($result, $i); $i++) { $s .= sprintf("<tr><td>%.3f</td><td><a href=\"locate.php?network=%s\">%s</a></td><td><a href=\"site.php?station=%s&network=%s\">%s</a></td></tr>", $row["dist"], $row["network"], $row["network"], $row["id"], $row["network"], $row["name"]); } $s .= "</table>"; return $s; }
function get_data2() { global $phenomena, $significance; $dbconn = iemdb("postgis"); $rs = pg_query("\n\t\tWITH data as (\n\t\t\tSELECT distinct wfo, eventid, extract(year from issue) as yr\n\t\t\tfrom warnings where phenomena = '{$phenomena}' and\n\t\t\tsignificance = '{$significance}'\n\t\t)\n\t\tSELECT wfo, yr, count(*) from data GROUP by wfo, yr\n\t"); $data = array(); for ($i = 0; $row = @pg_fetch_assoc($rs, $i); $i++) { $yr = $row["yr"]; if (!array_key_exists($yr, $data)) { $data[$yr] = array(); } $data[$yr][$row["wfo"]] = $row["count"]; } return $data; }
function NetworkTable($a) { $this->table = array(); $this->dbconn = iemdb("mesosite", PGSQL_CONNECT_FORCE_NEW); $rs = pg_prepare($this->dbconn, "SELECT", "SELECT *, ST_x(geom) as lon, \n \tST_y(geom) as lat from stations WHERE network = \$1 ORDER by name ASC"); $rs = pg_prepare($this->dbconn, "SELECTST", "SELECT *, ST_x(geom) as lon, \n \tST_y(geom) as lat from stations WHERE id = \$1"); if (is_string($a)) { $this->load_network($a); } else { if (is_array($a)) { foreach ($a as $network) { $this->load_network($network); } } } }
function StationData($a, $n = "") { $this->table = array(); $this->dbconn = iemdb("mesosite"); $rs = pg_prepare($this->dbconn, "SELECT ST1", "SELECT *, " . "ST_x(geom) as lon, ST_y(geom) as lat from stations " . "WHERE id = \$1 and network = \$2"); $rs = pg_prepare($this->dbconn, "SELECT ST2", "SELECT *, " . "ST_x(geom) as lon, ST_y(geom) as lat from stations " . "WHERE id = \$1"); if (is_string($a)) { $this->load_station($a, $n); } else { if (is_array($a)) { foreach ($a as $id) { $this->load_station($id, $n); } } } }
function download_data($sts, $ets) { $dbconn = iemdb('other'); $rs = pg_prepare($dbconn, "SELECT", "SELECT * from asi_data WHERE\n\t\t\tvalid >= \$1 and valid < \$2 ORDER by valid ASC"); $rs = pg_execute($dbconn, "SELECT", array(date("Y-m-d", $sts), date("Y-m-d", $ets))); header("Content-type: text/plain"); echo "station,valid,"; for ($i = 1; $i < 13; $i++) { echo sprintf("ch%savg,ch%ssd,ch%smax,ch%smin,", $i, $i, $i, $i); } echo "\n"; for ($i = 0; $row = @pg_fetch_assoc($rs, $i); $i++) { echo sprintf("%s,%s,", $row['station'], $row['valid']); for ($j = 1; $j < 13; $j++) { echo sprintf("%s,%s,%s,%s,", $row["ch{$j}avg"], $row["ch{$j}sd"], $row["ch{$j}max"], $row["ch{$j}min"]); } echo "\n"; } }
function selectNetwork($selected, $extra = array()) { $selected = strtoupper($selected); include_once dirname(__FILE__) . "/database.inc.php"; $dbconn = iemdb('mesosite'); $rs = pg_exec($dbconn, "SELECT * from networks ORDER by name ASC"); $s = "<select name=\"network\">\n"; reset($extra); while (list($idx, $sid) = each($extra)) { $s .= "<option value=\"{$idx}\" "; if ($selected == $idx) { $s .= "SELECTED"; } $s .= ">{$sid}</option>\n"; } for ($i = 0; $row = @pg_fetch_array($rs, $i); $i++) { $s .= "<option value=\"" . $row["id"] . "\" "; if ($row["id"] == $selected) { $s .= "SELECTED"; } $s .= ">" . $row["name"] . "</option>\n"; } return $s; }
define("IEM_APPID", 156); include_once "../../include/myview.php"; include_once "../../include/database.inc.php"; include_once "../../include/forms.php"; include_once "../../include/imagemaps.php"; include_once "../../include/network.php"; $nt = new NetworkTable("NWSCLI"); $station = isset($_GET["station"]) ? $_GET["station"] : 'KDSM'; $year = isset($_GET["year"]) ? intval($_GET["year"]) : date("Y"); $month = isset($_GET["month"]) ? intval($_GET["month"]) : null; $day = isset($_GET["day"]) ? intval($_GET["day"]) : null; $opt = isset($_GET["opt"]) ? $_GET["opt"] : "bystation"; $ys = yearSelect(2009, $year, "year"); $ms = monthSelect($month, "month"); $ds = daySelect($day, "day"); $pgconn = iemdb("iem"); $byday = false; if ($opt === "bystation") { $title = sprintf("Station: %s for Year: %s", $station, $year); $col1label = "Date"; $rs = pg_prepare($pgconn, "SELECT", "SELECT *,\n\t\t\tarray_to_string(high_record_years, ' ') as hry,\n\t\t\tarray_to_string(low_record_years, ' ') as lry,\n\t\t\tarray_to_string(precip_record_years, ' ') as pry,\n\t\t\tarray_to_string(snow_record_years, ' ') as sry\n\t\t\tfrom cli_data where\n\t\t\tstation = \$1 and valid BETWEEN \$2 and \$3 ORDER by valid ASC"); $rs = pg_execute($pgconn, "SELECT", array($station, "{$year}-01-01", "{$year}-12-31")); } else { $col1label = "Station"; $byday = true; $day = mktime(0, 0, 0, $month, $day, $year); $title = sprintf("All Stations for Date: %s", date("d F Y", $day)); $rs = pg_prepare($pgconn, "SELECT", "SELECT *,\n\t\t\tarray_to_string(high_record_years, ' ') as hry,\n\t\t\tarray_to_string(low_record_years, ' ') as lry,\n\t\t\tarray_to_string(precip_record_years, ' ') as pry,\n\t\t\tarray_to_string(snow_record_years, ' ') as sry\n\t\t\tfrom cli_data where\n\t\t\tvalid = \$1 ORDER by station ASC"); $rs = pg_execute($pgconn, "SELECT", array(date("Y-m-d", $day))); } $table = <<<EOF
$var = sqrt($sum / (count($std) - 1)); return round($var, 2); } $station = isset($_GET["station"]) ? $_GET['station'] : 'IA0200'; /* Setup start/end dates */ $smonth = isset($_GET['smonth']) ? $_GET['smonth'] : 5; $sday = isset($_GET['sday']) ? $_GET['sday'] : 1; $emonth = isset($_GET['emonth']) ? $_GET['emonth'] : 5; $eday = isset($_GET['eday']) ? $_GET['eday'] : 31; $sts = mktime(0, 0, 0, $smonth, $sday, 2000); $ets = mktime(0, 0, 0, $emonth, $eday, 2000); $stsSQL = date("Y-m-d", $sts); $etsSQL = date("Y-m-d", $ets); $subtitle = sprintf("Between %s and %s", date('M d', $sts), date('M d', $ets)); /* Query out the average accumulations during that time */ $coop = iemdb("coop"); pg_prepare($coop, "SELECTOR", "select year, round(sum(precip)::numeric,2) as rain from alldata_ia\n WHERE extract(doy from day) BETWEEN extract(doy from '{$stsSQL}'::date) and \n extract(doy from '{$etsSQL}'::date) and station = \$1 and \n year < extract(year from now()) GROUP by year ORDER by rain ASC"); $rs = pg_execute($coop, "SELECTOR", array($station)); /* Generate plot */ $rowcount = pg_numrows($rs); $data = array(); $rdata = array(); for ($i = 0; $row = @pg_fetch_array($rs, $i); $i++) { if ($i == 0) { $lowVal = $row["rain"]; $lowYear = $row["year"]; } if ($i == $rowcount - 1) { $hiVal = $row["rain"]; $hiYear = $row["year"]; }
<?php header("Content-type: text/plain"); echo 'Title: SchoolNet Where is it raining? Refresh: 1 Color: 200 200 255 Font: 1, 11, 1, "Courier New" '; include "../../../config/settings.inc.php"; include "../../../include/database.inc.php"; include "../../../include/mlib.php"; include "../../../include/network.php"; $nt = new NetworkTable(array("KCCI", "KIMT", "KELO")); $pgconn = iemdb("access"); $rs = pg_query($pgconn, "select * from events WHERE \n\t\tvalid > now() - '5 minutes'::interval and event = 'P+' "); for ($i = 0; $row = @pg_fetch_array($rs, $i); $i++) { $lat = $nt->table[$row["station"]]["lat"]; $lon = $nt->table[$row["station"]]["lon"]; $hover = sprintf("Name: %s\\n15 minute:%s IN", $nt->table[$row["station"]]["name"], $row["magnitude"]); echo "Object: " . $lat . "," . $lon . "\n Text: 0, 0, 1, \"" . $row["magnitude"] . "\", \"{$hover}\"\n End: \n\n"; }
<?php putenv("TZ=GMT"); include "../../config/settings.inc.php"; include "../../include/database.inc.php"; $mos = iemdb("mos"); pg_exec($mos, "SET TIME ZONE 'GMT'"); $year1 = isset($_GET["year1"]) ? $_GET["year1"] : date("Y", time() + 86400); $year2 = isset($_GET["year2"]) ? $_GET["year2"] : date("Y", time() + 86400); $month1 = isset($_GET["month1"]) ? $_GET["month1"] : date("m", time() + 86400); $month2 = isset($_GET["month2"]) ? $_GET["month2"] : date("m", time() + 86400); $day1 = isset($_GET["day1"]) ? $_GET["day1"] : date("d", time() + 86400); $day2 = isset($_GET["day2"]) ? $_GET["day2"] : date("d", time() + 86400); $hour1 = isset($_GET["hour1"]) ? $_GET["hour1"] : 0; $hour2 = isset($_GET["hour2"]) ? $_GET["hour2"] : 12; $model = isset($_GET["model"]) ? $_GET["model"] : "GFS"; $station = isset($_GET["station"]) ? strtoupper($_GET["station"]) : "KAMW"; $sts = mktime($hour1, 0, 0, $month1, $day1, $year1); $ets = mktime($hour2, 0, 0, $month2, $day2, $year2); $table = "alldata"; if ($year1 == $year2) { $table = sprintf("t%s", $year1); } $rs = pg_prepare($mos, "SELECTOR", "select *, t06_1 ||'/'||t06_2 as t06, \n t12_1 ||'/'|| t12_2 as t12 from {$table} WHERE station = \$1\n and runtime >= \$2 and runtime <= \$3 and \n (model = \$4 or model = \$5)\n ORDER by runtime,ftime ASC"); if ($model == "NAM") { $model2 = "ETA"; } if ($model == "GFS") { $model2 = "AVN"; } $rs = pg_execute($mos, "SELECTOR", array($station, date("Y-m-d H:i", $sts), date("Y-m-d H:i", $ets), $model, $model2));
$snet->set("status", MS_ON); $iards = $map->getlayerbyname("iards"); $iards->set("status", MS_ON); $bar640t = $map->getlayerbyname("bar640t"); $bar640t->set("status", MS_ON); $ponly = $map->getlayerbyname("pointonly"); $ponly->set("status", MS_ON); $states = $map->getlayerbyname("states"); $states->set("status", MS_ON); $img = $map->prepareImage(); $counties->draw($img); $states->draw($img); $iards->draw($img); $bar640t->draw($img); $c = iemdb("isuag"); $climatedb = iemdb("coop"); $sstr = strftime("%Y-%m-%d", $gs_start); $estr = strftime("%Y-%m-%d", $gs_end); $cStart = "2000" . strftime("-%m-%d", $gs_start); $cEnd = "2000" . strftime("-%m-%d", $gs_end); $sstr_txt = strftime("%b %d", $gs_start); $estr_txt = strftime("%b %d", $gs_end); function gdd($high, $low, $ceiling, $floor) { if ($low < $floor) { $low = $floor; } if ($high > $ceiling) { $high = $ceiling; } if ($high < $floor) {
<?php include "../../config/settings.inc.php"; include "../../include/database.inc.php"; $con = iemdb("postgis"); $sql = "SELECT max(valid) as valid from roads_current"; $rs = pg_query($con, $sql); $row = pg_fetch_array($rs, 0); $valid = substr($row["valid"], 0, 16); $map = ms_newMapObj('roads.map'); //$map->setProjection("init=epsg:4326"); $map->setProjection("init=epsg:26915"); $map->selectOutputFormat("jpeg"); $map->setextent(122487.56, 4443095.235, 809431.656, 4919662.5); $map->set("width", 720); $map->set("height", 496); $img = $map->prepareImage(); $background = $map->getlayerbyname("kwwlback"); $background->set("status", MS_ON); $background->set("data", "images/26915/kcau.tif"); $background->draw($img); //$counties = $map->getlayerbyname("counties"); //$counties->set("status", MS_ON); //$counties->draw($img); //$states = $map->getlayerbyname("states"); //$states->set("status", MS_ON); //$states->draw($img); $roads = $map->getlayerbyname("roads"); $roads->set("status", MS_ON); if (isset($_GET["extreme"])) { $roads->set("data", "geom from (select b.type as rtype, b.int1, b.oid as boid, b.segid, c.cond_code, b.geom from roads_base b, roads_2007_log c WHERE b.segid = c.segid and c.valid = '2007-03-02 00:11' and b.type > 1 ORDER by b.segid DESC) as foo using UNIQUE boid using SRID=26915");
<?php include "../../config/settings.inc.php"; include "../../include/database.inc.php"; /* We need to get some CGI vars! */ $year = isset($_GET['year']) ? $_GET['year'] : die; $month = isset($_GET['month']) ? $_GET['month'] : die; $day = isset($_GET['day']) ? $_GET['day'] : die; $pvar = isset($_GET['pvar']) ? $_GET['pvar'] : die; $sts = mktime(0, 0, 0, $month, $day, $year); $vars = array(); $pgconn = iemdb("other"); $sql = "SELECT * from flux_vars ORDER by details ASC"; $rows = pg_exec($pgconn, $sql); for ($i = 0; $row = @pg_fetch_array($rows, $i); $i++) { $vars[$row["name"]] = array("units" => $row["units"], "details" => $row["details"]); } $rs = pg_prepare($pgconn, "SELECT", "SELECT * from flux_data WHERE\n valid >= \$1 and valid < (\$1 + '1 day'::interval) \n\t and {$pvar} IS NOT NULL ORDER by valid ASC"); $rs = pg_prepare($pgconn, "METADATA", "SELECT * from flux_meta WHERE \n sts < \$1 and ets > \$1"); $rs = pg_execute($pgconn, "SELECT", array(date('Y-m-d', $sts))); $data = array("NSTL11" => array(), "NSTL10" => array(), "NSTL30FT" => array(), "NSTL110" => array(), "NSTLNSPR" => array()); $times = array("NSTL11" => array(), "NSTL10" => array(), "NSTL30FT" => array(), "NSTL110" => array(), "NSTLNSPR" => array()); for ($i = 0; $row = @pg_fetch_array($rs, $i); $i++) { $ts = strtotime(substr($row["valid"], 0, 16)); $stid = $row["station"]; $val = floatval($row[$pvar]); if ($val > -90000) { $data[$stid][] = floatval($row[$pvar]); $times[$stid][] = $ts; } }
$windhail = ""; if ($warn["windtag"] != null) { $windhail = sprintf("<br />H: %s\"<br />W: %s", $warn["hailtag"], $warn["windtag"]); } $s = sprintf("<tr><td style=\"background: %s;\"><a href=\"%s\">%s.%s</a>%s</td>\n \t\t<td>%s</td><td>%s</td>\n \t\t<td colspan=\"2\"><a href=\"%s\" target=\"_new\">%s</a></td>\n \t\t<td><a href=\"%s\">%s</a></td><td>%.0f sq km</td>\n \t\t<td>%.0f sq km</td><td>%.0f %%</td>\n \t\t<td>%.0f%% <a href=\"/GIS/radmap.php?layers[]=legend&layers[]=ci&layers[]=cbw&layers[]=sbw&layers[]=uscounties&layers[]=bufferedlsr&vtec=%s.K%s.%s.%s.%04d&lsrbuffer=%s\">Visual</a></td>\n \t\t<td>%s</td></tr>\n", $background, $uri, $warn["phenomena"], $warn["eventid"], $windhail, gmdate("m/d/Y H:i", $warn["sts"]), gmdate("m/d/Y H:i", $warn["expire"]), $uri, implode(", ", $warn["ugcname"]), $uri, $warn["status"], $warn["parea"], $warn["carea"], ($warn["carea"] - $warn["parea"]) / $warn["carea"] * 100, $bratio, date("Y", $ts), $warn["wfo"], $warn["phenomena"], $warn["significance"], $warn["eventid"], $lsrbuffer, clean_area_verify($warn["buffered"], $warn["parea"])); reset($warn["lsrs"]); if (sizeof($warn["lsrs"]) == 0 && $warn["verify"]) { $s .= "<tr><td></td><td colspan=\"10\">The warning above had one or more local\n \t\t\tstorm reports that were within previously issued warnings and are\n \t\t\tnot double counted here. Thus the warning appears as verified,\n \t\t\tbut no local storm reports are shown. Future code improvements may \n \t\t\tbe added to the Cow to better account for these.</td></tr>"; } while (list($k, $lsr) = each($warn["lsrs"])) { $s .= printLSR($cow->lsrs[$lsr]); } return $s; } include_once "../../include/cow.php"; $cow = new Cow(iemdb("postgis")); $cow->setLimitWFO(array($wfo)); $cow->setLimitTime($sts, $ets); $cow->setHailSize($hail); $cow->setWind($wind); $cow->setLimitType($wtype); $cow->setLimitLSRType($ltype); $cow->setLSRBuffer($lsrbuffer); $cow->setWarningBuffer($warnbuffer); if (isset($useWindHailTag) && $useWindHailTag == 'Y') { $cow->useWindHailTag = true; } if (isset($limitwarns) && $limitwarns == 'Y') { $cow->limitwarns = true; } $cow->milk();
<?php include "../../config/settings.inc.php"; define("IEM_APPID", 6); include "../../include/database.inc.php"; include_once "../../include/myview.php"; include_once "../../include/forms.php"; $pgconn = iemdb("mesosite"); $network = isset($_GET['network']) ? $_GET['network'] : 'IA_ASOS'; if ($network == '_ALL_') { $sql = "SELECT *,\n ST_x(geom) as longitude, ST_y(geom) as latitude from stations\n WHERE online = 'y' and '_ALL_' = \$1 ORDER by name"; } else { if (isset($_GET["special"]) && $_GET["special"] == 'allasos') { $sql = "SELECT *,\n ST_x(geom) as longitude, ST_y(geom) as latitude from stations\n WHERE online = 'y' and\n\t\t\t(network ~* 'ASOS' or network = 'AWOS') and\n\t\t\t'IA_ASOS' = \$1 ORDER by name"; $network = "IA_ASOS"; } else { $sql = "SELECT *,\n ST_x(geom) as longitude, ST_y(geom) as latitude from stations\n WHERE online = 'y' and\n\t\t\tnetwork = \$1 ORDER by name"; } } $rs = pg_prepare($pgconn, "NTSELECT", $sql); include "../../include/imagemaps.php"; $format = isset($_GET['format']) ? $_GET['format'] : 'html'; $nohtml = isset($_GET['nohtml']); $table = ""; if (strlen($network) > 0) { $result = pg_execute($pgconn, "NTSELECT", array($network)); if ($format == "html") { $table .= "<p><table class=\"table table-striped\">\n"; $table .= "<caption><b>" . $network . " Network</b></caption>\n"; $table .= "<thead><tr><th>ID</th><th>Station Name</td><th>Latitude<sup>1</sup></th>\n\t\t\t<th>Longitude<sup>1</sup></th><th>Elevation [m]</th><th>Archive Begins</th><th>IEM Network</th></tr></thead>\n"; for ($i = 0; $row = @pg_fetch_array($result, $i); $i++) {
$shefcodes = array(); $rs = pg_query($mesosite, "SELECT * from shef_physical_codes"); for ($i = 0; $row = @pg_fetch_assoc($rs, $i); $i++) { $shefcodes[$row['code']] = $row['name']; } $durationcodes = array(); $rs = pg_query($mesosite, "SELECT * from shef_duration_codes"); for ($i = 0; $row = @pg_fetch_assoc($rs, $i); $i++) { $durationcodes[$row['code']] = $row['name']; } $extremumcodes = array(); $rs = pg_query($mesosite, "SELECT * from shef_extremum_codes"); for ($i = 0; $row = @pg_fetch_assoc($rs, $i); $i++) { $extremumcodes[$row['code']] = $row['name']; } $pgconn = iemdb('access'); pg_query($pgconn, "SET time zone '" . $metadata['tzname'] . "'"); $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";
foreach ($Rcities as $key => $value) { $station = $key; include "plot_1min.php"; } } else { foreach ($stations as $key => $value) { $station = $value; include "plot_1min.php"; } } } else { header("Content-type: text/plain"); } } if ($what != "plot") { $connection = iemdb("rwis"); $query1 = "SET TIME ZONE 'GMT'"; $result = pg_exec($connection, $query1); $rs = pg_exec($connection, $sqlStr); pg_close($connection); if ($gis == "yes") { echo "station,station_name,lat,lon,valid(GMT),"; } else { echo "station,station_name,valid(GMT),"; } for ($j = 0; $j < $num_vars; $j++) { echo $vars[$j] . $d[$delim]; if ($vars[$j] == "ca1") { echo "ca1code" . $d[$delim]; } if ($vars[$j] == "ca2") {
<?php /* * Generate Watch by county placefile */ include "../../../config/settings.inc.php"; include "{$rootpath}/include/database.inc.php"; $dbconn = iemdb("postgis"); header("Content-type: text/plain"); $rs = pg_query($dbconn, "select phenomena, eventid, \n \t\tST_asText(ST_Multi(ST_buffer(ST_collect( u.geom ),0))) as g \n \t\tfrom warnings w JOIN ugcs u on (u.gid = w.gid) \n \t\tWHERE significance = 'A' and phenomena IN ('TO','SV') and \n \t\tissue <= now() and expire > now() \n \t\tand substr(w.ugc,3,1) = 'C' GROUP by phenomena, eventid \n \t\tORDER by phenomena ASC"); echo "Refresh: 10\n"; echo "Threshold: 999\n"; echo "Title: SPC Watch by County\n"; for ($i = 0; $row = @pg_fetch_array($rs, $i); $i++) { $geom = $row["g"]; if ($geom == null) { continue; } //echo $geom ."\n"; $geom = str_replace("MULTIPOLYGON(((", "", $geom); $geom = str_replace(")))", "", $geom); $tokens3 = preg_split("/\\)\\),\\(\\(/", $geom); foreach ($tokens3 as $token3) { $tokens = preg_split("/\\),\\(/", $token3); foreach ($tokens as $token) { if ($row["phenomena"] == "SV") { $c = ", 255, 255, 0, 255"; } else { $c = ", 255, 0, 0, 255"; } echo "\n;" . $row["phenomena"] . " Watch Number " . $row["eventid"] . "\n";
$cities = $nt->table; $station = isset($_GET["station"]) ? $_GET["station"] : "SKCI4"; $year = isset($_GET["year"]) ? $_GET["year"] : date("Y"); $month = isset($_GET["month"]) ? $_GET["month"] : date("m"); $day = isset($_GET["day"]) ? $_GET["day"] : date("d"); $myTime = mktime(0, 0, 0, $month, $day, $year); $yesterday = mktime(0, 0, 0, date("m"), date("d"), date("Y")) - 96400; if ($myTime >= $yesterday) { /* Look in IEM Access! */ $dbconn = iemdb("access"); $tbl = "current_log"; $pcol = ", pres as alti"; $rs = pg_prepare($dbconn, "SELECT", "SELECT * {$pcol} from {$tbl} c JOIN stations s ON (s.iemid = c.iemid)\n WHERE id = \$1 and date(valid) = \$2 ORDER by valid ASC"); } else { /* Dig in the archive for our data! */ $dbconn = iemdb("snet"); $tbl = sprintf("t%s", date("Y_m", $myTime)); $pcol = ""; $rs = pg_prepare($dbconn, "SELECT", "SELECT * {$pcol} from {$tbl} \n WHERE station = \$1 and date(valid) = \$2 ORDER by valid ASC"); } $rs = pg_execute($dbconn, "SELECT", array($station, date("Y-m-d", $myTime))); if (pg_num_rows($rs) == 0) { $led = new DigitalLED74(); $led->StrokeNumber('NO DATA FOR THIS DATE', LEDC_GREEN); die; } $titleDate = strftime("%b %d, %Y", $myTime); $cityname = $cities[$station]['name']; /* BEGIN GOOD WORK HERE */ $times = array(); $temps = array();
$month1 = isset($_GET["month1"]) ? $_GET["month1"] : die("No month1"); $month2 = isset($_GET["month2"]) ? $_GET["month2"] : die("No month2"); $vars = isset($_GET["vars"]) ? $_GET["vars"] : die("No vars"); $sample = isset($_GET["sample"]) ? $_GET["sample"] : die("No Sample"); $dl_option = isset($_GET["dl_option"]) ? $_GET["dl_option"] : die("No dl_option"); $delim = isset($_GET["delim"]) ? $_GET["delim"] : die("No delim"); $ts1 = mktime($hour1, 0, 0, $month1, $day1, $year1) or die("Invalid Date Format"); $ts2 = mktime($hour2, 0, 0, $month2, $day2, $year2) or die("Invalid Date Format"); if ($ts1 >= $ts2) { die("Error: Your 'End Date' is before your 'Start Date'!"); } $num_vars = count($vars); if ($num_vars == 0) { die("You did not specify data"); } $connection = iemdb("snet"); $sqlStr = "SELECT station, "; for ($i = 0; $i < $num_vars; $i++) { $sqlStr .= $vars[$i] . " as var" . $i . ", "; } $sqlTS1 = strftime("%Y-%m-%d %H:%M", $ts1); $sqlTS2 = strftime("%Y-%m-%d %H:%M", $ts2); $nicedate = strftime("%Y-%m-%d", $ts1); $sampleStr = array("1min" => "1", "5min" => "5", "10min" => "10", "20min" => "20", "1hour" => "60"); $d = array("comma" => ",", "space" => " ", "tab" => "\t"); $stations = $_GET["station"]; $stationString = "("; foreach ($stations as $key => $value) { $stationString .= " '" . $value . "',"; } $stationString = substr($stationString, 0, -1);
<?php include "../../../config/settings.inc.php"; include_once "{$rootpath}/include/database.inc.php"; $sqlStr = "SELECT station, "; for ($i = 0; $i < $num_vars; $i++) { $sqlStr .= $vars[$i] . " as var" . $i . ", "; } $sqlStr .= "to_char(valid, 'YYYY-MM-DD HH24:MI') as dvalid from " . $table; $sqlStr .= " WHERE valid >= '" . $sqlTS1 . "' and valid <= '" . $sqlTS2 . "' "; $sqlStr .= " and extract(minute from valid)::int % " . $sampleStr[$sample] . " = 0 "; $sqlStr .= " and station = '" . $station . "' ORDER by valid ASC"; $connection = iemdb("awos"); $query1 = "SET TIME ZONE 'GMT'"; $result = pg_exec($connection, $query1); $rs = pg_exec($connection, $sqlStr); pg_close($connection); $dataA = array(); $times = array(); for ($j = 0; $j < $num_vars; $j++) { $dataA[$j] = array(); } for ($i = 0; $row = @pg_fetch_array($rs, $i); $i++) { $times[$i] = strtotime($row["dvalid"]); for ($j = 0; $j < $num_vars; $j++) { $dataA[$j][$i] = $row["var" . $j]; } } // End of for looper // Create the graph. These two calls are always required $graph = new Graph(600, 400, "example3");
<?php /* * Giveme JSON data listing of webcams */ header('content-type: application/json; charset=utf-8'); require_once 'Zend/Json.php'; require_once '../../config/settings.inc.php'; require_once "../../include/database.inc.php"; // This should be a UTC timestamp, gasp! $ts = isset($_REQUEST["ts"]) ? strtotime($_REQUEST["ts"]) : 0; $network = isset($_REQUEST["network"]) ? substr($_REQUEST["network"], 0, 4) : "KCCI"; $connect = iemdb("mesosite"); pg_exec($connect, "SET TIME ZONE 'UTC'"); if ($ts > 0) { if ($network != "IDOT") { $rs = pg_prepare($connect, "CAMSEL", "SELECT * from " . "camera_log c, webcams w WHERE valid = \$1 and c.cam = w.id " . "and w.network = \$2 ORDER by name ASC"); $ar = array(date('Y-m-d H:i', $ts), $network); } else { $rs = pg_prepare($connect, "CAMSEL", "SELECT * from " . "camera_log c, webcams w WHERE " . "valid BETWEEN \$1 and \$2 and c.cam = w.id " . "and w.network = \$3 ORDER by name ASC, valid ASC"); $ar = array(date('Y-m-d H:i', $ts - 10 * 60), date('Y-m-d H:i', $ts + 10 * 60), $network); } } else { $rs = pg_prepare($connect, "CAMSEL", "SELECT * from " . "camera_current c, webcams w WHERE " . "valid > (now() - '30 minutes'::interval) and c.cam = w.id " . "and w.network = \$1 ORDER by name ASC"); $ar = array($network); } $result = pg_execute($connect, "CAMSEL", $ar); $ar = array("images" => array()); if ($ts > 0) { $url = "https://mesonet.agron.iastate.edu/current/camrad.php?network={$network}&ts=" . $_REQUEST["ts"]; } else {
$year = isset($_REQUEST["year"]) ? intval($_REQUEST["year"]) : date("Y"); $month = isset($_REQUEST["month"]) ? intval($_REQUEST["month"]) : date("m"); define("IEM_APPID", 23); $t = new MyView(); $t->title = "Past Features"; $t->thispage = "iem-feature"; $ts = mktime(0, 0, 0, $month, 1, $year); $prev = $ts - 15 * 86400; $plink = sprintf("past.php?year=%s&month=%s", date("Y", $prev), date("m", $prev)); $next = $ts + 35 * 86400; $nmonth = date("m", $next); $nyear = date("Y", $next); $nlink = sprintf("past.php?year=%s&month=%s", $nyear, $nmonth); $mstr = date("M Y", $ts); $table = ""; $c = iemdb("mesosite"); $sql = <<<EOF \tSELECT *, to_char(valid, 'YYYY/MM/YYMMDD') as imageref, \tto_char(valid, 'DD Mon YYYY HH:MI AM') as webdate, \tto_char(valid, 'Dy Mon DD, YYYY') as calhead, \tto_char(valid, 'D') as dow from feature \tWHERE valid BETWEEN '{$year}-{$month}-01' and '{$nyear}-{$nmonth}-01' \tORDER by valid ASC EOF; $rs = pg_exec($c, $sql); $num = pg_numrows($rs); $linkbar = <<<EOF <div class="row well"> \t<div class="col-md-4 col-sm-4"> <a href="{$plink}" class="btn btn-default btn-lg"><i class="glyphicon glyphicon-arrow-left"></i> Previous Month</a> \t</div>
<?php /* Print last two days worth of some PIL */ include "../../../config/settings.inc.php"; include "../../../include/database.inc.php"; $pil = isset($_GET['pil']) ? strtoupper(substr($_GET['pil'], 0, 3)) : "AFD"; $conn = iemdb("afos"); $rs = pg_prepare($conn, "_LSELECT", "SELECT data from products\n WHERE substr(pil,1,3) = \$1 \n\t\tand entered between now() - '48 hours'::interval and now()\n ORDER by entered DESC"); $rs = pg_execute($conn, "_LSELECT", array($pil)); $content = ""; if (pg_numrows($rs) < 1) { $content .= "ERROR: No products found in past 48 hours."; } for ($i = 0; $row = @pg_fetch_assoc($rs, $i); $i++) { $d = preg_replace("/\r\r\n/", "\n", $row["data"]); $d = preg_replace("//", "", $d); $d = preg_replace("//", "", $d); $content .= $d; } header("Content-type: text/plain"); echo $content;
</style> <p>This application plots a timeseries of data from an Iowa RWIS site of your choice. You can optionally select which variables to plot and for which time period in the archive.</p> <form method="GET" action="sf_fe.php" name="olselect"> EOF; if (strlen($station) > 0) { $ys = yearSelect2(1995, $syear, "syear"); $ms = monthSelect2($smonth, "smonth"); $ds = daySelect2($sday, "sday"); $ds2 = daySelect2($days, "days"); $nselect = networkSelect("IA_RWIS", $station); $c0 = iemdb('rwis'); $q0 = "SELECT * from sensors WHERE station = '" . $station . "' "; $r0 = pg_exec($c0, $q0); $row = @pg_fetch_array($r0, 0); $ns0 = $row['sensor0']; $ns1 = $row['sensor1']; $ns2 = $row['sensor2']; $ns3 = $row['sensor3']; pg_close($c0); $cgiStr = "&mode={$mode}&sday={$sday}&smonth={$smonth}&syear={$syear}&days={$days}&"; $table = "<table border=\"1\" cellpadding=\"3\" cellspacing=\"0\">\n <tr><th colspan=\"3\">Plot Options</th></tr>\n <tr><td><b>Restrict Plot:</b>\n <br><input type=\"checkbox\" name=\"limit\" value=\"yes\" "; if (isset($_GET["limit"])) { $table .= "CHECKED"; } $table .= ">Temps between 25-35\n </td><td><b>Pavement Sensors:</b><br>\n"; if (strlen($ns0) > 0) {
<?php /* Generate a CSV file based on a request */ include "../../../config/settings.inc.php"; include "{$rootpath}/include/database.inc.php"; $mesosite = iemdb("mesosite"); $access = iemdb("access"); $asos = iemdb("asos"); pg_exec($access, "SET TIME ZONE 'GMT'"); pg_exec($asos, "SET TIME ZONE 'GMT'"); $stations = array("AMW"); if (isset($_GET["lat"]) && isset($_GET["lon"])) { /* Figure out what station(s) fits the bill */ $sql = sprintf("SELECT id, \n ST_distance_sphere(geom, ST_geometryfromtext('POINT(%.4f %.4f)',4326)) as dist from stations\n WHERE (network ~* 'ASOS' or network ~* 'AWOS') ORDER by dist ASC\n LIMIT 5", $_GET["lon"], $_GET["lat"]); $rs = pg_exec($mesosite, $sql); for ($i = 0; $row = @pg_fetch_array($rs, $i); $i++) { $stations[$i] = $row["id"]; } } $result = "id,valid,tmpf,dwpf,sknt,drct,phour,alti,gust,lon,lat\n"; $prepared = null; while (list($k, $id) = each($stations)) { if (isset($_REQUEST["date"])) { $ts = strtotime($_REQUEST["date"]); if ($prepared == null) { $prepared = pg_prepare($asos, "SELECT", sprintf("SELECT station as id, valid,\n\t\tmax(tmpf) as tmpf, max(dwpf) as dwpf, max(sknt) as sknt, max(drct) as drct,\n\t\tmax(p01i) as phour, max(alti) as alti, max(gust) as gust, \n\t\tmax(ST_x(s.geom)) as lon, max(ST_y(s.geom)) as lat from t%s t, stations s\n\t\twhere s.id = \$1 and (s.network ~* 'ASOS' or s.network ~* 'AWOS')\n\t\tand t.station = s.id and t.valid BETWEEN '%s'::date \n\t\tand '%s'::date + '9 days'::interval GROUP by station, valid \n\t\tORDER by valid ASC", date("Y", $ts), date("Y-m-d", $ts), date("Y-m-d", $ts))); } $rs = pg_execute($asos, "SELECT", array($id)); } else { $rs = pg_exec($access, "SELECT s.id, valid, max(tmpf) as tmpf, max(dwpf) as dwpf, \n max(sknt) as sknt, max(drct) as drct,\n max(phour) as phour, max(alti) as alti, max(gust) as gust,\n max(ST_x(s.geom)) as lon, max(ST_y(s.geom)) as lat from current_log c, stations s\n WHERE s.id = '{$id}' and s.iemid = c.iemid\n GROUP by id, valid ORDER by valid ASC"); }
<?php require_once "../config/settings.inc.php"; include_once "../include/myview.php"; $t = new MyView(); define("IEM_APPID", 39); include_once "../include/database.inc.php"; $dbconn = iemdb("mesosite"); $t->title = "Application Listing"; $t->thispage = "iem-apps"; $table = ""; $tags = array(); $rs = pg_exec($dbconn, "SELECT appid, string_agg(tag, ',') as t from iemapps_tags GROUP by appid"); for ($i = 0; $row = @pg_fetch_assoc($rs, $i); $i++) { $tags[$row["appid"]] = $row["t"]; } $rs = pg_exec($dbconn, "SELECT * from iemapps i ORDER by appid ASC"); for ($i = 0; $row = @pg_fetch_assoc($rs, $i); $i++) { $table .= sprintf("<tr><th><a href='%s'>%s</a></th><td>%s</td><td>%s</td></tr>\n", $row["url"], $row["name"], $row["description"], @$tags[$row["appid"]]); } $t->content = <<<EOF <h3>IEM Application Listing</h3> <p>These are applications internally indexed by the IEM. This list is created to help index content on this website. <p><table class="table table-striped"> <thead> <tr><th>Title</th><th>Description</th><th>Tags</th></tr> </thead> <tbody> {$table}
<?php include "../../../config/settings.inc.php"; $network = isset($_GET['network']) ? substr($_GET["network"], 0, 30) : 'IA_COOP'; include "../../../include/database.inc.php"; $connection = iemdb("iem"); include "../../../include/network.php"; $nt = new NetworkTable($network); $cities = $nt->table; $delim = isset($_GET["delim"]) ? $_GET["delim"] : ","; $what = isset($_GET["what"]) ? $_GET["what"] : 'dl'; $day1 = isset($_GET["day1"]) ? $_GET["day1"] : die("No day1 specified"); $day2 = isset($_GET["day2"]) ? $_GET["day2"] : die("No day2 specified"); $month1 = isset($_GET["month1"]) ? $_GET["month1"] : die("No month1 specified"); $month2 = isset($_GET["month2"]) ? $_GET["month2"] : die("No month2 specified"); $year1 = isset($_GET["year1"]) ? $_GET["year1"] : die("No year1 specified"); $year2 = isset($_GET["year2"]) ? $_GET["year2"] : die("No year2 specified"); $hour1 = 0; $hour2 = 0; $minute1 = 0; $minute2 = 0; $station = $_GET["station"]; $stations = $_GET["station"]; $stationString = "("; $selectAll = false; foreach ($stations as $key => $value) { if ($value == "_ALL") { $selectAll = true; } $stationString .= " '" . $value . "',"; }
<?php include_once "../../../config/settings.inc.php"; include_once "{$rootpath}/include/database.inc.php"; $sqlStr = "SELECT station, "; for ($i = 0; $i < $num_vars; $i++) { $sqlStr .= $vars[$i] . " as var" . $i . ", "; } $sqlStr .= "to_char(valid, 'YYYY-MM-DD HH24:MI') as dvalid from " . $table; $sqlStr .= " WHERE valid >= '" . $sqlTS1 . "' and valid <= '" . $sqlTS2 . "' "; $sqlStr .= " and extract(minute from valid)::int % " . $sampleStr[$sample] . " = 0 "; $sqlStr .= " and station = '" . $station . "' ORDER by valid ASC"; $connection = iemdb("asos"); if ($tz == 'UTC') { $query1 = "SET TIME ZONE 'GMT'"; $result = pg_exec($connection, $query1); } $rs = pg_exec($connection, $sqlStr); pg_close($connection); $dataA = array(); $times = array(); for ($j = 0; $j < $num_vars; $j++) { $dataA[$j] = array(); } for ($i = 0; $row = @pg_fetch_array($rs, $i); $i++) { $times[$i] = strtotime($row["dvalid"]); for ($j = 0; $j < $num_vars; $j++) { $dataA[$j][$i] = $row["var" . $j]; } } // End of for looper