Skip to content

Commit

Permalink
Merge pull request #1125 from akrherz/250224-3
Browse files Browse the repository at this point in the history
Omnibus
  • Loading branch information
akrherz authored Feb 25, 2025
2 parents 12f1154 + 3f2cde7 commit 4b57623
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ci:
autoupdate_schedule: quarterly
repos:
- repo: https://github.com/pre-commit/mirrors-eslint
rev: 'v9.20.1'
rev: 'v9.21.0'
hooks:
- id: eslint
- repo: https://github.com/astral-sh/ruff-pre-commit
Expand Down
5 changes: 5 additions & 0 deletions htdocs/sites/hist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* global $ */

$(document).ready(() => {
$("#thetable").DataTable();
});
16 changes: 5 additions & 11 deletions htdocs/sites/hist.phtml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
/* hist.phtml */
require_once "../../config/settings.inc.php";
require_once "../../include/sites.php";
require_once "../../include/imagemaps.php";
Expand Down Expand Up @@ -60,13 +59,13 @@ function printMonth($year, $month, $db, $thisApp, $dailyApp)
$first_dow = intval(date("w", $sts));

$title = date("M Y", $sts);
$s = <<<EOF
$s = <<<EOM
<table class="table table-bordered">
<tr><td><a href="{$lurl}">{$lstr}</a></td><th colspan="5">{$title}</th>
<td><a href="{$nurl}">{$nstr}</a></td></tr>
<tr><th>Sunday</th><th>Monday</th><th>Tuesday</th><th>Wednesday</th>
<th>Thursday</th><th>Friday</th><th>Saturday</th></tr>
EOF;
EOM;

// Handle the first week
$now = $sts;
Expand Down Expand Up @@ -322,12 +321,12 @@ $htmlout .= <<< EOM
exists as well.</p>
EOM;

