Skip to content

Commit

Permalink
Merge pull request #585 from akrherz/231111-2
Browse files Browse the repository at this point in the history
Omnibus
  • Loading branch information
akrherz authored Nov 12, 2023
2 parents c3b864e + 0fd5a87 commit 994ebde
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 16 deletions.
1 change: 1 addition & 0 deletions .github/workflows/etchosts.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
127.0.0.1 iemdb-smos.local
127.0.0.1 iemdb-talltowers.local
127.0.0.1 iemdb-td.local
127.0.0.1 iemdb-uscrn.local
127.0.0.1 iemdb-sustainablecorn.local
127.0.0.1 iemdb-asos1min.local
127.0.0.1 iem-memcached3
Expand Down
12 changes: 8 additions & 4 deletions htdocs/json/spcoutlook.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import pandas as pd
from pandas.io.sql import read_sql
from pyiem.exceptions import IncompleteWebRequest
from pyiem.nws.products.spcpts import THRESHOLD_ORDER
from pyiem.util import get_dbconnc, get_sqlalchemy_conn, html_escape
from pyiem.webutil import iemapp
Expand Down Expand Up @@ -135,11 +136,14 @@ def dowork(lon, lat, last, day, cat):
@iemapp()
def application(environ, start_response):
"""Answer request."""
lat = float(environ.get("lat", 42.0))
lon = float(environ.get("lon", -95.0))
try:
lat = float(environ.get("lat", 42.0))
lon = float(environ.get("lon", -95.0))
last = int(environ.get("last", 0))
day = int(environ.get("day", 1))
except ValueError as exp:
raise IncompleteWebRequest(f"Invalid request parameter {exp}")
time = environ.get("time")
last = int(environ.get("last", 0))
day = int(environ.get("day", 1))
cat = environ.get("cat", "categorical").upper()

cb = environ.get("callback")
Expand Down
5 changes: 4 additions & 1 deletion htdocs/plotting/auto/scripts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@
"High/Low Temp above/below avg OR dry streaks by NWS CLI Sites"
),
},
{"id": 19, "label": "Histogram of Daily High/Low Temperatures + Ranges"},
{
"id": 19,
"label": "Histogram (weathergami) of Daily High/Low Temps + Ranges",
},
{"id": 35, "label": "Histogram of X Hour Temp/RH/Dew/Pressure Changes"},
{
"id": 60,
Expand Down
10 changes: 6 additions & 4 deletions htdocs/plotting/auto/scripts100/p125.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import pandas as pd
from pyiem.exceptions import NoDataFound
from pyiem.plot import MapPlot, get_cmap, pretty_bins
from pyiem.reference import LATLON, SECTORS_NAME
from pyiem.reference import LATLON, SECTORS_NAME, Z_OVERLAY2
from pyiem.util import get_autoplot_context, get_sqlalchemy_conn
from sqlalchemy import text

Expand Down Expand Up @@ -184,7 +184,7 @@ def plotter(fdict):
months = [ts.month]

if len(months) == 1:
title = f"{calendar.month_name[months[0]]} {PDICT3[varname]}"
title = calendar.month_name[months[0]]
else:
title = MDICT[month]
params = {}
Expand Down Expand Up @@ -227,13 +227,13 @@ def plotter(fdict):
text(
f"""
WITH mystations as (
select {joincol} as myid,
select {joincol} as myid, max(state) as state,
max(ST_x(geom)) as lon, max(ST_y(geom)) as lat from stations
where network ~* 'CLIMATE' and
ST_Contains(ST_MakeEnvelope(:b1, :b2, :b3, :b4, 4326), geom)
GROUP by myid
)
SELECT station,
SELECT station, max(state) as state,
max(lon) as lon, min(lat) as lat,
sum(precip) as total_precip,
avg(high) as avg_high,
Expand Down Expand Up @@ -277,6 +277,7 @@ def plotter(fdict):
# Manual clipping sector
mp.draw_mask(None if sector == "state" else "conus")
if sector == "state":
df = df[df["state"] == state]
mp.drawcounties()
if opt in ["both", "values"]:
mp.plot_values(
Expand All @@ -285,6 +286,7 @@ def plotter(fdict):
df[varname].values,
fmt=f"%.{PRECISION.get(varname, 1)}f",
labelbuffer=5,
zorder=Z_OVERLAY2 + 3, # FIXME in pyIEM someday
)

return mp.fig, df
Expand Down
2 changes: 1 addition & 1 deletion include/database.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ function iemdb($dbname, $force_new = 0, $rw = FALSE)
database_failure($dbname);
}
return $db;
} // End of iemdb()
}
3 changes: 2 additions & 1 deletion scripts/dbutil/compute_alldata_sts.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
from pyiem.util import get_dbconnc, logger

LOG = logger()
ALLDATA = {"USCRN": "uscrn_alldata"}
ALLDATA = {}
START_YEAR = {
"rwis": 1994,
"asos": 1928,
"other": 2003,
"scan": 1987,
"uscrn": 2001,
}
TODAY = datetime.date.today()

Expand Down
6 changes: 3 additions & 3 deletions scripts/ingestors/uscrn_ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def download(year, reprocess=False):
def main(argv):
"""Go Main Go"""
iem_pgconn = get_dbconn("iem")
other_pgconn = get_dbconn("other")
pgconn = get_dbconn("uscrn")
year = datetime.datetime.utcnow().year
reprocess = False
if len(argv) == 2:
Expand All @@ -244,15 +244,15 @@ def main(argv):
reprocess = True
for [fn, size] in download(year, len(argv) == 2):
icursor = iem_pgconn.cursor(row_factory=dict_row)
ocursor = other_pgconn.cursor()
ocursor = pgconn.cursor()
try:
process_file(icursor, ocursor, year, fn, size, reprocess)
except Exception as exp:
LOG.warning("uscrn_ingest %s traceback: %s", fn, exp)
icursor.close()
ocursor.close()
iem_pgconn.commit()
other_pgconn.commit()
pgconn.commit()


if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions scripts/uscrn/compute_uscrn_pday.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ def run(valid):
nt = NetworkTable("USCRN")
iem_pgconn = get_dbconn("iem")
LOG.info("Processing %s", valid.date())
with get_sqlalchemy_conn("other") as conn:
with get_sqlalchemy_conn("uscrn") as conn:
# Fetch enough data to cross all the dates
df = pd.read_sql(
"SELECT station, valid at time zone 'UTC' as utc_valid, precip_mm "
"from uscrn_alldata where valid > %s and valid < %s",
"from alldata where valid > %s and valid < %s",
conn,
params=(
valid - datetime.timedelta(days=1),
Expand Down

0 comments on commit 994ebde

Please sign in to comment.