From 9a253c1251a2c92df1226fc3d045bd018bd7ad59 Mon Sep 17 00:00:00 2001 From: akrherz Date: Mon, 6 Jan 2025 14:28:12 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Print=20two=20decimals=20for=20i?= =?UTF-8?q?ce?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pylib/iemweb/autoplot/scripts200/p207.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pylib/iemweb/autoplot/scripts200/p207.py b/pylib/iemweb/autoplot/scripts200/p207.py index 0fd603b26..e8c9740c6 100644 --- a/pylib/iemweb/autoplot/scripts200/p207.py +++ b/pylib/iemweb/autoplot/scripts200/p207.py @@ -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): @@ -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)