Skip to content

Commit

Permalink
Merge pull request #1059 from akrherz/250108
Browse files Browse the repository at this point in the history
Omnibus
  • Loading branch information
akrherz authored Jan 8, 2025
2 parents 11ebd26 + 98df048 commit bd95f7e
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 29 deletions.
4 changes: 4 additions & 0 deletions config/navbar.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@
"title": "Daily Observations",
"url": "/request/daily.phtml"
},
{
"title": "Dataset Documentation",
"url": "/info/datasets/"
},
{
"title": "IEM Reanalysis",
"url": "/iemre/"
Expand Down
3 changes: 1 addition & 2 deletions include/generators.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ function get_website_citations($label){
<h3>Publications Citing IEM Data</h3>
<p>These are publications that have cited the usage of data from this page. This
list is not exhaustive, so please <a href="/info/contacts.php">let us know</a>
if you have a publication that should be added. Hopefully by early 2025, this
listing can be more complete.</p>
if you have a publication that should be added.</p>
<ul>
EOM;
for ($i=0; $row = pg_fetch_assoc($rs); $i++){
Expand Down
3 changes: 2 additions & 1 deletion pylib/iemweb/autoplot/scripts/p3.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ def add_ctx(ctx):
xlabel = f"Year, Max: {df[ptype].max():.2f} {df2.index.values[0]}{xx}"
df2 = df[df[ptype] == df[ptype].min()]
xx = "+" if len(df2.index) > 1 else ""
xlabel += f", Min: {df[ptype].min():.2f} {df2.index.values[0]}{xx}"
if not df2.empty:
xlabel += f", Min: {df[ptype].min():.2f} {df2.index.values[0]}{xx}"
ctx["xlabel"] = xlabel
data = df[ptype].values
ctx["data"] = data
Expand Down
15 changes: 8 additions & 7 deletions pylib/iemweb/autoplot/scripts/p57.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
"""

import calendar
import datetime
from datetime import date, timedelta

import numpy as np
import pandas as pd
from pyiem.database import get_sqlalchemy_conn
from pyiem.exceptions import NoDataFound
from pyiem.plot import figure_axes
from sqlalchemy import text

from iemweb.autoplot import ARG_STATION

Expand Down Expand Up @@ -54,22 +55,22 @@ def plotter(ctx: dict):
varname = ctx["varname"]
agg = ctx["agg"]

lastday = datetime.date.today()
lastday = date.today()
if varname == "total_precip" and agg == "max":
lastday += datetime.timedelta(days=1)
lastday += timedelta(days=1)
else:
lastday = lastday.replace(day=1)
with get_sqlalchemy_conn("coop") as conn:
df = pd.read_sql(
"""SELECT year, month, avg((high+low)/2.) as avg_temp,
text("""SELECT year, month, avg((high+low)/2.) as avg_temp,
avg(high) as avg_high_temp, avg(low) as avg_low_temp,
sum(precip) as total_precip,
sum(case when precip > 0.005 then 1 else 0 end) as rain_days
from alldata where station = %s and day < %s
from alldata where station = :station and day < :lastday
GROUP by year, month
""",
"""),
conn,
params=(station, lastday),
params={"station": station, "lastday": lastday},
)
if df.empty:
raise NoDataFound("No Data Found.")
Expand Down
4 changes: 2 additions & 2 deletions pylib/iemweb/autoplot/scripts/p59.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"""

import calendar
import datetime

import numpy as np
import pandas as pd
Expand All @@ -16,6 +15,7 @@
from pyiem.database import get_sqlalchemy_conn
from pyiem.exceptions import NoDataFound
from pyiem.plot import figure
from pyiem.util import utc
from sqlalchemy import text

PDICT = {
Expand Down Expand Up @@ -63,7 +63,7 @@ def add_plot(ctx):
"""Do plotting."""
title = (
f"{ctx['_sname']} :: Daily Average Component Wind Speed\n"
f"[{ctx['ab'].year}-{datetime.datetime.now().year}] 7 day smooth "
f"[{ctx['ab'].year}-{utc().year}] 7 day smooth "
f"filter applied, {len(ctx['df'].index):.0f} obs found"
)
ctx["fig"] = figure(apctx=ctx, title=title)
Expand Down
10 changes: 5 additions & 5 deletions pylib/iemweb/autoplot/scripts/p61.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
This plot is based off of NWS CLI sites.
"""

import datetime
from datetime import date, timedelta

import geopandas as gpd
import pandas as pd
Expand Down Expand Up @@ -44,7 +44,7 @@ def get_description():
dict(
type="date",
name="sdate",
default=datetime.date.today().strftime("%Y/%m/%d"),
default=date.today().strftime("%Y/%m/%d"),
label="Start Date:",
min="2010/01/01",
),
Expand Down Expand Up @@ -78,8 +78,8 @@ def get_data(ctx):
varname = ctx["var"]

today = ctx["sdate"]
yesterday = today - datetime.timedelta(days=1)
d180 = today - datetime.timedelta(days=180)
yesterday = today - timedelta(days=1)
d180 = today - timedelta(days=180)
with get_sqlalchemy_conn("iem") as conn:
df = pd.read_sql(
"""
Expand Down Expand Up @@ -153,7 +153,7 @@ def get_data(ctx):
df = df[pd.notnull(df["lon"])]
ctx["df"] = gpd.GeoDataFrame(
df, geometry=gpd.points_from_xy(df["lon"], df["lat"])
)
) # type: ignore
ctx["subtitle"] = (
"based on NWS CLI Sites, map approximately "
f"valid for {today:%-d %b %Y}"
Expand Down
23 changes: 12 additions & 11 deletions pylib/iemweb/autoplot/scripts/p62.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""

import copy
import datetime
from datetime import date, datetime

import matplotlib.colors as mpcolors
import numpy as np
Expand All @@ -15,6 +15,7 @@
from pyiem.exceptions import NoDataFound
from pyiem.plot import figure
from pyiem.plot.colormaps import nwssnow
from sqlalchemy import text

from iemweb.autoplot import ARG_STATION

Expand All @@ -24,7 +25,7 @@
def get_description():
"""Return a dict describing how to call this plotter"""
desc = {"description": __doc__, "data": True}
today = datetime.datetime.today()
today = datetime.today()
lyear = today.year if today.month > 8 else (today.year - 1)
desc["arguments"] = [
ARG_STATION,
Expand Down Expand Up @@ -54,22 +55,22 @@ def plotter(ctx: dict):
raise NoDataFound("Unknown station metadatab.")
syear = max([ctx["syear"], ab.year])
eyear = ctx["eyear"]
sts = datetime.date(syear, 11, 1)
ets = datetime.date(eyear + 1, 6, 1)
sts = date(syear, 11, 1)
ets = date(eyear + 1, 6, 1)

eyear = datetime.datetime.now().year
eyear = datetime.now().year
obs = np.ma.ones((eyear - syear + 1, 183), "f") * -1
with get_sqlalchemy_conn("coop") as conn:
df = pd.read_sql(
"""
text("""
SELECT year, extract(doy from day) as doy, snowd, day,
case when month < 6 then year - 1 else year end as winter_year
from alldata WHERE station = %s and
from alldata WHERE station = :station and
month in (11, 12, 1, 2, 3, 4) and snowd >= 0 and
day between %s and %s
""",
day between :sts and :ets
"""),
conn,
params=(station, sts, ets),
params={"station": station, "sts": sts, "ets": ets},
index_col="day",
)
if df.empty:
Expand All @@ -86,7 +87,7 @@ def plotter(ctx: dict):
f"{ctx['_sname']}\n" f"Daily Snow Depth ({minyear}-{eyear}) [inches]"
)
fig = figure(apctx=ctx, title=title)
ax = fig.add_axes([0.1, 0.1, 0.93, 0.8])
ax = fig.add_axes((0.1, 0.1, 0.93, 0.8))
ax.set_xticks((0, 29, 60, 91, 120, 151, 181))
ax.set_xticklabels(
["Nov 1", "Dec 1", "Jan 1", "Feb 1", "Mar 1", "Apr 1", "May 1"]
Expand Down
10 changes: 9 additions & 1 deletion pylib/iemweb/autoplot/scripts200/p200.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,13 @@ def get_description():
options=PDICT2,
label="Which metric to plot?",
),
{
"type": "date",
"name": "sdate",
"label": "Limit plot to start date (2002 is start):",
"min": "2002/01/01",
"default": "2002/01/01",
},
dict(
optional=True,
type="date",
Expand Down Expand Up @@ -267,6 +274,7 @@ def get_raster(ctx: dict):
"t": level.split(".", 1)[1],
"cat": level.split(".")[0],
"months": months,
"sdate": ctx["sdate"],
"edate": ctx.get("edate", utc() + timedelta(days=2)),
"west": GRIDWEST,
"south": GRIDSOUTH,
Expand All @@ -291,7 +299,7 @@ def get_raster(ctx: dict):
ST_Intersects(geom,
ST_MakeEnvelope(:west, :south, :east, :north, 4326))
and extract(month from issue) = ANY(:months)
and product_issue > '2002-01-01' and
and product_issue > :sdate and
product_issue < :edate
GROUP by expire ORDER by min_issue ASC
"""
Expand Down

0 comments on commit bd95f7e

Please sign in to comment.