Skip to content

Commit

Permalink
🎨 Print two decimals for ice
Browse files Browse the repository at this point in the history
  • Loading branch information
akrherz committed Jan 6, 2025
1 parent d41bf75 commit 9a253c1
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pylib/iemweb/autoplot/scripts200/p207.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,18 @@ def do_analysis(df: pd.DataFrame, ctx: dict):
return lons, lats, vals


def prettyprint(val):
def prettyprint(val, decimals=1):
"""Make trace pretty."""
if val == 0:
return "0"
if 0 < val < 0.1:
return "T"
return f"{val:.1f}"
return f"{val:.1f}" if decimals == 1 else f"{val:.2f}"


def prettyprint2(val):
"""Lazy."""
return prettyprint(val, 2)


def plotter(ctx: dict):
Expand All @@ -408,7 +413,9 @@ def plotter(ctx: dict):
ctx["bnds2163"] = compute_grid_bounds(ctx, csector)
# add zeros and QC
df = add_zeros(df, ctx)
df["label"] = df["val"].apply(prettyprint)
df["label"] = df["val"].apply(
prettyprint2 if ctx["v"] == "ice" else prettyprint
)
# do gridding
df2 = df[df[USEME]]
lons, lats, vals = do_analysis(df2, ctx)
Expand Down

0 comments on commit 9a253c1

Please sign in to comment.