Divide by Zero error generating graphs

81 views
Skip to first unread message

Greeebs

unread,
Sep 25, 2018, 2:44:44 AM9/25/18
to weewx-user
Hi all,
New weewx user here using a home brew weather station based on Arduino's and nRF24L01+ radios.
I wrote my own driver to accept packets on the nRF24L01 attached to the RPi and weewx is happily accepting my LOOP packets and producing reports every archiving period. I've also managed to import the last 18 months of weather data  I had collected prior to installing weewx. Until today, weewx has been going fantastically.

Today I encountered a weird issue which I've not found described elsewhere. I was getting a divide by zero error during graph generation and none of my graphs were being updated.

I had a period of 24+ hours where my humidity was stuck at 100%. As soon as it dropped to 99%, the error went away and all of my graphs were updated.

It turns out that if you specify only a maximum value for a graph, and have a period where the reading for the entire graph period was at that maximum, you get the divide by zero error.
Is this a known bug?

Here's the relevant section from the log:
Sep 25 06:26:19 hub-pi weewx[436]: reportengine: Caught unrecoverable exception in generator weewx.imagegenerator.ImageGenerator
Sep 25 06:26:19 hub-pi weewx[436]:         ****  float division by zero
Sep 25 06:26:19 hub-pi weewx[436]:         ****  Traceback (most recent call last):
Sep 25 06:26:19 hub-pi weewx[436]:         ****    File "/usr/share/weewx/weewx/reportengine.py", line 239, in run
Sep 25 06:26:19 hub-pi weewx[436]:         ****      obj.start()
Sep 25 06:26:19 hub-pi weewx[436]:         ****    File "/usr/share/weewx/weewx/reportengine.py", line 273, in start
Sep 25 06:26:19 hub-pi weewx[436]:         ****      self.run()
Sep 25 06:26:19 hub-pi weewx[436]:         ****    File "/usr/share/weewx/weewx/imagegenerator.py", line 32, in run
Sep 25 06:26:19 hub-pi weewx[436]:         ****      self.genImages(self.gen_ts)
Sep 25 06:26:19 hub-pi weewx[436]:         ****    File "/usr/share/weewx/weewx/imagegenerator.py", line 235, in genImages
Sep 25 06:26:19 hub-pi weewx[436]:         ****      image = plot.render()
Sep 25 06:26:19 hub-pi weewx[436]:         ****    File "/usr/share/weewx/weeplot/genplot.py", line 195, in render
Sep 25 06:26:19 hub-pi weewx[436]:         ****      sdraw = self._getScaledDraw(draw)
Sep 25 06:26:19 hub-pi weewx[436]:         ****    File "/usr/share/weewx/weeplot/genplot.py", line 222, in _getScaledDraw
Sep 25 06:26:19 hub-pi weewx[436]:         ****      ((self.xscale[0], self.yscale[0]), (self.xscale[1], self.yscale[1])))
Sep 25 06:26:19 hub-pi weewx[436]:         ****    File "/usr/share/weewx/weeplot/utilities.py", line 317, in __init__
Sep 25 06:26:19 hub-pi weewx[436]:         ****      self.yscale = -float(lri[1] - uli[1]) / float(urs[1] - lls[1])
Sep 25 06:26:19 hub-pi weewx[436]:         ****  ZeroDivisionError: float division by zero
Sep 25 06:26:19 hub-pi weewx[436]:         ****  Generator terminated
Sep 25 06:26:19 hub-pi weewx[436]: copygenerator: copied 0 files to /var/www/html/weewx


Here's the relevant section from the skin.conf:
        [[[dayhum]]]
            yscale = None, 100, None
            [[[[outHumidity]]]]


Thomas Keffer

unread,
Sep 25, 2018, 9:18:20 AM9/25/18
to weewx-user
I was able to reproduce this. I've created issue #344 to track.

Shouldn't be too hard to fix.

-tk

--
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.
For more options, visit https://groups.google.com/d/optout.

R Sparkes

unread,
Sep 25, 2018, 5:17:54 PM9/25/18
to weewx...@googlegroups.com
Excellent!
Much appreciated.

You received this message because you are subscribed to a topic in the Google Groups "weewx-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/weewx-user/H1C8sLDALWs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to weewx-user+...@googlegroups.com.

Thomas Keffer

unread,
Sep 26, 2018, 11:28:48 AM9/26/18
to weewx-user
OK, replace your copy of weeplot/utilities.py with the attached.

Incidentally, good sleuthing when you figured out the problem! It made it easy to come up with the fix.

-tk
utilities.py

R Sparkes

unread,
Sep 26, 2018, 5:37:39 PM9/26/18
to weewx...@googlegroups.com
Thanks for the quick turnaround, I've put that new version in place and will see how it goes.

Greeebs

unread,
Oct 5, 2018, 7:50:29 AM10/5/18
to weewx-user
Just like to confirm that after another period of 24+ hours of 100% humidity, I'm still getting graphs generated so this is now definitely fixed :)
Reply all
Reply to author
Forward
0 new messages