示例#1
0
function wind_formatter($row)
{
    if ($row["drct"] == null) {
        return "M";
    }
    $gust_text = "";
    if ($row["gust"] > 0) {
        $gust_text = sprintf("G %.0f", $row["gust"] * 1.15);
    }
    return sprintf("%s %.0f%s", drct2txt($row["drct"]), $row["sknt"] * 1.15, $gust_text);
}
示例#2
0
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);
}
// End of while
fclose($rwis);
$pqstr = "data c 000000000000 wxc/wxc_ia_awos.txt bogus txt";
$cmd = sprintf("/home/ldm/bin/pqinsert -p '%s' /tmp/wxc_ia_awos.txt", $pqstr);
system($cmd);
unlink("/tmp/wxc_ia_awos.txt");
示例#3
0
文件: kelo.php 项目: muthulatha/iem
    }
    if ($s < 75) {
        return "1,15";
    }
    if ($s < 80) {
        return "1,16";
    }
    if ($s < 85) {
        return "1,17";
    }
    if ($s < 80) {
        return "1,18";
    }
    if ($s < 100) {
        return "1,19";
    }
    return "1,20";
}
$now = time();
while (list($key, $iemob) = each($snet)) {
    $mydata = $iemob->db;
    $meta = $cities[$key];
    $tdiff = $now - $mydata["ts"];
    if ($tdiff > 3600) {
        continue;
    }
    if ($mydata["sknt"] < 2.5) {
        $mydata["drct"] = 0;
    }
    echo "Object: " . $meta["lat"] . "," . $meta["lon"] . "\n  Threshold: 999 \n  Icon: 0,0," . $mydata["drct"] . "," . s2icon(floatval($mydata["sknt"])) . "\n  Icon: 0,0,000,2,13,\"" . $meta["name"] . " @ " . strftime("%d %b %I:%M %p", $mydata['ts']) . "\\nTemp: " . $mydata["tmpf"] . "F (Dew: " . $mydata["dwpf"] . "F)\\nWind: " . drct2txt($mydata["drct"]) . " @ " . intval($mydata["sknt"]) . "kt\\n\" \n  Threshold: 150\n  Text:  -17, 13, 1, \" " . $mydata["tmpf"] . " \" \n  Text:  -17, -13, 1, \" " . $mydata["dwpf"] . " \" \n End: \n\n";
}
示例#4
0
文件: kelo.php 项目: muthulatha/iem
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"];
$width = 320;
$height = 240;
$Font = '/mesonet/data/gis/static/fonts/kcci.ttf';
$gif = ImageCreate($width, $height);
//int imagecopy ( resource dst_im, resource src_im, int dst_x, int dst_y, int src_x, int src_y, int src_w, int src_h)
$black = ImageColorAllocate($gif, 0, 0, 0);
$white = ImageColorAllocate($gif, 250, 250, 250);
$green = ImageColorAllocate($gif, 0, 255, 0);
$yellow = ImageColorAllocate($gif, 255, 255, 120);
$red = ImageColorAllocate($gif, 148, 52, 53);
$blue = ImageColorAllocate($gif, 0, 0, 255);
$grey = ImageColorAllocate($gif, 110, 110, 110);
ImageFilledRectangle($gif, 2, 2, $width, $height, $grey);
示例#5
0
文件: alpha.php 项目: muthulatha/iem
<?php

$station = isset($_GET['station']) ? substr($_GET['station'], 0, 5) : 'SJEI4';
include "../../config/settings.inc.php";
include "../../include/iemaccess.php";
include "../../include/mlib.php";
include "../../include/iemaccessob.php";
$iem = new IEMAccess();
$ob = $iem->getSingleSite($station);
header('Content-type: text/plain');
echo $ob->db["tmpf"] . "\n";
echo $ob->db["dwpf"] . "\n";
echo $ob->db["sknt"] . "\n";
echo drct2txt($ob->db["drct"]) . "\n";
echo round($ob->db["gust"], 0) . "\n";
echo $ob->db["pday"] . "\n";
echo $ob->db["relh"] . "\n";
echo $ob->db["pres"] . "\n";
echo feels_like($ob->db['tmpf'], $ob->db['relh'], $ob->db['sknt']) . "\n";
示例#6
0
    }
    if (round($val->db['tsf2'], 0) == -100) {
        $val->db['tsf2'] = 'M';
    } else {
        $val->db['tsf2'] = round($val->db['tsf2'], 0);
    }
    if (round($val->db['tsf3'], 0) == -100) {
        $val->db['tsf3'] = '';
    } else {
        $val->db['tsf3'] = round($val->db['tsf3'], 0);
    }
    if (round($val->db['pave_avg'], 0) == -100) {
        $val->db['pave_avg'] = 'M';
    } else {
        $val->db['pave_avg'] = round($val->db['pave_avg'], 0);
    }
    $s = sprintf("%6s %-52s %2s %7s %8s %2s %4s %5.1f %5s %4.0f %4.0f %5.1f %5s %5s %5s %5s %5s %5s %5s %5s %5s %5s\n", $key, strtoupper(preg_replace("/\\s+/", "|", $cities[$key]['name'])), $val->db['state'], 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'], fancy($val->db['rwis_subf'], -50, 180, 5), fancy($val->db['tsf0'], -50, 180, 5), fancy($val->db['tsf1'], -50, 180, 5), fancy($val->db['tsf2'], -50, 180, 5), fancy($val->db['tsf3'], -50, 180, 5), fancy($val->db['pave_avg'], -50, 180, 5), $val->db["wcht"], $val->db["heat"], fancy($val->db["max_tmpf"], -50, 120, 5), fancy($val->db["min_tmpf"], -50, 120, 5));
    fwrite($rwis, str_replace("|", " ", $s));
    fwrite($rwiscsv, str_replace("|", " ", implode(",", preg_split("/\\s+/", trim($s)))) . "\n");
}
// End of while
fclose($rwis);
fclose($rwiscsv);
$pqstr = "data c 000000000000 wxc/wxc_oh_in_kydot.txt bogus txt";
$cmd = sprintf("/home/ldm/bin/pqinsert -p '%s' /tmp/wxc_oh_in_kydot.txt", $pqstr);
system($cmd);
$pqstr = "data c 000000000000 csv/oh_in_kydot.txt bogus txt";
$cmd = sprintf("/home/ldm/bin/pqinsert -p '%s' /tmp/csv_oh_in_kydot.txt", $pqstr);
system($cmd);
unlink("/tmp/wxc_oh_in_kydot.txt");
unlink("/tmp/csv_oh_in_kydot.txt");