Scaling Units for different reports

63 views
Skip to first unread message

Peter Fletcher

unread,
Jun 3, 2022, 7:31:55 PM6/3/22
to weewx-user
As noted in a different thread, I am working on a small extension to calculate and store sunshine time (time when the sun is out, rather than covered by clouds). I am saving the number of minutes of sunshine during the archive period in each archive record. Sunshine minutes are fine for display on daily reports and graphs, but I would rather display the more usual sunshine hours on weekly, monthly, and longer reports. Is there an easy way to tell the report generator to scale the units it uses for different report periods? I can see this being useful for other categories of data, too. You might, for example want to display solar production in Wh for the daily reports but in kWh for monthly and longer ones.

I feel that XTypes may provide the answer to this, but couldn't really get my head around how it would work, in practice.

Tom Keffer

unread,
Jun 3, 2022, 7:41:33 PM6/3/22
to weewx-user
Sure. Just tell the report to use hours instead of minutes.

For example, for tags, it becomes $week.sunshine.sum.hour

For a plot, use option 'unit' in skin.conf.

[ImageGenerator]
  ...
  [[week_images]]
    ...
    [[[week_sunshine]]]
      unit = hour
      [[[[sunshine]]]]
      
All documented in the Customizing Guide.

On Fri, Jun 3, 2022 at 4:31 PM 'Peter Fletcher' via weewx-user <weewx...@googlegroups.com> wrote:
As noted in a different thread, I am working on a small extension to calculate and store sunshine time (time when the sun is out, rather than covered by clouds). I am saving the number of minutes of sunshine during the archive period in each archive record. Sunshine minutes are fine for display on daily reports and graphs, but I would rather display the more usual sunshine hours on weekly, monthly, and longer reports. Is there an easy way to tell the report generator to scale the units it uses for different report periods? I can see this being useful for other categories of data, too. You might, for example want to display solar production in Wh for the daily reports but in kWh for monthly and longer ones.

I feel that XTypes may provide the answer to this, but couldn't really get my head around how it would work, in practice.

--
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/2df447f0-c12d-4947-9bf4-9a2ab9491411n%40googlegroups.com.

Peter Fletcher

unread,
Jun 5, 2022, 11:45:52 AM6/5/22
to weewx-user
Thanks!
I assume that this works 'out of the box' because I have defined the unit for sunshine time as 'minute' (rather than something like 'sun_minute') and weewx already 'knows' how to convert between common units of time. For my solar production example, you would presumably need to use the unit names as they are defined in one of the energy groups..

Tom Keffer

unread,
Jun 5, 2022, 12:07:11 PM6/5/22
to weewx-user
Exactly.

That's the big advantage of assigning a type to a unit group. All the formatting and conversion machinery becomes available.

Reply all
Reply to author
Forward
0 new messages