Zero temperature with a minus sign

54 views
Skip to first unread message

Tomasz Lewicki

unread,
Nov 8, 2025, 4:26:26 AMNov 8
to weewx-user
I first asked the developers of the neowx-material skin, which I use to display data from my station, but I will repeat the question here, as it seems to be an internal Weewx issue.

Sometimes I see a reading like the one in the screenshot below (non-graphic version: -0.0*C - minus zero point zero degree of Celsius). Of course, I guess this is due to the rounding of a value that is not visible. The question is, does this happen at the Weewx level (in which case I will ask on the weewx-user group), or can it be "fixed" in neowx-material?

Since images cannot be attached to posts on the group, here is a link to a screenshot: https://imgur.com/a/r7KxBqN

The answer was: "It is read by getVar, it looks for example like this $getVar(current.outTemp) or another variables like that. So I believe it is caused by weewx. And I agree that it is done by rounding some value, maybe it is like -0,01 or like that. In neowx-material it is done similar way as in for example official Seasons/current.inc" (https://github.com/seehase/neowx-material/issues/198#issuecomment-3504803216)

And what do you think about that?

michael.k...@gmx.at

unread,
Nov 8, 2025, 4:52:55 AMNov 8
to weewx-user
I think this is perfectly fine and no issue. It just seems odd at a first glance, maybe because it's a special case where you have more information about the real value, than in any other possible case: In contrast to e.g. 0.1°C, where you know, it is a value between 0.05 and 0,149999, which is an interval of 0.1°C, with 0.0°C you know it is between 0.0 and 0.049999, with -0.0°C you know it's between -0.049999 and -0.000001, which is an 0.05°C interval each.

Especially for weather observation I'd say the negative sign in front of the rounded zero is crucial, since the impact on the aggregate state of water is essential, which furthermore has observable effects on weather conditions. (Yes, I know about the limitations of this claim in real life)

Tomasz Lewicki

unread,
Nov 8, 2025, 6:27:39 AMNov 8
to weewx-user

Thanks for the explanation. It's not a big deal, it just looks strange/funny, but your explanation convinces me. 

Tom Keffer

unread,
Nov 8, 2025, 10:02:31 AMNov 8
to weewx...@googlegroups.com
This is a Python quirk. The specification

"%.1f" % -0.01

always yields '-0.0'

While there is no easy way to change this, there might be a workaround. First, note that 

"%.1f" % (float("%.1f" % value) + 0.0)

yields '0.0', which is what you want. Apply this diff to weewx/units.py. It should work for all float values, but I worry that somewhere out there someone has created a skin that tries to format integers or even strings. NOT TESTED.

===================================================================
diff --git a/src/weewx/units.py b/src/weewx/units.py
--- a/src/weewx/units.py (revision c7f1549acf69ee24f355616e161c3067e477422f)
+++ b/src/weewx/units.py (date 1762613730921)
@@ -781,10 +781,10 @@
                 format_string = useThisFormat
             if localize:
                 # Localization requested. Use locale with the supplied format:
-                val_str = locale.format_string(format_string, val_t[0])
+                val_str = locale.format_string(format_string, float(format_string % val_t[0]) + 0.0)
             else:
                 # No localization. Just format the string.
-                val_str = format_string % val_t[0]
+                val_str = format_string % (float(format_string % val_t[0]) + 0.0)
 
         # Add a label, if requested:
         if addLabel:


--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/weewx-user/6ea43c98-0064-45e6-bf60-f7edbdc4c8d9n%40googlegroups.com.

Tomasz Lewicki

unread,
Nov 8, 2025, 10:49:32 AMNov 8
to weewx-user
Thank you :)
Reply all
Reply to author
Forward
0 new messages