Skip to content

Commit

Permalink
Merge pull request #1063 from akrherz/250109
Browse files Browse the repository at this point in the history
Omnibus
  • Loading branch information
akrherz authored Jan 9, 2025
2 parents 9ce37b7 + 36600b3 commit 0c9232d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
18 changes: 12 additions & 6 deletions htdocs/sites/scp.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@

$exturi = sprintf(
"https://mesonet.agron.iastate.edu/" .
"api/1/scp.json?station=%s&date=%s",
"api/1/scp.json?station=%s&date=%s&tz=%s",
$station,
date("Y-m-d", $date)
date("Y-m-d", $date),
$metadata["tzname"],
);
$arr = array(
"station" => $station,
"date" => date("Y-m-d", $date),
"tz" => $metadata["tzname"],
);
$json = iemws_json("scp.json", $arr);
if ($json === FALSE) {
Expand Down Expand Up @@ -88,8 +90,11 @@ function skyc($row, $i)

$table = <<<EOM
<table>
<thead>
<tr><th rowspan="2" class="rl">SCP Valid UTC</th>$header<th colspan="2">ASOS METAR Report</th></tr>
<thead class="sticky">
<tr>
<th rowspan="2" class="rl">SCP Valid UTC</th>
<th rowspan="2" class="rl">METAR Valid Local</th>
$header<th colspan="2">ASOS METAR Report</th></tr>
<tr>$header2<th>Levels ft</th><th>METAR</th></tr>
</thead>
<tbody>
Expand All @@ -103,8 +108,9 @@ function skyc($row, $i)
continue;
}
$table .= sprintf(
"<tr><td class=\"rl\">%sZ</td>",
gmdate("Hi", strtotime($row["utc_scp_valid"]))
"<tr><td class=\"rl\">%sZ</td><td class=\"rl\">%s</td>",
gmdate("Hi", strtotime($row["utc_scp_valid"])),
date("g:i A", strtotime($row["local_valid"]))
);
foreach ($birds as $b) {
$table .= sprintf(
Expand Down
10 changes: 6 additions & 4 deletions scripts/dl/download_narr.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import click
import httpx
import pygrib
from pyiem.util import exponential_backoff, logger
from pyiem.util import logger

LOG = logger()
TMP = "/mesonet/tmp"
Expand Down Expand Up @@ -59,10 +59,12 @@ def fetch_rda(year, month):
"https://data.rda.ucar.edu/ds608.0/3HRLY/"
f"{year}/NARRsfc_{year}{month:02.0f}_{day}.tar"
)
req = exponential_backoff(httpx.get, uri, timeout=30, stream=True)
tmpfn = f"{TMP}/narr.tar"
with open(tmpfn, "wb") as fh:
for chunk in req.iter_content(chunk_size=1024):
with (
httpx.stream("GET", uri, timeout=30) as resp,
open(tmpfn, "wb") as fh,
):
for chunk in resp.iter_bytes(chunk_size=1024):
if chunk:
fh.write(chunk)
process(tmpfn)
Expand Down

0 comments on commit 0c9232d

Please sign in to comment.