Skip to content

Commit

Permalink
Merge pull request #563 from akrherz/231025-2
Browse files Browse the repository at this point in the history
Omnibus
  • Loading branch information
akrherz authored Oct 26, 2023
2 parents 3972db2 + 3de8ec8 commit 91a51bc
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 42 deletions.
4 changes: 2 additions & 2 deletions cgi-bin/request/coop.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,8 +697,8 @@ def do_swat(ctx):
f"""
WITH scenario as (
SELECT
('{thisyear}-'||month||'-'||extract(day from day))::date as day,
high, low, precip, station from {table}
('{thisyear}-'||month||'-'||extract(day from day))::date
as day, high, low, precip, station from {table}
WHERE station = ANY(:sids) and
day >= :asts and year = :scenario_year),
obs as (
Expand Down
7 changes: 5 additions & 2 deletions htdocs/iemre/multiday.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ def application(environ, start_response):
"""Go Main Go"""
if "date1" not in environ:
raise IncompleteWebRequest("GET date1= parameter missing")
ts1 = datetime.datetime.strptime(environ.get("date1"), "%Y-%m-%d")
ts2 = datetime.datetime.strptime(environ.get("date2"), "%Y-%m-%d")
try:
ts1 = datetime.datetime.strptime(environ.get("date1"), "%Y-%m-%d")
ts2 = datetime.datetime.strptime(environ.get("date2"), "%Y-%m-%d")
except ValueError:
raise IncompleteWebRequest("Invalid date(s) provided")
if ts1 > ts2:
(ts1, ts2) = (ts2, ts1)
if ts1.year != ts2.year:
Expand Down
3 changes: 2 additions & 1 deletion htdocs/plotting/auto/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ def map_select_widget(network, name):
return f"""
&nbsp; <button type="button" id="button_{network}_{name}" data-state="0"
onClick="mapFactory('{network}', '{name}');">Show Map</button>
<div style="display: none; width: 100%; height: 640px;" id="map_{network}_{name}_wrap">
<div style="display: none; width: 100%; height: 640px;"
id="map_{network}_{name}_wrap">
<br />Click dot to select in form above. <strong>Key</strong>
<img src="/images/green_dot.svg" style="height: 15px;"> Online &nbsp;
<img src="/images/red_dot.svg" style="height: 15px;"> Offline<br />
Expand Down
4 changes: 2 additions & 2 deletions htdocs/plotting/auto/scripts/p59.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ 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 filter "
f"applied, {len(ctx['df'].index):.0f} obs found"
f"[{ctx['ab'].year}-{datetime.datetime.now().year}] 7 day smooth "
f"filter applied, {len(ctx['df'].index):.0f} obs found"
)
ctx["fig"] = figure(apctx=ctx, title=title)
axes = ctx["fig"].subplots(2, 1)
Expand Down
14 changes: 11 additions & 3 deletions htdocs/plotting/auto/scripts/p99.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ def plotter(fdict):
df = pd.read_sql(
"""
WITH days as (
select generate_series('%s-01-01'::date, '%s-12-31'::date,
select generate_series(%s, %s,
'1 day'::interval)::date as day,
to_char(generate_series('%s-01-01'::date, '%s-12-31'::date,
to_char(generate_series(%s, %s,
'1 day'::interval)::date, 'mmdd') as sday
),
climo as (
Expand All @@ -78,7 +78,15 @@ def plotter(fdict):
(t.sday = c.sday) ORDER by t.day ASC
""",
conn,
params=(year, year, year, year, station, station, year),
params=(
datetime.date(year, 1, 1),
datetime.date(year, 12, 31),
datetime.date(year, 1, 1),
datetime.date(year, 12, 31),
station,
station,
year,
),
index_col="day",
)
if df.empty or df["stddev_high"].min() == 0:
Expand Down
9 changes: 6 additions & 3 deletions htdocs/plotting/auto/scripts100/p147.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,14 @@ def plotter(fdict):
alldata WHERE station = %s)
SELECT extract(doy from o.day) as doy, count(*),
sum(case when o.high >= (t.high::numeric + %s) then 1 else 0 end) as high_hits,
sum(case when o.low >= (t.low::numeric + %s) then 1 else 0 end) as low_hits,
sum(case when o.high >= (t.high::numeric + %s) then 1 else 0 end)
as high_hits,
sum(case when o.low >= (t.low::numeric + %s) then 1 else 0 end)
as low_hits,
sum(case when o.precip >= (t.precip + %s) then 1 else 0 end)
as precip_hits,
sum(case when o.avgt >= (t.avgt::numeric + %s) then 1 else 0 end) as avgt_hits
sum(case when o.avgt >= (t.avgt::numeric + %s) then 1 else 0 end)
as avgt_hits
from obs1 o JOIN obs2 t on (o.day = t.day) GROUP by doy
ORDER by doy ASC
""",
Expand Down
50 changes: 23 additions & 27 deletions htdocs/plotting/auto/scripts100/p170.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
"""METAR frequency"""
"""
This chart totals the number of distinct calendar
days or hours per month that a given present weather condition is reported
within the METAR data feed. The calendar day is computed for the local time
zone of the reporting station.
<p>The reporting of present weather codes within METARs has changed over
the years and there is some non-standard nomenclature used by some sites.
The thunder (TS) reports are delineated into three categories here to
hopefully allow more accurate statistics.
<ul>
<li><strong>All Thunder Reports (TS)</strong> includes any
<code>TS</code> mention in any present weather code</li>
<li><strong>Thunder in Vicinity (VCTS)</strong> includes any
<code>VCTS</code> mention in any present weather code, for example,
<code>VCTSRA</code> would match.</li>
<li><strong>Thunder Reports (excluding VCTS)</strong> includes most
<code>TS</code> mentions, but not any including <code>VC</code></li>
</ul></p>
<p>This autoplot considers both routine and special hourly reports.
"""
import calendar
import datetime

Expand Down Expand Up @@ -31,32 +52,7 @@

def get_description():
"""Return a dict describing how to call this plotter"""
desc = {}
desc["data"] = True
desc["cache"] = 86400
desc[
"description"
] = """This chart totals the number of distinct calendar
days or hours per month that a given present weather condition is reported within
the METAR data feed. The calendar day is computed for the local time zone
of the reporting station.
<p>The reporting of present weather codes within METARs has changed over
the years and there is some non-standard nomenclature used by some sites.
The thunder (TS) reports are delineated into three categories here to
hopefully allow more accurate statistics.
<ul>
<li><strong>All Thunder Reports (TS)</strong> includes any
<code>TS</code> mention in any present weather code</li>
<li><strong>Thunder in Vicinity (VCTS)</strong> includes any
<code>VCTS</code> mention in any present weather code, for example,
<code>VCTSRA</code> would match.</li>
<li><strong>Thunder Reports (excluding VCTS)</strong> includes most
<code>TS</code> mentions, but not any including <code>VC</code></li>
</ul></p>
<p>This autoplot considers both routine and special hourly reports.
"""
desc = {"description": __doc__, "data": True, "cache": 86400}
desc["arguments"] = [
dict(
type="zstation",
Expand Down
4 changes: 2 additions & 2 deletions htdocs/projects/iembot/mastodon/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
<h3>Highly Experimental IEMBot to Mastodon Configuration:</h3>
<div class="alert alert-danger">There are absolutely no warranties with this service.
Use at your own risk and peril!</div>
<div class="alert alert-danger">There are absolutely no warranties with this
service. Use at your own risk and peril!</div>
"""
ENTER_HOST_FORM = """
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
line-length = 79

[tool.ruff]
line-length = 79
select = ["E", "F", "I"]
target-version = "py39"

0 comments on commit 91a51bc

Please sign in to comment.