How does weewx deal with null values in longer term graphs?

47 views
Skip to first unread message

Peter Fletcher

unread,
Jun 3, 2023, 7:39:29 PM6/3/23
to weewx-user
For reasons discussed elsewhere, I have a user service which saves nulls. rather than zeros to the archive records for UV and solar radiation values during the night. Daily and weekly graphs continue to look as they should (with the daytime tracings arising from at or very near to the zero axis). On the monthly graphs, however, the tracings do not touch the zero axis at either end of the daytime peak, I am guessing that, in calculating averaged data points for the longer term graphs, weewx is treating the average of any group of values that contains a null value as null. There is some logic to this, but the results are unhelpful in this case. Am I right about the cause of the problem, and is there a workaround for it?
WeekGraphs.jpg
MonthGraphs.jpg

Tom Keffer

unread,
Jun 3, 2023, 8:10:26 PM6/3/23
to weewx...@googlegroups.com
WeeWX uses a SQL statement to calculate the averages. SQL ignores any nulls in an aggregate interval. So, if there is nothing but nulls in an interval, the result will be null, not zero.

Null values signify unknown values, not zero. I didn't follow the discussion of your service, but if you can't change it to store zero when the value is, well, zero, then you'll have to define your own specialty xtype aggregations, which treats null as a zero, perhaps by using the SQL function IFNULL(). 

Instructions on defining custom xtype aggregations: https://github.com/weewx/weewx/wiki/xtypes#calculating-aggregates


On Sat, Jun 3, 2023 at 4:39 PM 'Peter Fletcher' via weewx-user <weewx...@googlegroups.com> wrote:
For reasons discussed elsewhere, I have a user service which saves nulls. rather than zeros to the archive records for UV and solar radiation values during the night. Daily and weekly graphs continue to look as they should (with the daytime tracings arising from at or very near to the zero axis). On the monthly graphs, however, the tracings do not touch the zero axis at either end of the daytime peak, I am guessing that, in calculating averaged data points for the longer term graphs, weewx is treating the average of any group of values that contains a null value as null. There is some logic to this, but the results are unhelpful in this case. Am I right about the cause of the problem, and is there a workaround for it?

--
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/aff03e49-1c45-4383-bc80-a3db9425ac8fn%40googlegroups.com.

Peter Fletcher

unread,
Jun 3, 2023, 10:11:01 PM6/3/23
to weewx-user
I would not expect the standard SQL behavior (ignoring nulls and averaging the rest of the values) to result in what I am seeing in the graphs, but you are probably right that I am going to have to define a specialty aggregation.

Tom Keffer

unread,
Jun 4, 2023, 7:23:12 AM6/4/23
to weewx...@googlegroups.com
If you look closely at your weekly graph, the curve does not go to zero. Instead, it's missing. That's the effect of the null values.

Same with monthly, but more obvious.

From what I'm seeing, your results reflect how SQL handles averages. 


Reply all
Reply to author
Forward
0 new messages