Fixing units in a new graph

141 views
Skip to first unread message

Jan-Jaap van der Geer

unread,
Feb 16, 2021, 4:01:19 PM2/16/21
to weewx-user
I have added a luminosity graph to weewx (Seasons skin). It seems to work, the graph works. However, it does not mention the unit used at the top left, like the others do.

I am trying to fix this, but I'm not sure how.

In the weewx.conf I added, under [[[Units]]] in [[[[Groups]]]] :

group_illuminance = lux

(I think that shouldn't be needed as there is only one choice of unit for illuminance?)

Under [[[[StringFormats]]]] I have added:

lux = %.0f

And under [[[[Labels]]]] I have:

lux = " lux"

But apparently I'm still missing something. But what?

Also in the high/low part of the template I tried adding Luminosity like so:

      #if $day.luminosity.has_data
      <tr>
        <td class="label">$obs.label.luminosity</td>
        #for $archive in $archive_data
        <td class="data new_row hilo_$archive[0]">
          <span title="$archive[1].luminosity.maxtime">
            $archive[1].luminosity.max.format(add_label=False)</span><br/>
          <span title="$archive[1].luminosity.mintime">
            $archive[1].luminosity.min.format(add_label=False)</span>
        </td>
        #end for
        <td class="units">$unit.label.luminosity</td>
      </tr>
      #end if

But also this is not showing the unit and the format is 6 digits after the floating point, which is a bit overkill.

Any suggestion how to fix this?

Cheers,
Jan-Jaap

Tom Keffer

unread,
Feb 16, 2021, 4:53:33 PM2/16/21
to weewx-user
There's already a type for luminosity, but it's called "illuminance", introduced in V4.2. It's a member of group_illuminance

See issue #613, in particular, this post.

--
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/52f9dece-add1-44bb-8ee3-e447a5e97592n%40googlegroups.com.

Jan-Jaap van der Geer

unread,
Feb 17, 2021, 4:28:37 PM2/17/21
to weewx-user
On Tuesday, February 16, 2021 at 10:53:33 PM UTC+1 tke...@gmail.com wrote:
There's already a type for luminosity, but it's called "illuminance", introduced in V4.2. It's a member of group_illuminance
 
See issue #613, in particular, this post.

Hm, I'm not sure that helps me. I've tried replacing the 'lux = " lux"' with 'illuminance = " lux"' and  adding 'illuminance = %.0f' to the StringFormats but there's still no unit on the graph and the low/high table still has lot's of digits behind the comma. I'm not sure what to do, but I do see that lux/illuminance might be a difficult one to get right because of naming confusion.

But I have a graph for the voltage as well. That one also doesn't show the unit (v) in its graph. Maybe that's a better example. I added these values in weewx.conf:

[[Defaults]]
  [[[Units]]]
    [[[[Groups]]]]
      group_volt = volt

    [[[[Labels]]]]
      volt = " volt"
      
But that does not add the unit to the volt-graph. What am I missing?

Thinking about it a bit more I think I might be completely in the wrong area as there's nothing in the section I quoted that seems to tell weewx to use "°C" for temperatures but still it does.

How does it know this?

Cheers,
Jan-Jaap

Jan-Jaap van der Geer

unread,
Feb 17, 2021, 5:23:19 PM2/17/21
to weewx-user
Aaaah, no matter. I just found the section 'Assigning a unit group' in the Customization guide. That seems to work... RTFM, I suppose... Thanks!

Cheers,
Jan-Jaap

Tom Keffer

unread,
Feb 17, 2021, 5:27:40 PM2/17/21
to weewx-user
Formats and labels are keyed to unit groups, not observation types. If you really want to use luminance (instead of illuminance), you need to tell the system what unit group it is in. You do that by making an assignment to the data structure weewx.units.obs_group_dict:

import weewx.units
weewx.units.obs_group_dict['luminance'] = 'group_illuminance'

See the section Assigning a unit group in the Customizing Guide. 

However, be aware that illuminance is not the same of luminance. Illuminance measures the amount of light falling on a surface area. Luminance measures the amount of light passing through a solid angle. Only illuminance is measured in lux.

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

Jan-Jaap van der Geer

unread,
Feb 17, 2021, 6:08:12 PM2/17/21
to weewx-user
On Wednesday, February 17, 2021 at 11:27:40 PM UTC+1 tke...@gmail.com wrote:
Formats and labels are keyed to unit groups, not observation types. If you really want to use luminance (instead of illuminance), you need to tell the system what unit group it is in. You do that by making an assignment to the data structure weewx.units.obs_group_dict:

import weewx.units
weewx.units.obs_group_dict['luminance'] = 'group_illuminance'

See the section Assigning a unit group in the Customizing Guide. 

However, be aware that illuminance is not the same of luminance. Illuminance measures the amount of light falling on a surface area. Luminance measures the amount of light passing through a solid angle. Only illuminance is measured in lux.

This is almost what I ended up doing:

import weewx.units
weewx.units.obs_group_dict['outTempBatteryStatus'] = 'group_volt'
weewx.units.obs_group_dict['luminosity'] = 'group_illuminance'

I hadn't picked up on the difference between luminance and illuminance. But the field I'm using is called yet another thing, luminosity. What's that than? Time for a bit of googling I suppose, although I'm not sure I'll go as far as adding a field especially for this. Since there's a field for luminosity I think maybe I'll use that regardless.

Thanks for the help!

Cheers,
Jan-Jaap

Reply all
Reply to author
Forward
0 new messages