From 4e3dca8b3b7f634740e92266e716d820a6b672fb Mon Sep 17 00:00:00 2001 From: akrherz Date: Fri, 10 Nov 2023 12:52:47 -0600 Subject: [PATCH 1/2] mnt: workaround pandas frag warning --- scripts/isusm/agg_1minute.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/isusm/agg_1minute.py b/scripts/isusm/agg_1minute.py index 2c77dbc039..b9784b39e4 100644 --- a/scripts/isusm/agg_1minute.py +++ b/scripts/isusm/agg_1minute.py @@ -131,7 +131,8 @@ def main(argv): with get_sqlalchemy_conn("isuag") as conn: # Get the minute data mdf = pd.read_sql( - "SELECT *, valid at time zone 'UTC' as utc_valid from sm_minute " + "SELECT *, valid at time zone 'UTC' as utc_valid, " + "date(valid) as date from sm_minute " "where valid >= %s and valid < %s ORDER by valid ASC", conn, params=(sts, ets), @@ -139,7 +140,8 @@ def main(argv): ).fillna(np.nan) # Get the hourly data hdf = pd.read_sql( - "SELECT *, valid at time zone 'UTC' as utc_valid from sm_hourly " + "SELECT *, valid at time zone 'UTC' as utc_valid, " + "date(valid) as date from sm_hourly " "where valid >= %s and valid < %s ORDER by valid ASC", conn, params=(sts, ets), From ecfd71fff73fd2cf84fff9e81a2f4a3a13263e4d Mon Sep 17 00:00:00 2001 From: akrherz Date: Sat, 11 Nov 2023 07:16:24 -0600 Subject: [PATCH 2/2] feat: add 6 hour snowfall report table https://mesonet.agron.iastate.edu/nws/snowfall_6hour.php closes #582 --- htdocs/nws/index.php | 11 +++ htdocs/nws/snowfall_6hour.php | 156 ++++++++++++++++++++++++++++++++++ 2 files changed, 167 insertions(+) create mode 100644 htdocs/nws/snowfall_6hour.php diff --git a/htdocs/nws/index.php b/htdocs/nws/index.php index d804b28ce4..ae1541767f 100644 --- a/htdocs/nws/index.php +++ b/htdocs/nws/index.php @@ -285,6 +285,17 @@ +
+
Snowfall
+
+ +
+
+ +
Storm Prediction Center Products
diff --git a/htdocs/nws/snowfall_6hour.php b/htdocs/nws/snowfall_6hour.php new file mode 100644 index 0000000000..094e75f2ac --- /dev/null +++ b/htdocs/nws/snowfall_6hour.php @@ -0,0 +1,156 @@ +headextra = << +EOM; +$t->jsextra = << + +EOM; + +$year = get_int404("year", date("Y")); +$month = get_int404("month", date("m")); +$day = get_int404("day", date("d")); +$now = new DateTime(sprintf("%s-%s-%s 12:00", $year, $month, $day), new DateTimeZone("UTC")); +$wfo = isset($_REQUEST["wfo"]) ? xssafe($_REQUEST["wfo"]) : "DMX"; +$w = isset($_REQUEST["w"]) ? xssafe($_REQUEST["w"]) : "all"; +$state = isset($_REQUEST["state"]) ? xssafe($_REQUEST["state"]) : "IA"; + +$t->title = "NWS Six Hour Snowfall Reports"; +$t->refresh = 360; + +$wselect = networkSelect("WFO", $wfo, array(), "wfo"); +$yselect = yearSelect2(2010, $year, "year"); +$mselect = monthSelect($month, "month"); +$dselect = daySelect($day); + +// We need to loop over the date, so starting at 12z and to 6z of the next day +$station_data = Array(); +$hrs = Array(12, 18, 0, 6); +// loop over hrs array +foreach($hrs as $hr){ + $arr = array("valid" => $now->format("Y-m-d\TH:i")); + $jobj = iemws_json("nws/snowfall_6hour.json", $arr); + foreach ($jobj["data"] as $bogus => $row) { + $station = $row["station"]; + if ($w == "wfo" && $row["wfo"] != $wfo){ + continue; + } + if ($w == "state" && $row["state"] != $state){ + continue; + } + if (! array_key_exists($station, $station_data)){ + $station_data[$station] = Array( + "network" => $row["network"], + "station" => $station, + "name" => $row["name"], + "state" => $row["state"], + "wfo" => $row["wfo"], + "value" => Array(12 => "M", 18 => "M", 0 => "M", 6 => "M"), + ); + } + $station_data[$station]["value"][$hr] = ($row["value"] == 0.0001) ? "T": $row["value"]; + } + // add 6 hours to $now + $now->modify("+6 hours"); +} + + +$table = ""; +foreach ($station_data as $row) { + $table .= sprintf( + '%s[%s]' . + '%s%s%s%s'. + '%s%s%s', + $row["network"], + $row["station"], + $row["station"], + $row["network"], + $row["name"], + $row["state"], + $row["wfo"], + $row["value"][12], + $row["value"][18], + $row["value"][0], + $row["value"][6], + ); +} + +$wfoselected = ($w == "wfo") ? 'checked="checked"' : ""; +$allselected = ($w == "all") ? 'checked="checked"' : ""; +$stateselected = ($w == "state") ? 'checked="checked"' : ""; +$sselect = stateSelect($state); + +$t->content = << +
  • NWS User Resources
  • +
  • NWS Six Hour Snowfall
  • + + +

    The National Weather Service has a limited number of observers that report +snowfall totals at 6 hour intervals. This page lists any of those observations +found by the IEM whilst parsing the feed of SHEF encoded data. +API Service +with this data.

    + +

    This page presents one "day" of data at a time. The day is defined as starting +at 6 UTC, so the first report shown is valid at 12 UTC of the given date. The +subsequent 0, and 6 UTC values shown are with valid dates of the next day.

    + +

    + +
    + + + + + + + + + + +
    Year: {$yselect}Month: {$mselect}Day: {$dselect} + + + + +:{$wselect} + + +:{$sselect} +
    +
    + +

    Six Hour Snowfall

    + +

    Values are in inches. T indicates a trace of snowfall. The table will +refresh every 6 minutes.

    + +
    + + + + + + + +{$table} + +
    Station/NetworkNameStateWFO12 UTC
    (6 AM CST)
    18 UTC
    (12 PM CST)
    0 UTC
    (6 PM CST)
    6 UTC
    (12 AM CST)
    +
    +EOF; +$t->render('full.phtml');