Skip to content

Commit

Permalink
mnt: sundry updates
Browse files Browse the repository at this point in the history
  • Loading branch information
akrherz committed Dec 28, 2023
1 parent 184742a commit d8ae60f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 27 deletions.
10 changes: 4 additions & 6 deletions htdocs/geojson/cf6.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import simplejson as json
from pyiem.reference import TRACE_VALUE
from pyiem.util import get_dbconnc, html_escape
from pyiem.util import html_escape
from pyiem.webutil import iemapp
from pymemcache.client import Client
from simplejson import encoder
Expand Down Expand Up @@ -45,9 +45,8 @@ def f2_sanitize(val):
return round(val, 2)


def get_data(ts, fmt):
def get_data(cursor, ts, fmt):
"""Get the data for this timestamp"""
pgconn, cursor = get_dbconnc("iem")
data = {"type": "FeatureCollection", "features": []}
# Fetch the daily values
cursor.execute(
Expand Down Expand Up @@ -119,11 +118,10 @@ def get_data(ts, fmt):
else:
res += "%s," % (val,)
res += "\n"
pgconn.close()
return res


@iemapp()
@iemapp(iemdb="iem", iemdb_cursorname="cursor")
def application(environ, start_response):
"""see how we are called"""
dt = environ.get("dt", datetime.date.today().strftime("%Y-%m-%d"))
Expand All @@ -145,7 +143,7 @@ def application(environ, start_response):
mc = Client("iem-memcached:11211")
res = mc.get(mckey)
if not res:
res = get_data(ts, fmt)
res = get_data(environ["iemdb.iem.cursor"], ts, fmt)
mc.set(mckey, res, 300)
else:
res = res.decode("utf-8")
Expand Down
10 changes: 4 additions & 6 deletions htdocs/geojson/snowfall.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import json

from pyiem.reference import TRACE_VALUE
from pyiem.util import get_dbconnc, html_escape
from pyiem.util import html_escape
from pyiem.webutil import iemapp
from pymemcache.client import Client

Expand All @@ -19,9 +19,8 @@ def sanitize(val):
return val


def get_data(ts):
def get_data(cursor, ts):
"""Get the data for this timestamp"""
pgconn, cursor = get_dbconnc("iem")
data = {"type": "FeatureCollection", "features": []}
# Fetch the daily values
cursor.execute(
Expand Down Expand Up @@ -53,11 +52,10 @@ def get_data(ts):
},
}
)
pgconn.close()
return json.dumps(data)


@iemapp()
@iemapp(iemdb="iem", iemdb_cursorname="cursor")
def application(environ, start_response):
"""see how we are called"""
dt = environ.get("dt", datetime.date.today().strftime("%Y-%m-%d"))
Expand All @@ -69,7 +67,7 @@ def application(environ, start_response):
mc = Client("iem-memcached:11211")
res = mc.get(mckey)
if not res:
res = get_data(ts)
res = get_data(environ["iemdb.iem.cursor"], ts)
mc.set(mckey, res, 300)
else:
res = res.decode("utf-8")
Expand Down
7 changes: 6 additions & 1 deletion htdocs/plotting/auto/scripts/p47.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ def get_description():
label="Select Station:",
network="IACLIMATE",
),
dict(type="month", name="month", default="12", label="Select Month:"),
{
"type": "month",
"name": "month",
"default": "12",
"label": "Select Month:",
},
dict(
type="year",
name="year",
Expand Down
5 changes: 2 additions & 3 deletions htdocs/plotting/auto/scripts/p71.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,12 @@ def plotter(fdict):
SELECT extract(year from day) as year,
to_char(day, 'mmdd') as sday,
day, avg_sknt as sknt, vector_avg_drct as drct
from summary s JOIN stations t
ON (t.iemid = s.iemid) WHERE t.id = %s and t.network = %s and
from summary s WHERE iemid = %s and
extract(month from day) = %s and avg_sknt is not null
and vector_avg_drct is not null ORDER by day ASC
""",
conn,
params=(station, ctx["network"], month),
params=(ctx["_nt"].sts[station]["iemid"], month),
parse_dates=["day"],
)
title = (
Expand Down
24 changes: 13 additions & 11 deletions htdocs/sites/current.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,17 +214,19 @@ function make_shef_table($data, $iscurrent){
} // End if
$table .= "</table>";

// Cloud Levels
$skyc = $json["last_ob"]["skycover[code]"];
$skyl = $json["last_ob"]["skylevel[ft]"];
for ($i = 0; $i < 4; $i++) {
if (is_null($skyc[$i])) continue;
$table .= sprintf(
"<b>Cloud Layer %s</b>: %s (%s feet)<br />",
$i + 1,
$skyc[$i],
$skyl[$i]
);
if (array_key_exists("last_ob", $json)){
// Cloud Levels
$skyc = $json["last_ob"]["skycover[code]"];
$skyl = $json["last_ob"]["skylevel[ft]"];
for ($i = 0; $i < 4; $i++) {
if (is_null($skyc[$i])) continue;
$table .= sprintf(
"<b>Cloud Layer %s</b>: %s (%s feet)<br />",
$i + 1,
$skyc[$i],
$skyl[$i]
);
}
}
}

Expand Down

0 comments on commit d8ae60f

Please sign in to comment.