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

Add English Unit option #36

Merged
merged 2 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.1.6"
rev: "v0.1.9"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
11 changes: 9 additions & 2 deletions htdocs/dl/shapefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
PRJFILE = "/opt/iem/data/gis/meta/5070.prj"


def workflow(start_response, dt, dt2, states):
def workflow(start_response, dt, dt2, states, conv):
"""Generate for a given date"""
dextra = "valid = :dt"
params = {"dt": dt}
Expand Down Expand Up @@ -59,6 +59,12 @@ def workflow(start_response, dt, dt2, states):
params=params,
geom_col="geo",
)
if conv == "english":
df["prec_in"] = df["prec_mm"] / 25.4
df["loss_tpa"] = df["los_kgm2"] * 4.463
df["runof_in"] = df["runof_mm"] / 25.4
df["deli_tpa"] = df["deli_kgm"] * 4.463
df = df.drop(columns=["prec_mm", "los_kgm2", "runof_mm", "deli_kgm"])

with tempfile.TemporaryDirectory() as tempdir:
basefn = f"idepv2_{dt:%Y%m%d}"
Expand Down Expand Up @@ -94,6 +100,7 @@ def application(environ, start_response):
dt = datetime.datetime.strptime(form.get("dt", "2019-12-11"), "%Y-%m-%d")
dt2 = form.get("dt2")
states = form.get("states")
conv = form.get("conv", "metric")
if dt2 is not None:
dt2 = datetime.datetime.strptime(form.get("dt2"), "%Y-%m-%d")
return [workflow(start_response, dt, dt2, states)]
return [workflow(start_response, dt, dt2, states, conv)]