$content = <<<EOF
$content = <<<EOM
<div class="hidden-print">
<form method="GET" name="changer" class="form-inline" role="form">
<input type="hidden" name="station" value="{$station}">
<input type="hidden" name="network" value="{$network}">
EOF;
EOM;
$startyear = 2002;
if (!is_null($metadata["archive_begin"])) {
$startyear = $metadata["archive_begin"]->format("Y");
Expand Down Expand Up @@ -365,11 +364,6 @@ $t->headextra = <<<EOM
EOM;
$t->jsextra = <<<EOM
<script src="/vendor/jquery-datatables/{$DT}/datatables.min.js"></script>
<script>
$(document).ready(function(){
$("#thetable").DataTable();
});
</script>
<script src="hist.js" type="text/javascript"></script>
EOM;
$t->render('sites.phtml');
45 changes: 25 additions & 20 deletions htdocs/vtec/yearly_counts.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,23 @@
require_once "../../include/vtec.php";
require_once "../../include/network.php";
require_once "../../include/forms.php";
require_once "../../include/imagemaps.php";
$nt = new NetworkTable("WFO");

$clobber = isset($_REQUEST["clobber"]);
$wfo = isset($_REQUEST["wfo"]) ? strtoupper(substr(xssafe($_REQUEST["wfo"]), 0, 3)) : null;
$wfo = isset($_REQUEST["wfo"]) ? strtoupper(substr(xssafe($_REQUEST["wfo"]), 0, 4)) : "_ALL";
$wfo3 = unrectify_wfo($wfo);
$phenomena = isset($_REQUEST["phenomena"]) ? strtoupper(substr(xssafe($_REQUEST["phenomena"]), 0, 2)) : null;
$significance = isset($_REQUEST["significance"]) ? strtoupper(substr(xssafe($_REQUEST["significance"]), 0, 1)) : null;
$wfoLimiter = "";
$wfoMsg = "Data for all WFOs shown";
if ($wfo) {
$wfoLimiter = " and wfo = '{$wfo}' ";
if ($wfo != "_ALL") {
$wfoLimiter = " and wfo = '{$wfo3}' ";
$wfoMsg = "Data for only $wfo shown";
}

$p1 = make_select("phenomena", $phenomena, $vtec_phenomena);
$s1 = make_select("significance", $significance, $vtec_significance);
$p1 = make_select("phenomena", $phenomena, $vtec_phenomena, $showvalue = TRUE);
$s1 = make_select("significance", $significance, $vtec_significance, $showvalue = TRUE);

$t = new MyView();
$t->title = "VTEC Yearly Event Counts";
Expand All @@ -34,12 +36,13 @@ function get_data()
$dbconn,
"
SELECT yr, phenomena, significance, count(*) from
(SELECT distinct extract(year from issue) as yr, wfo,
(SELECT distinct vtec_year as yr, wfo,
phenomena, significance, eventid from warnings WHERE
significance is not null and phenomena is not null and
issue > '1980-01-01' $wfoLimiter) as foo
GROUP by yr, phenomena, significance
");
"
);

$data = array();
$pcodes = array();
Expand All @@ -64,12 +67,13 @@ function get_data2()
$dbconn,
"
WITH data as (
SELECT distinct wfo, eventid, extract(year from issue) as yr
SELECT distinct wfo, eventid, vtec_year as yr
from warnings where phenomena = '$phenomena' and
significance = '$significance'
)
SELECT wfo, yr, count(*) from data GROUP by wfo, yr
");
"
);

$data = array();
for ($i = 0; $row = pg_fetch_assoc($rs); $i++) {
Expand Down Expand Up @@ -99,7 +103,7 @@ function get_data2()

$table = <<<EOF
<table class="table table-striped">
<thead><tr><th>P</th><th>S</th><th>Phenomena</th><th>Significance</th>
<thead class="sticky"><tr><th>P</th><th>S</th><th>Phenomena</th><th>Significance</th>
EOF;
$years = array_keys($data);
asort($years);
Expand Down Expand Up @@ -144,7 +148,7 @@ function get_data2()

$table = <<<EOF
<table class="table table-striped">
<thead><tr><th>WFO</th><th>WFO Name</th>
<thead class="sticky"><tr><th>WFO</th><th>WFO Name</th>
EOF;
$years = array_keys($data);
asort($years);
Expand All @@ -154,14 +158,15 @@ function get_data2()
$table .= "</tr></thead>\n";

foreach ($nt->table as $key => $val) {
$wfo3 = unrectify_wfo($key);
$table .= sprintf(
"<tr><td>%s</td><td>%s</td>",
$key,
$val["name"]
);
foreach ($years as $i => $yr) {
if (array_key_exists($key, $data[$yr])) {
$table .= sprintf("<td>%s</td>", $data[$yr][$key]);
if (array_key_exists($wfo3, $data[$yr])) {
$table .= sprintf("<td>%s</td>", $data[$yr][$wfo3]);
} else {
$table .= "<td>0</td>";
}
Expand Down Expand Up @@ -197,18 +202,18 @@ function get_data2()
your favorite spreadsheet program for further analysis...</div>
$cachedwarning
<p><h4>Option 1: All VTEC Events by Year</h4>
<form method="GET" name="wfo">
Limit Numbers by WFO:
EOF;
$content .= "<select name=\"wfo\">
<option value=\"ALL\" SELECTED>All Available</option>";
foreach ($nt->table as $key => $value) {
$content .= "<option value='$key'>[$key] " . $value["name"] . "</option>\n";
}
$allWFO = array("_ALL" => array(
"id" => "_ALL",
"name" => "All Available",
"archive_end" => null,
"archive_begin" => new DateTime("1980-01-01")));
$content .= networkSelect("WFO", $wfo, $extra = $allWFO, $selectName = "wfo");
$content .= <<<EOF
</select>
<input type="submit" value="Generate Table">
</form>
Expand Down
2 changes: 1 addition & 1 deletion scripts/util/set_iemdb_etc_hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"-isuag": IPS[DB1],
"-kcci": IPS[DB1],
"-mesonet": IPS[DB1],
"-mesosite": IPS[DB1],
"-mesosite": IPS[DB2], # needs 10g
"-mos": IPS[DB1],
"-nc1018": IPS[DB1],
"-nldn": IPS[DB2],
Expand Down

0 comments on commit 4b57623

Please sign in to comment.