Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omnibus #1026

Merged
merged 5 commits into from
Dec 13, 2024
Merged

Omnibus #1026

Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.2"
rev: "v0.8.3"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
35 changes: 2 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,5 @@ Limited integration testing is done on Github Actions: [![Build Status](https://
[![DeepSource](https://app.deepsource.com/gh/akrherz/iem.svg/?label=active+issues&show_trend=true&token=WvZunVBligt7HgkO2JGg5uMe)](https://app.deepsource.com/gh/akrherz/iem/)
[![codecov](https://codecov.io/gh/akrherz/iem/graph/badge.svg?token=zKXnLZdxIk)](https://codecov.io/gh/akrherz/iem)

Database schema is in [akrherz/iem-database](https://github.com/akrherz/iem-database).

## Where are processes running

The processing load for the IEM is spread over a number of virtual machines.
This is an attempt to document what is running where. The backup shown may not
be automated, but another system that could be up and running the service in
limited time.

Process | Primary | Backup | Monitor
------- | ------- | ------ | -------
GOES R/S | iem8-dc | iem19 | None
hrrr | iem8-dc | None | None
iembot | iem11-dc | None | nagios
iemdb1 | metvm33-dc | iemvm4 | nagios check
iemdb2 | metvm4-dc | iemvm5 | nagios check
iemdb3 | metvm2-dc | iemvm0 | nagios check
iem-archive | metvm6-dc | iemvm6 | nagios
iem-web-services | iem27-dc | iem11-dc | nagios check
letsencrpyt | iem8-dc | None | nagios SSL check
LDM | iem11 | None | None
LoggerNet | iem8-dc | None | nagios check
memcached | metvm0-dc | iem8-dc | nagios check
NEXRAD Mosaics | iem8-dc | iem16 | nagios checks archive
NWWS-OI Ingest | iem12 | None | None
openfire | iem11-dc | None | None
rabbitmq | iem9-dc | iem8-dc | nagios check
samba | iem16 | None | cron scripts check data availability
RIDGE | iem9-dc | None | inbound file queue, check latency 7 radars
webalizer | iem8-dc | None | None
webcam haproxy | iem19 | iem12 | nagios
Webcam Current | iem19 | None | cron script monitors for offline webcams
Webcam Lapses | iem19 | None | None
See [@akrherz Github Profile](https://github.com/akrherz) for an overview of
repositories found here and how the fit together.
1 change: 1 addition & 0 deletions htdocs/docs/nexrad_mosaic/index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require_once "../../../config/settings.inc.php";
require_once "../../../include/myview.php";
$t = new MyView();
$t->iem_resource = "MOSAIC";
$t->title = "About NEXRAD Mosaics";
$d = date("Y/m/d");
$t->content = <<<EOF
Expand Down
6 changes: 3 additions & 3 deletions htdocs/schoolnet/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<h3>SchoolNet</h3>

<p>Over the years, the IEM partnered with
<a href="http://www.kcci.com/">KCCI-TV</a> (Des Moines, IA),
<a href="http://www.keloland.com">KELO-TV</a> (Sioux Falls, SD),
and <a href="http://www.kimt.com">KIMT-TV</a> (Mason City, IA) to collect data
<a href="https://www.kcci.com/">KCCI-TV</a> (Des Moines, IA),
<a href="https://www.keloland.com">KELO-TV</a> (Sioux Falls, SD),
and <a href="https://www.kimt.com">KIMT-TV</a> (Mason City, IA) to collect data
from their respective school-based weather stations. Sadly, the observation
equipment fell into disrepair and the various networks were wound down or
replaced with proprietary solutions.
Expand Down
4 changes: 2 additions & 2 deletions htdocs/smos/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@
</div><div class="col-md-6">
<div id="map"></div>

</div></div>
</div></div>

<input type="submit" value="Get Data!" />

</form>
</form>

<p><h4>Recent Analysis Plots at 00 UTC</h4>
<i>Click image for archived imagery</i>
Expand Down
4 changes: 1 addition & 3 deletions htdocs/smos/smosmap.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/* global $, ol */
let controls;
let vectors;
let feature;
window.app = {};
const app = window.app;
Expand Down Expand Up @@ -121,7 +119,7 @@ app.Drag.prototype.handleMoveEvent = function (evt) {
* @param {ol.MapBrowserEvent} evt Map browser event.
* @return {boolean} `false` to stop the drag sequence.
*/
app.Drag.prototype.handleUpEvent = function (evt) {
app.Drag.prototype.handleUpEvent = function (_evt) {
const ar = ol.proj.transform(this.coordinate_, 'EPSG:3857', 'EPSG:4326');
$('#lon').val(ar[0].toFixed(4));
$('#lat').val(ar[1].toFixed(4));
Expand Down
12 changes: 6 additions & 6 deletions pylib/iemweb/autoplot/scripts/p16.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,28 +122,28 @@ def get_highcharts(ctx: dict) -> str:
series: [
{{
name: '{bins[1]} - {bins[2]}',
data: {str(list(table[:, 0]))},
data: {list(table[:, 0])},
pointInterval: 22.5,
_colorIndex: 0
}},
{{name: '{bins[2]} - {bins[3]}',
data: {str(list(table[:, 1]))},
data: {list(table[:, 1])},
pointInterval: 22.5,
_colorIndex: 1}},
{{name: '{bins[3]} - {bins[4]}',
data: {str(list(table[:, 2]))},
data: {list(table[:, 2])},
pointInterval: 22.5,
_colorIndex: 2}},
{{name: '{bins[4]} - {bins[5]}',
data: {str(list(table[:, 3]))},
data: {list(table[:, 3])},
pointInterval: 22.5,
_colorIndex: 3}},
{{name: '{bins[5]} - {bins[6]}',
data: {str(list(table[:, 4]))},
data: {list(table[:, 4])},
pointInterval: 22.5,
_colorIndex: 4}},
{{name: '{bins[6]} +',
data: {str(list(table[:, 5]))},
data: {list(table[:, 5])},
pointInterval: 22.5,
_colorIndex: 5}}
],
Expand Down
3 changes: 2 additions & 1 deletion pylib/iemweb/autoplot/scripts/p18.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def get_highcharts(ctx: dict) -> dict:
j["tooltip"] = {
"crosshairs": True,
"shared": True,
"valueSuffix": " %s" % (UNITS[ctx["var"]],),
"valueSuffix": f" {UNITS[ctx['var']]}",
}
j["legend"] = {}
j["time"] = {"useUTC": False}
Expand All @@ -103,6 +103,7 @@ def get_highcharts(ctx: dict) -> dict:
zip(
ctx["df"].ticks.values.tolist(),
ctx["df"].datum.values.tolist(),
strict=True,
)
),
"zIndex": 2,
Expand Down
10 changes: 5 additions & 5 deletions pylib/iemweb/autoplot/scripts/p3.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,25 +167,25 @@ def get_highcharts(ctx: dict) -> str:
tooltip: {{
valueDecimals: 2
}},
data: {str(ctx["data"].tolist())},
data: {ctx["data"].tolist()},
threshold: null
}}, {{
tooltip: {{valueDecimals: 2}},
name: '30 Year Trailing Avg',
pointStart: {str(ctx["df"].index.min() + (3 if ctx["decadal"] else 30))},
pointStart: {ctx["df"].index.min() + (3 if ctx["decadal"] else 30)},
pointInterval: {ptinterval},
width: 2,
data: {str(ctx["tavg"][(3 if ctx["decadal"] else 30) :])}
data: {ctx["tavg"][(3 if ctx["decadal"] else 30) :]}
}},{{
tooltip: {{
valueDecimals: 2
}},
name: 'Average',
width: 2,
pointPadding: 0.1,
pointStart: {str(ctx["df"].index.min())},
pointStart: {ctx["df"].index.min()},
pointInterval: {ptinterval},
data: {str([ctx["avgv"]] * len(ctx["df"].index))}
data: {[ctx["avgv"]] * len(ctx["df"].index)}
}}]
}});
"""
Expand Down
4 changes: 2 additions & 2 deletions pylib/iemweb/autoplot/scripts/p50.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ def plotter(fdict):
ax.set_yticks(range(-1, len(uniquehail)))
ax.set_xlim(-0.5, len(uniquewind) + 0.5)
ax.set_ylim(-1.5, len(uniquehail) - 0.5)
ax.set_xticklabels(uniquewind + ["Total"], fontsize=14)
ax.set_yticklabels(["Total"] + uniquehail, fontsize=14)
ax.set_xticklabels([*uniquewind, "Total"], fontsize=14)
ax.set_yticklabels(["Total", *uniquehail], fontsize=14)
ax.xaxis.tick_top()
ax.set_xlabel("Wind Speed [mph]", fontsize=14)
ax.set_ylabel("Hail Size [inch]", fontsize=14)
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 @@ -205,7 +205,7 @@ def get_highcharts(ctx: dict) -> str:
containername = ctx["_e"]

return f"""
var units = {repr(ctx['units'])};
var units = "{ctx['units']:%s}";
function getPointCategoryName(point, dimension) {{
var series = point.series,
isY = dimension === 'y',
Expand All @@ -226,11 +226,11 @@ def get_highcharts(ctx: dict) -> str:
min: 0,
max: 23,
title: {{
text: {repr(ctx['ylabel'])}
text: "{ctx['ylabel']:%s}"
}}
}},
title: {{
text: {repr(title)}
text: "{title:%s}"
}},
accessibility: {{
point: {{
Expand Down
2 changes: 1 addition & 1 deletion pylib/iemweb/autoplot/scripts100/p102.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def plotter(fdict):
"Local Storm Report Sources Ranks"
)
if ltype:
label = f"For LSR Types: {repr(ltype)}"
label = f"For LSR Types: {ltype:%s}"
if len(label) > 90:
label = f"{label[:90]}..."
title += f"\n{label}"
Expand Down
4 changes: 2 additions & 2 deletions pylib/iemweb/autoplot/scripts100/p119.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def plotter(fdict):
celltext[j][i] = row["dates"].strftime("%b %d")
cellcolors[j][i] = colors[row["dates"].month - 1]

ax2 = fig.add_axes([0.75, 0.1, 0.2, 0.75])
ax2 = fig.add_axes((0.75, 0.1, 0.2, 0.75))
# remove all the splines, but show the ylabel
ax2.spines["top"].set_visible(False)
ax2.spines["bottom"].set_visible(False)
Expand All @@ -259,7 +259,7 @@ def plotter(fdict):
celltext,
cellColours=cellcolors,
colLabels=[f"{t}" + r"$^\circ$F" for t in thresholds],
rowLabels=["Min"] + list(range(10, 100, 10)) + ["Max"],
rowLabels=["Min", *list(range(10, 100, 10)), "Max"],
loc="center",
)
# add some vertical padding to text in the table and keep the borders
Expand Down
10 changes: 6 additions & 4 deletions pylib/iemweb/autoplot/scripts100/p151.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,15 @@ def get_data(ctx):
p2eyear = ctx["p2eyear"]
p2years = p2eyear - p2syear + 1

datumsql = "year"
if month != "custom":
mlimiter = "and month = ANY(:months)" if month != "all" else ""
months = month2months(month)
else:
mlimiter = "and sday >= :sday and sday <= :eday"
if sday > eday:
mlimiter = "and (sday >= :sday or sday <= :eday)"
datumsql = "case when sday >= :sday then year + 1 else year end"
months = None
table = "alldata"
if sector == "state":
Expand Down Expand Up @@ -255,15 +257,15 @@ def get_data(ctx):
text(
f"""
WITH period1 as (
SELECT station, year,
SELECT station, {datumsql} as datum,
{sqlopts[ctx['var']]} as {ctx['var']}
from {table} WHERE year >= :syear1 and year <= :eyear1
{mlimiter} GROUP by station, year),
{mlimiter} GROUP by station, datum),
period2 as (
SELECT station, year,
SELECT station, {datumsql} as datum,
{sqlopts[ctx['var']]} as {ctx['var']}
from {table} WHERE year >= :syear2 and year <= :eyear2
{mlimiter} GROUP by station, year),
{mlimiter} GROUP by station, datum),
p1agg as (
SELECT station,
avg({ctx['var']}) as {ctx['var']}, count(*) as count
Expand Down
2 changes: 1 addition & 1 deletion pylib/iemweb/current/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def workflow(cid):
return res
try:
res = fetch(cid)
except Exception: # noqa
except Exception:
return None
if res is not None:
# Set for 15 seconds
Expand Down
5 changes: 3 additions & 2 deletions pylib/iemweb/projects/iembot/mastodon/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
import mastodon
import requests
from paste.request import get_cookie_dict
from pyiem.database import get_dbconnc
from pyiem.templates.iem import TEMPLATE
from pyiem.util import get_dbconnc, get_properties
from pyiem.util import get_properties
from pyiem.webutil import iemapp

PRIVKEY = get_properties().get("mod_wsgi.privkey", "")
Expand Down Expand Up @@ -124,7 +125,7 @@ def build_subui(mapp, fdict):
"""Show the subscriptions."""
me = mapp.me()
res = f"""
<p>Hi <a href="{me['url']}">@{str(me['username'])}</a>
<p>Hi <a href="{me['url']}">@{me['username']:%s}</a>
<img src="{me['avatar']}" style="width:20px;">!
This page configures your IEMBot channel subscriptions.</p>
"""
Expand Down
48 changes: 24 additions & 24 deletions pylib/iemweb/request/grx/iadot_trucks.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
"""
Placefile for DOT trucks and webcam images
"""
""".. title:: Iowa DOT Trucks for GRLevelX

This script generates a GRLevelX compatible text file for the Iowa DOT Trucks
service.

import datetime
Example Requests:

from pyiem.util import get_dbconn
from pymemcache.client import Client
Get the current Iowa DOT Trucks data:

https://mesonet.agron.iastate.edu/request/grx/iadot_trucks.txt

"""

from pyiem.database import get_dbconn
from pyiem.util import utc
from pyiem.webutil import iemapp

URLBASE = "https://mesonet.agron.iastate.edu/data/camera/idot_trucks"
ARROWS = "https://mesonet.agron.iastate.edu/request/grx/arrows.png"
Expand All @@ -14,17 +22,13 @@
def produce_content():
"""Generate content"""

res = """Title: Iowa DOT Trucks @%sZ
res = f"""Title: Iowa DOT Trucks @{utc():%H%M}Z
Refresh: 5
Color: 200 200 255
IconFile: 1, 15, 25, 8, 25, "%s"
IconFile: 1, 15, 25, 8, 25, "{ARROWS}"
Font: 1, 11, 1, "Courier New"

""" % (
datetime.datetime.utcnow().strftime("%H%M"),
ARROWS,
)

"""
pgconn = get_dbconn("postgis")
cursor = pgconn.cursor()

Expand Down Expand Up @@ -60,17 +64,13 @@ def produce_content():
return res


@iemapp(
help=__doc__,
content_type="text/plain",
memcacheexpire=300,
memcachekey="/request/grx/iadot_trucks.txt",
)
def application(_environ, start_response):
"""Go Main Go"""
start_response("200 OK", [("Content-type", "text/plain")])

mckey = "/request/grx/iadot_trucks.txt"
mc = Client("iem-memcached:11211")
res = mc.get(mckey)
if not res:
res = produce_content()
mc.set(mckey, res, 300)
else:
res = res.decode("utf-8")
mc.close()
return [res.encode("ascii")]
return produce_content()
2 changes: 1 addition & 1 deletion pylib/iemweb/request/tempwind_aloft.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Schema(CGIModel):
"UTC",
description=(
"The timezone to use for timestamps in request and response, it "
"should be something recognized by the pytz library."
"should be something recognized by the ZoneInfo library."
),
)
year1: int = Field(
Expand Down
Loading
Loading