diff --git a/.github/workflows/etchosts.txt b/.github/workflows/etchosts.txt index c852fb891b..e0d4863ba2 100644 --- a/.github/workflows/etchosts.txt +++ b/.github/workflows/etchosts.txt @@ -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 diff --git a/htdocs/json/spcoutlook.py b/htdocs/json/spcoutlook.py index 9084a78d43..3af370fb91 100644 --- a/htdocs/json/spcoutlook.py +++ b/htdocs/json/spcoutlook.py @@ -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 @@ -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") diff --git a/htdocs/plotting/auto/scripts/__init__.py b/htdocs/plotting/auto/scripts/__init__.py index 1644f8c17f..341f93400f 100644 --- a/htdocs/plotting/auto/scripts/__init__.py +++ b/htdocs/plotting/auto/scripts/__init__.py @@ -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, diff --git a/htdocs/plotting/auto/scripts100/p125.py b/htdocs/plotting/auto/scripts100/p125.py index 852920178f..cecd5f02e7 100644 --- a/htdocs/plotting/auto/scripts100/p125.py +++ b/htdocs/plotting/auto/scripts100/p125.py @@ -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 @@ -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 = {} @@ -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, @@ -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( @@ -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 diff --git a/include/database.inc.php b/include/database.inc.php index cbc04ead67..6ddb73d1e4 100644 --- a/include/database.inc.php +++ b/include/database.inc.php @@ -32,4 +32,4 @@ function iemdb($dbname, $force_new = 0, $rw = FALSE) database_failure($dbname); } return $db; -} // End of iemdb() +} diff --git a/scripts/dbutil/compute_alldata_sts.py b/scripts/dbutil/compute_alldata_sts.py index 0452e8dedb..ba4a733a29 100644 --- a/scripts/dbutil/compute_alldata_sts.py +++ b/scripts/dbutil/compute_alldata_sts.py @@ -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() diff --git a/scripts/ingestors/uscrn_ingest.py b/scripts/ingestors/uscrn_ingest.py index 299295cdc7..9b5bd14f1a 100644 --- a/scripts/ingestors/uscrn_ingest.py +++ b/scripts/ingestors/uscrn_ingest.py @@ -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: @@ -244,7 +244,7 @@ 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: @@ -252,7 +252,7 @@ def main(argv): icursor.close() ocursor.close() iem_pgconn.commit() - other_pgconn.commit() + pgconn.commit() if __name__ == "__main__": diff --git a/scripts/uscrn/compute_uscrn_pday.py b/scripts/uscrn/compute_uscrn_pday.py index 83569cf278..7fa3fd0b92 100644 --- a/scripts/uscrn/compute_uscrn_pday.py +++ b/scripts/uscrn/compute_uscrn_pday.py @@ -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),