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?