weewx division by zero error

24 views
Skip to first unread message

Jeff Ross

unread,
Mar 25, 2020, 6:52:09 PM3/25/20
to weewx-user
Getting the following error on weewx 3.9.2:

2020-03-25 16:25:39.975468500 127.0.0.1: user.debug: Mar 25 16:25:39 weewx[17898]: interceptor: MainThread: raw packet: {'wind_speed': 5.1, 'humidity_in': 30.0, 'temperature_in': 70.3, 'barometer': 25.609, 'windchill': 29.7, 'dewpoint': 28.2, 'humidity_out': 78.0, 'uv': 0.0, 'radiation': 52.85, 'rain': None, 'dateTime': 1585175109, 'pressure': 25.609, 'temperature_out': 34.3, 'wind_dir': 237.0, 'rain_total': 0.331, 'usUnits': 1, 'wind_gust': 5.8}
2020-03-25 16:25:39.975558500 127.0.0.1: user.debug: Mar 25 16:25:39 weewx[17898]: interceptor: MainThread: mapped packet: {'barometer': 25.609, 'windchill': 29.7, 'dewpoint': 28.2, 'pressure': 25.609, 'outHumidity': 78.0, 'UV': 0.0, 'radiation': 52.85, 'rain': None, 'dateTime': 1585175109, 'windDir': 237.0, 'outTemp': 34.3, 'windSpeed': 5.1, 'inHumidity': 30.0, 'inTemp': 70.3, 'windGust': 5.8, 'usUnits': 1}
2020-03-25 16:25:40.089632500 127.0.0.1: user.info: Mar 25 16:25:40 weewx[17898]: engine: Main loop exiting. Shutting engine down.
2020-03-25 16:25:40.109860500 127.0.0.1: user.debug: Mar 25 16:25:40 weewx[17898]: restx: Shut down Windy thread.
2020-03-25 16:25:40.129892500 127.0.0.1: user.debug: Mar 25 16:25:40 weewx[17898]: restx: Shut down PWSWeather thread.
2020-03-25 16:25:40.149827500 127.0.0.1: user.debug: Mar 25 16:25:40 weewx[17898]: restx: Shut down StationRegistry thread.
2020-03-25 16:25:40.150077500 127.0.0.1: user.info: Mar 25 16:25:40 weewx[17898]: interceptor: MainThread: shutting down server thread
2020-03-25 16:25:40.150189500 127.0.0.1: user.debug: Mar 25 16:25:40 weewx[17898]: interceptor: MainThread: stop sniff server
2020-03-25 16:25:40.151404500 127.0.0.1: user.crit: Mar 25 16:25:40 weewx[17898]: engine: Caught unrecoverable exception in engine:
2020-03-25 16:25:40.151596500 127.0.0.1: user.crit: Mar 25 16:25:40 weewx[17898]:     ****  integer division or modulo by zero
2020-03-25 16:25:40.192081500 127.0.0.1: user.crit: Mar 25 16:25:40 weewx[17898]:     ****  Traceback (most recent call last):
2020-03-25 16:25:40.192281500 127.0.0.1: user.crit: Mar 25 16:25:40 weewx[17898]:     ****    File "/home/weewx/bin/weewx/engine.py", line 894, in main
2020-03-25 16:25:40.192286500 127.0.0.1: user.crit: Mar 25 16:25:40 weewx[17898]:     ****      engine.run()
2020-03-25 16:25:40.192501500 127.0.0.1: user.crit: Mar 25 16:25:40 weewx[17898]:     ****    File "/home/weewx/bin/weewx/engine.py", line 191, in run
2020-03-25 16:25:40.192506500 127.0.0.1: user.crit: Mar 25 16:25:40 weewx[17898]:     ****      self.dispatchEvent(weewx.Event(weewx.NEW_LOOP_PACKET, packet=packet))
2020-03-25 16:25:40.193301500 127.0.0.1: user.crit: Mar 25 16:25:40 weewx[17898]:     ****    File "/home/weewx/bin/weewx/engine.py", line 224, in dispatchEvent
2020-03-25 16:25:40.193324500 127.0.0.1: user.crit: Mar 25 16:25:40 weewx[17898]:     ****      callback(event)
2020-03-25 16:25:40.193328500 127.0.0.1: user.crit: Mar 25 16:25:40 weewx[17898]:     ****    File "/home/weewx/bin/weewx/engine.py", line 540, in new_loop_packet
2020-03-25 16:25:40.193332500 127.0.0.1: user.crit: Mar 25 16:25:40 weewx[17898]:     ****      self.accumulator = self._new_accumulator(event.packet['dateTime'])
2020-03-25 16:25:40.193336500 127.0.0.1: user.crit: Mar 25 16:25:40 weewx[17898]:     ****    File "/home/weewx/bin/weewx/engine.py", line 650, in _new_accumulator
2020-03-25 16:25:40.193345500 127.0.0.1: user.crit: Mar 25 16:25:40 weewx[17898]:     ****      self.archive_interval)
2020-03-25 16:25:40.193348500 127.0.0.1: user.crit: Mar 25 16:25:40 weewx[17898]:     ****    File "/home/weewx/bin/weeutil/weeutil.py", line 197, in startOfInterval
2020-03-25 16:25:40.193353500 127.0.0.1: user.crit: Mar 25 16:25:40 weewx[17898]:     ****      m = int(time_tt.tm_min // interval_m * interval_m)
2020-03-25 16:25:40.193361500 127.0.0.1: user.crit: Mar 25 16:25:40 weewx[17898]:     ****  ZeroDivisionError: integer division or modulo by zero
2020-03-25 16:25:40.193365500 127.0.0.1: user.crit: Mar 25 16:25:40 weewx[17898]:     ****  Exiting.

If I'm reading the above correctly, the error occurs here in home/weewx/bin/weeutil/weeutil.py: 
def startOfInterval(time_ts, interval):
    """Find the start time of an interval.

    This algorithm assumes the day is divided up into
    intervals of 'interval' length. Given a timestamp, it
    figures out which interval it lies in, returning the start
    time.

    time_ts: A timestamp. The start of the interval containing this
    timestamp will be returned.

    interval: An interval length in seconds.

    Returns: A timestamp with the start of the interval.

    Examples:

    >>> os.environ['TZ'] = 'America/Los_Angeles'
    >>> start_ts = time.mktime(time.strptime("2013-07-04 01:57:35", "%Y-%m-%d %H:%M:%S"))
    >>> time.ctime(startOfInterval(start_ts,  300))
    'Thu Jul  4 01:55:00 2013'
    >>> time.ctime(startOfInterval(start_ts,  300.0))
    'Thu Jul  4 01:55:00 2013'
    >>> time.ctime(startOfInterval(start_ts,  600))
    'Thu Jul  4 01:50:00 2013'
    >>> time.ctime(startOfInterval(start_ts,  900))
    'Thu Jul  4 01:45:00 2013'
    >>> time.ctime(startOfInterval(start_ts, 3600))
    'Thu Jul  4 01:00:00 2013'
    >>> time.ctime(startOfInterval(start_ts, 7200))
    'Thu Jul  4 00:00:00 2013'
    >>> start_ts = time.mktime(time.strptime("2013-07-04 01:00:00", "%Y-%m-%d %H:%M:%S"))
    >>> time.ctime(startOfInterval(start_ts,  300))
    'Thu Jul  4 00:55:00 2013'
    >>> start_ts = time.mktime(time.strptime("2013-07-04 01:00:01", "%Y-%m-%d %H:%M:%S"))
    >>> time.ctime(startOfInterval(start_ts,  300))
    'Thu Jul  4 01:00:00 2013'
    >>> start_ts = time.mktime(time.strptime("2013-07-04 01:04:59", "%Y-%m-%d %H:%M:%S"))
    >>> time.ctime(startOfInterval(start_ts,  300))
    'Thu Jul  4 01:00:00 2013'
    >>> start_ts = time.mktime(time.strptime("2013-07-04 00:00:00", "%Y-%m-%d %H:%M:%S"))
    >>> time.ctime(startOfInterval(start_ts,  300))
    'Wed Jul  3 23:55:00 2013'
    >>> start_ts = time.mktime(time.strptime("2013-07-04 07:51:00", "%Y-%m-%d %H:%M:%S"))
    >>> time.ctime(startOfInterval(start_ts,  60))
    'Thu Jul  4 07:50:00 2013'
    >>> start_ts += 0.1
    >>> time.ctime(startOfInterval(start_ts,  60))
    'Thu Jul  4 07:51:00 2013'  
    """

    interval_m = int(interval // 60)
    interval_h = int(interval // 3600)
    time_tt = time.localtime(time_ts)
    m = int(time_tt.tm_min // interval_m * interval_m)
    h = int(time_tt.tm_hour // interval_h * interval_h) if interval_h > 1 else time_tt.tm_hour

Help!

Jeff Ross

Thomas Keffer

unread,
Mar 25, 2020, 6:56:51 PM3/25/20
to weewx-user
What are you using for an archive interval? 

To check, set debug=1, then restart the program. Look for a line such as

Using archive interval of 60 seconds (specified in weewx configuration)

-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.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/5a2cf3d4-5919-4bd2-bb7a-24275b94d472%40googlegroups.com.

Jeff Ross

unread,
Mar 25, 2020, 7:09:35 PM3/25/20
to weewx-user
30 seconds

Thomas Keffer

unread,
Mar 25, 2020, 7:23:51 PM3/25/20
to weewx-user
WeeWX V3.x does not support archive intervals less than 60 seconds.

WeeWX V4 will.

However, very few weather stations have LOOP packets that come fast enough to allow that short of an interval. 

-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.

Jeff Ross

unread,
Mar 25, 2020, 7:44:50 PM3/25/20
to weewx-user
3.9.1 had no problem with 30s.  Reset to 60 and no division by error.

Thanks!!!!

On Wednesday, March 25, 2020 at 4:52:09 PM UTC-6, Jeff Ross wrote:
Reply all
Reply to author
Forward
0 new messages