Skip to content

Commit

Permalink
Merge pull request #1061 from akrherz/250108-2
Browse files Browse the repository at this point in the history
Omnibus
  • Loading branch information
akrherz authored Jan 9, 2025
2 parents 82c9d07 + 8a327b3 commit 9ce37b7
Show file tree
Hide file tree
Showing 77 changed files with 170 additions and 217 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
hooks:
- id: eslint
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.8.6"
rev: "v0.9.0"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
21 changes: 8 additions & 13 deletions pylib/iemweb/autoplot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def import_script(p: int):
{
"id": 11,
"label": (
"ASOS Daily Min/Max Dew Point/Temp/Feels Like/RH " "for a Year"
"ASOS Daily Min/Max Dew Point/Temp/Feels Like/RH for a Year"
),
},
{"id": 94, "label": "Bias of 24 Hour High+Low Computation by Hour"},
Expand Down Expand Up @@ -407,7 +407,7 @@ def import_script(p: int):
{
"id": 95,
"label": (
"Monthly Precip/Temperature with " "El Nino SOI Index Relationship"
"Monthly Precip/Temperature with El Nino SOI Index Relationship"
),
},
{
Expand All @@ -431,7 +431,7 @@ def import_script(p: int):
{
"id": 58,
"label": (
"One Day's Precip Greater than X percentage " "of Monthly Total"
"One Day's Precip Greater than X percentage of Monthly Total"
),
},
{
Expand Down Expand Up @@ -495,15 +495,13 @@ def import_script(p: int):
{
"id": 12,
"label": (
"Days per year and first/latest date "
"above/below given threshold"
"Days per year and first/latest date above/below given threshold"
),
},
{
"id": 184,
"label": (
"Days per year with High Temperature "
"above temperature thresholds"
"Days per year with High Temperature above temperature thresholds"
),
},
{
Expand Down Expand Up @@ -862,8 +860,7 @@ def import_script(p: int):
{
"id": 201,
"label": (
"SPC Convective/Fire Wx or "
"WPC Excessive Rainfall Outlook Calendar"
"SPC Convective/Fire Wx or WPC Excessive Rainfall Outlook Calendar"
),
},
{
Expand All @@ -884,15 +881,13 @@ def import_script(p: int):
{
"id": 143,
"label": (
"Special Weather Statements (SPS) "
"Polygon Count by Year by Month"
"Special Weather Statements (SPS) Polygon Count by Year by Month"
),
},
{
"id": 233,
"label": (
"Special Weather Statements (SPS) "
"Polygon Calendar of Daily Counts"
"Special Weather Statements (SPS) Polygon Calendar of Daily Counts"
),
},
{
Expand Down
51 changes: 24 additions & 27 deletions pylib/iemweb/autoplot/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def cmap_handler(fdict, value, arg, res):
)
checked = ' checked="checked"' if reverse_on else ""
s += (
f"&nbsp; <input type=\"checkbox\" name=\"{arg['name']}_r\" "
f'&nbsp; <input type="checkbox" name="{arg["name"]}_r" '
f'value="on"{checked}> Reverse Colormap?'
)
res["pltvars"].append(f"{arg['name']}:{value}{'_r' if reverse_on else ''}")
Expand Down Expand Up @@ -351,8 +351,7 @@ def date_handler(value, arg, res):
);
"""
return (
f"<input type=\"text\" name=\"{arg['name']}\" id=\"{dpname}\" "
"> (YYYY/mm/dd)"
f'<input type="text" name="{arg["name"]}" id="{dpname}" > (YYYY/mm/dd)'
)


Expand All @@ -368,10 +367,10 @@ def datetime_handler(value, arg, res):
allowInput: true,
defaultDate: moment('{value}', 'YYYY/MM/DD HHmm').toDate(),
maxDate: moment('{vmax}', 'YYYY/MM/DD HHmm').toDate(),
minDate: moment('{arg['min']}', 'YYYY/MM/DD HHmm').toDate()}});
minDate: moment('{arg["min"]}', 'YYYY/MM/DD HHmm').toDate()}});
"""
return (
f"<input type=\"text\" name=\"{arg['name']}\" id=\"{dpname}\" "
f'<input type="text" name="{arg["name"]}" id="{dpname}" '
"> (YYYY/mm/dd HH24MI)"
)

Expand Down Expand Up @@ -488,7 +487,7 @@ def dat_handler(fdict, res):
_globalid = feat["attributes"]["globalid"]
ss += (
f'<option value="{_globalid}" '
f'{"selected=" if _globalid == gid else ""}>'
f"{'selected=' if _globalid == gid else ''}>"
f"{compute_dat_label(feat['attributes'])} </option>\n"
)
ss += "</select>"
Expand All @@ -507,9 +506,7 @@ def dat_handler(fdict, res):
'setDate', new Date('{dt}')
);
"""
return (
'<input type="text" name="dat" id="dat"> (YYYY/mm/dd) &nbsp; ' f"{ss}"
)
return f'<input type="text" name="dat" id="dat"> (YYYY/mm/dd) &nbsp; {ss}'


def generate_form(apid, fdict, headers, cookies):
Expand Down Expand Up @@ -597,7 +594,7 @@ def generate_form(apid, fdict, headers, cookies):
form = make_select(arg["name"], value, FEMA_REGIONS)
elif arg["type"] in ["text", "int", "float"]:
form = (
f"<input type=\"text\" name=\"{arg['name']}\" size=\"60\" "
f'<input type="text" name="{arg["name"]}" size="60" '
f'value="{value}">'
)
elif arg["type"] in ["month", "zhour", "hour", "day", "year"]:
Expand Down Expand Up @@ -663,7 +660,7 @@ def generate_form(apid, fdict, headers, cookies):
</script>
<script src="/vendor/highcharts/{HIGHCHARTS}/modules/exporting.js"></script>
<script src="/vendor/highcharts/{HIGHCHARTS}/modules/heatmap.js"></script>
<script src="{res['imguri']}.js"></script>
<script src="{res["imguri"]}.js"></script>
"""
elif fmt == "maptable":
res["image"] = (
Expand Down Expand Up @@ -702,7 +699,7 @@ def generate_form(apid, fdict, headers, cookies):
</div>
</div>
<br clear="all" />
<img src="{res['imguri']}.{fmt}" class="img img-responsive"
<img src="{res["imguri"]}.{fmt}" class="img img-responsive"
id="theimage" />
"""
res["jsextra"] += f"""
Expand All @@ -719,9 +716,9 @@ def generate_form(apid, fdict, headers, cookies):
"""
elif fmt == "pdf":
res["image"] = f"""
<object id="windrose-plot" src="{res['imguri']}.{fmt}" width="700px"
<object id="windrose-plot" src="{res["imguri"]}.{fmt}" width="700px"
height="700px">
<embed src="{res['imguri']}.{fmt}" width="700px" height="700px">
<embed src="{res["imguri"]}.{fmt}" width="700px" height="700px">
</embed>
</object>
"""
Expand Down Expand Up @@ -798,28 +795,28 @@ def generate_form(apid, fdict, headers, cookies):
<button type="submit" name="_cb" value="1">
Force Updated Plot (no caching)</button>
</form>
{res['nassmsg']}
{res["nassmsg"]}
"""
if meta.get("report"):
res["dataextra"] = f"""
<a href="{res['imguri']}.txt" class="btn btn-primary">
<a href="{res["imguri"]}.txt" class="btn btn-primary">
<i class="fa fa-table"></i> Direct/Stable Link to Text</a> &nbsp;
"""
if meta.get("data"):
res["dataextra"] += f"""
<a href="{res['imguri']}.csv" class="btn btn-primary">
<a href="{res["imguri"]}.csv" class="btn btn-primary">
<i class="fa fa-table"></i> View Data (as csv)</a> &nbsp;
<a href="{res['imguri']}.xlsx" class="btn btn-primary">
<a href="{res["imguri"]}.xlsx" class="btn btn-primary">
<i class="fa fa-table"></i> Download as Excel</a> &nbsp;
"""
if meta["maptable"]:
res["dataextra"] += f"""
<a href="{res['imguri']}.geojson" class="btn btn-primary">
<a href="{res["imguri"]}.geojson" class="btn btn-primary">
<i class="fa fa-map"></i> Download as GeoJSON</a> &nbsp;
"""
if meta.get("raster"):
res["dataextra"] += f"""
<a href="{res['imguri']}.geotiff" class="btn btn-primary">
<a href="{res["imguri"]}.geotiff" class="btn btn-primary">
<i class="fa fa-map"></i> Download as GeoTIFF</a> &nbsp;
"""
res["issues"] = """
Expand Down Expand Up @@ -877,11 +874,11 @@ def generate_autoplot_list(apid):
"""The select list of available autoplots."""
s = '<select name="q" class="iemselect2" data-width="100%">\n'
for entry in autoplot_data["plots"]:
s += f"<optgroup label=\"{entry['label']}\">\n"
s += f'<optgroup label="{entry["label"]}">\n'
for opt in entry["options"]:
selected = ' selected="selected"' if opt["id"] == apid else ""
s += (
f"<option value=\"{opt['id']}\"{selected}>{opt['label']} "
f'<option value="{opt["id"]}"{selected}>{opt["label"]} '
f"(#{opt['id']})</option>\n"
)
s += "</optgroup>\n"
Expand Down Expand Up @@ -909,7 +906,7 @@ def generate_trending():
label = opt["label"]
break
res += (
f"<tr><td><a href=\"/plotting/auto/?q={entry['appid']}\">"
f'<tr><td><a href="/plotting/auto/?q={entry["appid"]}">'
f"#{entry['appid']}. {label}</a></td><td>{entry['count']:,}"
"</td></tr>\n"
)
Expand Down Expand Up @@ -978,7 +975,7 @@ def generate(fdict, headers, cookies):
{res["formhtml"]}
{res['description']}
{res["description"]}
<hr>
Expand All @@ -1004,15 +1001,15 @@ def generate(fdict, headers, cookies):
<script src="/vendor/openlayers/{OPENLAYERS}/ol.js" type="text/javascript">
</script>
<script src='/vendor/openlayers/{OPENLAYERS}/ol-layerswitcher.js'></script>
{res['extrascripts']}
{res["extrascripts"]}
<script src="js/mapselect.js?v=2"></script>
<script>
function hideImageLoad(){{
// console.log("load() fired...");
$('#willload').css('display', 'none');
}}
$(document).ready(function(){{
{res['jsextra']}
{res["jsextra"]}
$('.optcontrol').change(function(){{
if (this.checked){{
$("#"+ this.name).css('display', 'block');
Expand Down Expand Up @@ -1056,7 +1053,7 @@ def generate(fdict, headers, cookies):
.cmapselect{{
width: 400px; }}
</style>
{res['headextra']}
{res["headextra"]}
""",
}

Expand Down
3 changes: 1 addition & 2 deletions pylib/iemweb/autoplot/scripts/p11.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ def get_description():
name="emphasis",
default="-99",
label=(
"Temperature(&deg;F) or RH(%) Line "
"of Emphasis (-99 disables):"
"Temperature(&deg;F) or RH(%) Line of Emphasis (-99 disables):"
),
),
dict(
Expand Down
5 changes: 1 addition & 4 deletions pylib/iemweb/autoplot/scripts/p12.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,7 @@ def plotter(ctx: dict):
ax.text(
0.01,
0.99,
(
"%s year(s) failed threshold %s\nAvg Date: %s\n"
"Avg Count: %.1f days"
)
("%s year(s) failed threshold %s\nAvg Date: %s\nAvg Count: %.1f days")
% (
len(zeros),
("[" + ",".join([str(z) for z in zeros]) + "]")
Expand Down
2 changes: 1 addition & 1 deletion pylib/iemweb/autoplot/scripts/p13.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def plotter(ctx: dict):
0.03,
(
f"Avg Date: {avgd:%-d %b}, "
f"slope: {h_slope * 100.:.2f} days/century, "
f"slope: {h_slope * 100.0:.2f} days/century, "
f"R$^2$={r_value**2:.2f}"
),
transform=ax.transAxes,
Expand Down
2 changes: 1 addition & 1 deletion pylib/iemweb/autoplot/scripts/p14.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def plotter(ctx: dict):
0.5,
-0.05,
"Precipitation Bins [inch], split into equal 20%"
f" by rain volume ({(normal / 5.):.2f}in) over period of record",
f" by rain volume ({(normal / 5.0):.2f}in) over period of record",
transform=ax.transAxes,
va="top",
ha="center",
Expand Down
2 changes: 1 addition & 1 deletion pylib/iemweb/autoplot/scripts/p2.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def plotter(ctx: dict):
ax.plot(
[-4, 4],
[y1, y2],
label=f"Slope={h_slope:.2f} R$^2$={(r_value ** 2):.2f}",
label=f"Slope={h_slope:.2f} R$^2$={(r_value**2):.2f}",
)
xmax = df.gdd_sigma.abs().max() + 0.25
ymax = df.precip_sigma.abs().max() + 0.25
Expand Down
2 changes: 1 addition & 1 deletion pylib/iemweb/autoplot/scripts/p26.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def add_ctx(ctx):
title = "Year to Date Maximum Daily %s Temperature"
title = title % (varname.capitalize(),)
ctx["ylabel"] = title
ctx["title"] = f"{startyear}-{thisyear - 1} {ctx['_sname']}\n" f"{title}"
ctx["title"] = f"{startyear}-{thisyear - 1} {ctx['_sname']}\n{title}"
return ctx


Expand Down
2 changes: 1 addition & 1 deletion pylib/iemweb/autoplot/scripts/p30.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def plotter(ctx: dict):
df["rng"] = df["max_high"] - df["min_low"]

tt = calendar.month_name[month] if ctx["opt"] == "monthly" else "Yearly"
title = f"{ctx['_sname']}\n" f"{tt} Temperature Range (Max High - Min Low)"
title = f"{ctx['_sname']}\n{tt} Temperature Range (Max High - Min Low)"
fig = figure(title=title, apctx=ctx)
ax = fig.subplots(3, 1, sharex=True)
ax[0].scatter(df.index.values, df["max_high"].values)
Expand Down
2 changes: 1 addition & 1 deletion pylib/iemweb/autoplot/scripts/p39.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def compute_compare_month(ctx, cursor):
where station = %s and month = %s and year != %s
and high is not null and low is not null
GROUP by year
ORDER by avg {'desc' if compare == 'high' else 'asc'} LIMIT 1
ORDER by avg {"desc" if compare == "high" else "asc"} LIMIT 1
""",
(station, effective_date.month, effective_date.year),
)
Expand Down
2 changes: 1 addition & 1 deletion pylib/iemweb/autoplot/scripts/p42.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def plotter(ctx: dict):
label += (
f" {sts.strftime('%m/%d/%y %I:%M %p')} "
f"{ets.strftime('%m/%d/%y %I:%M %p')} "
f"{line.interval.total_seconds() / 3600.:4.0f}\n"
f"{line.interval.total_seconds() / 3600.0:4.0f}\n"
)
label += tzname
fig.text(0.99, 0.9, label, ha="right", va="top", fontsize=10)
Expand Down
2 changes: 1 addition & 1 deletion pylib/iemweb/autoplot/scripts/p5.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def plotter(ctx: dict):
if ctx["_nt"].sts[station]["archive_begin"] is not None:
syear = ctx["_nt"].sts[station]["archive_begin"].year
eyear = utc().year
title = f"{ctx['_sname']} ({syear}-{eyear})\n" f"{PDICT[varname]} by Month"
title = f"{ctx['_sname']} ({syear}-{eyear})\n{PDICT[varname]} by Month"

fig = figure(title=title, apctx=ctx)

Expand Down
2 changes: 1 addition & 1 deletion pylib/iemweb/autoplot/scripts/p56.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def compute_plot_climo(ax, df):
left + (weeks * 7) / 2.0,
ymax * 1.1,
f"{weeks} Weeks\n"
f"{rolsum.max() / df['count'].sum() * 100.:.0f}% Events",
f"{rolsum.max() / df['count'].sum() * 100.0:.0f}% Events",
ha="center",
va="center",
)
Expand Down
6 changes: 3 additions & 3 deletions pylib/iemweb/autoplot/scripts/p60.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def get_highcharts(ctx: dict) -> str:
containername = ctx["_e"]

return f"""
var units = "{ctx['units']}";
var units = "{ctx["units"]}";
function getPointCategoryName(point, dimension) {{
var series = point.series,
isY = dimension === 'y',
Expand All @@ -225,7 +225,7 @@ def get_highcharts(ctx: dict) -> str:
min: 0,
max: 23,
title: {{
text: "{ctx['ylabel']}"
text: "{ctx["ylabel"]}"
}}
}},
title: {{
Expand All @@ -244,7 +244,7 @@ def get_highcharts(ctx: dict) -> str:
}},
colorAxis: {{
min: 0,
max: {df[ctx['w']].max() + 1},
max: {df[ctx["w"]].max() + 1},
minColor: '#FFFFFF',
maxColor: Highcharts.getOptions().colors[0]
}},
Expand Down
Loading

0 comments on commit 9ce37b7

Please sign in to comment.