Skip to content

Commit

Permalink
Merge pull request #1052 from akrherz/250102-2
Browse files Browse the repository at this point in the history
Omnibus
  • Loading branch information
akrherz authored Jan 3, 2025
2 parents ce57d4c + f8f3932 commit f284f7a
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 9 deletions.
12 changes: 8 additions & 4 deletions pylib/iemweb/autoplot/scripts/p14.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ def plotter(ctx: dict):

cursor.execute(
"""
with pop as (
select precip, sum(precip) OVER (ORDER by precip ASC) as rsum,
sum(precip) OVER () as tsum,
min(year) OVER () as minyear from alldata where
station = %s and precip > 0.009 and extract(doy from day) < %s and
year < extract(year from now()) ORDER by precip ASC
year < extract(year from now()) ORDER by precip ASC)
select distinct precip, rsum, tsum, minyear from pop order by precip ASC
""",
(station, jdaylimit),
)
Expand All @@ -62,24 +64,26 @@ def plotter(ctx: dict):
bins = [0.01]
minyear = None
row = None
last_precip = None
for i, row in enumerate(cursor):
if i == 0:
minyear = row["minyear"]
total = row["tsum"]
onefifth = total / 5.0
base = onefifth
last_precip = row["precip"]
if row["rsum"] > base:
bins.append(row["precip"])
base += onefifth

if len(bins) != 6:
if len(bins) != 5:
pgconn.close()
raise NoDataFound("Not enough data found.")

normal = total / float(endyear - minyear - 1)
# A rounding edge case
if row["precip"] != bins[-1]:
bins.append(row["precip"])
if last_precip != bins[-1]:
bins.append(last_precip)

df = pd.DataFrame(
{"bin": range(1, 6), "lower": bins[0:-1], "upper": bins[1:]},
Expand Down
3 changes: 2 additions & 1 deletion pylib/iemweb/autoplot/scripts/p84.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from pyiem.plot.geoplot import MapPlot
from pyiem.reference import LATLON
from pyiem.util import get_properties
from pyproj import Proj

PDICT2 = {"c": "Contour Plot", "g": "Grid Cell Mesh"}
SRCDICT = {
Expand Down Expand Up @@ -411,7 +412,7 @@ def finalize_map(ctx):
# Compute the lat/lon grid
if ctx["src"] == "stage4":
xi, yi = np.meshgrid(xpts, ypts)
lons, lats = STAGE4.crs(xi, yi)
lons, lats = Proj(STAGE4.crs)(xi, yi)
else:
lons, lats = np.meshgrid(xpts, ypts)

Expand Down
7 changes: 3 additions & 4 deletions scripts/iemre/daily_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,10 @@ def copy_iemre_hourly(ts, ds, domain):
ets = sts + timedelta(hours=23)
pairs = [(sts, ets)]
if sts.year != ets.year:
# 6z to 23z (inclusve)
# 0z to 5z (inclusive)
# These are inclusive
pairs = [
(sts, sts + timedelta(hours=17)),
(sts + timedelta(hours=18), ets),
(sts, sts.replace(hour=23)),
(ets.replace(hour=0), ets),
]
ets = utc(ts.year, ts.month, ts.day, 12)
# 13z yesterday
Expand Down
13 changes: 13 additions & 0 deletions tests/iemweb/autoplot/test_extweb_failures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Test autoplots that call external services."""

from iemweb.autoplot.autoplot import application
from pytest_httpx import HTTPXMock
from werkzeug.test import Client


def test_ap17(httpx_mock: HTTPXMock):
"""Test a failure found in prod."""
httpx_mock.add_response(status_code=404)
c = Client(application)
res = c.get("?p=17")
assert res.status_code == 400
1 change: 1 addition & 0 deletions tests/iemweb/autoplot/urllist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
/plotting/auto/plot/84/sector:IA::network:WFO::src:prism::opt:acc::usdm:no::ptype:g::sdate:2024-08-13::edate:2024-08-13::cmap:YlGnBu::_r:t::dpi:100.png
/plotting/auto/plot/84/sector:IA::network:WFO::src:iemre::opt:acc::usdm:no::ptype:g::sdate:2024-08-13::edate:2024-08-13::cmap:YlGnBu::_r:t::dpi:100.png
/plotting/auto/plot/84/sector:IA::network:WFO::src:ifc::opt:acc::usdm:no::ptype:g::sdate:2024-01-01::edate:2024-01-02::cmap:YlGnBu::_r:t::dpi:100.png
/plotting/auto/plot/84/sector:MN::network:WFO::src:stage4::opt:acc::usdm:no::ptype:c::sdate:2024-01-01::edate:2024-01-01::clip:yes::cmap:YlGnBu::_r:t::dpi:100.png
/plotting/auto/plot/86/csector:AK::var:wind_speed::ptype:c::date:2024-01-01::cmap:magma::_r:t::dpi:100.png
/plotting/auto/plot/86/csector:IN::var:wind_speed::ptype:c::date:2024-01-01::cmap:magma::_r:t::dpi:100.png
/plotting/auto/plot/86/domain:europe::csector:IN::var:rsds::ptype:c::date:2024-01-01::cmap:magma::_r:t::dpi:100.png
Expand Down
11 changes: 11 additions & 0 deletions tests/iemweb/geojson/test_sbw.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""Test geojson/sbw.py service."""

from iemweb.geojson.sbw import application
from werkzeug.test import Client


def test_250102_ts_not_working():
"""Test a failure found in prod."""
c = Client(application)
res = c.get("?ts=2024-05-21T20:00:00Z")
assert res.json["features"]

0 comments on commit f284f7a

Please sign in to comment.