示例#1
5
<?php

date_default_timezone_set('UTC');
include "../../include/wfoLocs.php";
include "../../include/cow.php";
include "../../include/database.inc.php";
$lt = array("F" => "Flash Flood", "T" => "Tornado", "D" => "Tstm Wnd Dmg", "H" => "Hail", "G" => "Wind Gust", "W" => "Waterspout", "M" => "Marine Tstm Wnd");
while (list($key, $val) = each($wfos)) {
    echo "Running for {$key}\n";
    $output = fopen("data/{$key}.csv", 'w');
    fwrite($output, "WFO,YEAR,WARN_ID,ISSUE,EXPIRE,SBW_AREA,CNTY_AREA,PERIM_RATIO,AREAL_VERIF,LSR1_VALID,LSR1_TYPE,LSR1_MAG,LSR1_CITY,LSR1_COUNTY,LSR2_VALID,LSR2_TYPE,LSR2_MAG,LSR2_CITY,LSR2_COUNTY,LSR3_VALID,LSR3_TYPE,LSR3_MAG,LSR3_CITY,LSR3_COUNTY,LSR4_VALID,LSR4_TYPE,LSR4_MAG,LSR4_CITY,LSR4_COUNTY,LSR5_VALID,LSR5_TYPE,LSR5_MAG,LSR5_CITY,LSR5_COUNTY,\n");
    $cow = new Cow(iemdb("postgis"));
    $cow->setLimitTime(mktime(12, 0, 0, 1, 1, 2005), mktime(12, 0, 0, 1, 1, 2013));
    $cow->setHailSize(0.75);
    $cow->setLimitType(array("TO", "SV"));
    $cow->setLimitLSRType(array("TO", "SV"));
    $cow->setLimitWFO(array($key));
    $cow->milk();
    reset($cow->warnings);
    while (list($k, $warn) = each($cow->warnings)) {
        $carea = 0;
        reset($warn["ugc"]);
        while (list($k, $v) = each($warn["ugc"])) {
            $carea += $cow->ugcCache[$v]["area"];
        }
        $bratio = "0";
        if ($warn["perimeter"] > 0) {
            $bratio = $warn["sharedborder"] / $warn["perimeter"] * 100.0;
        }
        fwrite($output, sprintf("%s,%s,%s.%s,%s,%s,%.2f,%.2f,%.2f,%.2f,", $key, gmdate("Y", $warn["sts"]), $warn["phenomena"], $warn["eventid"], date("m/d/Y H:i", $warn["sts"]), date("m/d/Y H:i", $warn["expire"]), $warn["parea"], $carea, $bratio, $warn["buffered"] / $warn["parea"] * 100.0));
        // LSRs
示例#2
0
文件: worker.php 项目: muthulatha/iem
    $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();
示例#3
0
<?php

/*
 * Print a report of IEM Cow statistics
 * This is called from the python spammer script as it uses the output to
 * send in an email
 */
date_default_timezone_set('America/Chicago');
/* Generate some cow statistics! */
$ets = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
$sts = $ets - 86400.0;
date_default_timezone_set('UTC');
include "../../include/cow.php";
include "../../include/database.inc.php";
$cow = new Cow(iemdb("postgis"));
$cow->setLimitTime($sts, $ets);
$cow->setHailSize(1.0);
$cow->setLimitType(array("TO", "SV"));
$cow->setLimitLSRType(array("TO", "SV"));
$cow->milk();
if (sizeof($cow->warnings) == 0) {
    echo "No Warnings Issued\n";
    die;
}
echo sprintf("SVR+TOR Warnings Issued: %s Verified: %s  [%.1f %%]\n", sizeof($cow->warnings), $cow->computeWarningsVerified(), $cow->computeWarningsVerifiedPercent());
echo sprintf("Reduction of Size Versus County Based     [%.1f %%]\n", $cow->computeSizeReduction());
echo sprintf("Average Perimeter Ratio                   [%.1f %%]\n", $cow->computeAveragePerimeterRatio());
echo sprintf("Percentage of Warned Area Verified (15km) [%.1f %%]\n", $cow->computeAreaVerify());
echo sprintf("Average Storm Based Warning Size          [%.0f sq km]\n", $cow->computeAverageSize());
echo sprintf("Probability of Detection(higher is better)[%.2f]\n", $cow->computePOD());
echo sprintf("False Alarm Ratio (lower is better)       [%.2f]\n", $cow->computeFAR());
示例#4
0
<?php

date_default_timezone_set('UTC');
include "../../include/wfoLocs.php";
include "../../include/cow.php";
include "../../include/database.inc.php";
echo "WFO,AREA_V,SIZE_R\n";
//while (list($key,$val) = each($wfos)){
$cow = new Cow(iemdb("postgis"));
$cow->setLimitTime(mktime(6, 0, 0, 10, 1, 2007), mktime(0, 0, 0, 1, 1, 2014));
$cow->setHailSize(0.75);
$cow->setLimitType(array("TO"));
$cow->setLimitLSRType(array("TO"));
$cow->setLimitWFO(array("MPX"));
$cow->milk();
echo sprintf("%s,%.1f,%.1f\n", $key, $cow->computeAreaVerify(), $cow->computeSizeReduction());
echo $cow->computeAveragePerimeterRatio();
echo "\n";
echo $cow->computePOD();
echo "\n";
echo $cow->computeFAR();
echo "\n";
echo $cow->computeCSI();
echo "\n";
echo $cow->computeSharedBorder();
echo "\n";
//}
示例#5
0
<?php

date_default_timezone_set('UTC');
include "../../include/cow.php";
include "../../include/database.inc.php";
$lt = array("F" => "Flash Flood", "T" => "Tornado", "D" => "Tstm Wnd Dmg", "H" => "Hail", "G" => "Wind Gust", "W" => "Waterspout", "M" => "Marine Tstm Wnd");
$pgconn = iemdb("postgis");
$output = fopen("arx.csv", 'w');
fwrite($output, "VALID,TYPE,MAG,CITY,COUNTY,VERIFY,LEADTIME,LAT,LON,WE_RATIO\n");
$cow = new Cow($pgconn);
$cow->setLimitTime(mktime(12, 0, 0, 10, 1, 2007), mktime(12, 0, 0, 7, 1, 2014));
$cow->setHailSize(0.75);
$cow->setLimitType(array("TO", "SV"));
$cow->setLimitLSRType(array("TO", "SV"));
$cow->setLimitWFO(array("ARX"));
$cow->milk();
reset($cow->lsrs);
while (list($k, $lsr) = each($cow->lsrs)) {
    $rs = pg_query($pgconn, sprintf("SELECT ST_XMIN(geom), ST_XMAX(geom) from ugcs\n\t\t\tWHERE name = '%s' and state = '%s' and end_ts is null\n\t\t\tand substr(ugc,3,1) = 'C'", $lsr['county'], $lsr['state']));
    if (pg_numrows($rs) < 1) {
        echo $lsr["county"] . " -- " . $lsr["state"];
    }
    $row = pg_fetch_assoc($rs, 0);
    $ratio = ($lsr["lon0"] - $row["st_xmin"]) / ($row["st_xmax"] - $row["st_xmin"]);
    fwrite($output, sprintf("%s,%s,%s,%s,%s,%s,%s,%s,%s,%.2f\n", gmdate("m/d/Y H:i", $lsr["ts"]), $lt[$lsr["type"]], $lsr["magnitude"], $lsr["city"], $lsr["county"], $lsr["warned"] ? 'T' : 'F', $lsr["leadtime"] == "NA" ? "M" : $lsr["leadtime"], $lsr["lat0"], $lsr["lon0"], $ratio));
}
fclose($output);