Units of interval in database

74 views
Skip to first unread message

Peter Cooper-Davis

unread,
Sep 4, 2024, 5:29:33 AM9/4/24
to weewx-user
I recently noticed some issues with my weewx database when calculating average values from the weighted daily sums compared to from the individual records. For example:

select avg(outTemp) from archive where strftime("%m", dateTime,'unixepoch','localtime')=='09'; gives 16.44376...

select sum(sum)/sum(count) from archive_day_outTemp where strftime("%m", dateTime,'unixepoch','localtime')=='09'; gives 16.44402...

BUT

select sum(wsum)/sum(sumtime) from archive_day_outTemp where where strftime("%m", dateTime,'unixepoch','localtime')=='09'; gives 12.76334...

I looked into my database in more detail and noticed that some days have a much higher count and sumtime than others despite the same record count. Following this discrepancy further, I then noticed that on the days with the larger sumtime, some of my records had an interval of 300 and some had a interval of 5.

This brings me to my question. What is the unit of interval in the database? I had assumed it was seconds (which matches the units of archive_interval in weewx.conf), so the records with an interval of 300 are 5-minute averaged catch-up records generated through my drivers genStartupRecords() where I manually specify the interval to be 300 seconds. The records with an internal of 5 are generated from loop packets. I suspect my issue is that the units of interval is minutes, and therefore I should change 300 to 5 in my genStartupRecords() function and manually adjust my database to change all instances of interval=300 to interval=5 (I have always used a constant archive interval). Before I do this though, can someone confirm that my thinking is correct?


Tom Keffer

unread,
Sep 4, 2024, 11:44:40 AM9/4/24
to weewx...@googlegroups.com
Your suspicion is correct. The unit for `interval` is minutes. I know it's not consistent with the rest of WeeWX, but we inherited it from the wview schema. 

See the section The database in the Customization Guide.

-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/23203cb0-2b36-49b7-8b49-6b0d7628367fn%40googlegroups.com.

Peter Cooper-Davis

unread,
Sep 4, 2024, 12:58:46 PM9/4/24
to weewx-user
Not sure how I missed that in the Customisation Guide! Thanks for clarifying though. I’ll update the interval in the archive table and then drop/rebuild the daily summaries
Reply all
Reply to author
Forward
0 new messages