How to get both lux and radiation values in the report?

444 views
Skip to first unread message

f4n...@gmail.com

unread,
Feb 26, 2022, 3:26:30 AM2/26/22
to weewx-user
Hi, i have a WH65 sensor and receive the data with an sdr stick. The WH65 sensor array sends its radiation readings in lux and is being converted back to w/m2 on the console, with the correction factor of /126.7, which gives an approximate value in w/m2, i guess this is the usual way to do in weewx too, so it can be compared with the ecowitt data.

But since this is only an approximation as stated here:

I wonder if it would be possible to get both values into the report, so the original lux value would also be visible. Is this somehow possible?

gjr80

unread,
Feb 27, 2022, 9:17:01 PM2/27/22
to weewx-user
The short answer is yes, it is possible. However, what you need to do depends. I assume you are using the SDR driver, if that is the case it should be providing you with the 'light' reading in Lux mapped to whatever WeeWX field you have specified in the sensor map (the usual mapping would be to the 'luminosity' field in the WeeWX extended schema).  You can have WeeWX derive/estimate the radiation field from this data by adding an entry under [StdCalibrate] [[Corrections]] in weewx.conf, something like:

[StdCalibrate]
    ....
    [[Corrections]]
        radiation = luminosity/126.7 if luminosity is not None else None

should see WeeWX calculate WeeWX field radiation from the WeeWX field luminosity and add it to any loop packet/archive records where luminosity appears.

What you do from here depends on your current skin arrangement and what you wish to display. If your database is using the extended schema both radiation and luminosity will be stored in your database allowing you to use any radiation or luminosity tags in your reports as well as using radiation or luminosity in plots. If you are using the legacy wview schema then only radiation will be saved to database meaning only the current luminosity value can be displayed, ie no luminosity stats or plots. To display luminosity stats or plots you would need to add luminosity to your schema or change to the extended schema.

You don't mention what skin your are using, if it is the WeeWX 4.6 or later Seasons skin then radiation will be automatically displayed, but you will need to edit the [DisplayOptions] settings in the Seasons skin config file skin.conf and add luminosity. If you are using some other skin or wish to display some other radiation or luminosity stats then you would need to follow the skin authors suggestion or add the appropriate tags to the skin you are using.

Gary

f4n...@gmail.com

unread,
Mar 1, 2022, 10:21:47 AM3/1/22
to weewx-user
I'm currently only using the standard Seasons skin. How do i find out which schema weewx uses? I never really changed this setting so what would be the standard weewx installation schema? I thought it was the extended one but as it seems i'm not getting any luminosity plots in the Seasons skin, just the current luminosity value

gjr80

unread,
Mar 1, 2022, 6:27:57 PM3/1/22
to weewx-user
The only real definitive way of determining what schema you are using is to access the database and check what fields are there. If you have only ever installed v 4.0.0 or later and did not explicitly change the schema you are almost certainly using the extended schema. If you have upgraded a v3.x or earlier install you are most likely using the legacy wview schema unless you explicitly changed schemas. You can check the schema config option for the binding concerned under [DataBindings] in weewx.conf, eg:

[DataBindings]


     [[wx_binding]]

         ....
         # The schema defines the structure of the database.
         # It is *only* used when the database is created.
 
schema = schemas.wview_extended.schema
         schema = schemas.wview_extended.schema

However, the schema config option is only used when the database is created so it is possible that it may be different to the actual schema of the database you are using.

The fact you don't get luminosity plots could be due to any one of a myriad of issues, schema is just but one of the possible causes. The most likely cause is that your skin is not set to generate and display such plots.

If you are using the 4.6.x Seasons skin you can specify in the skin config file what observations you wish to see reported and plotted. As I said in my previous post I suggest you have a look through the [DisplayOptions] stanza, the comments should guide you. One thing I did omit was that you will need to add suitable entries to the [ImageGenerator] stanza of the skin config file to create your luminosity plot files, something like (untested):


[ImageGenerator]
    ....
    [[day_images]]
        ....
        [[[dayluminosity]]]
            [[[[luminosity]]]]

likewise for week, month and year plots in [[week_images]], [[month_images]] and [[year_images]]. Provided you have appropriate settings in [DisplayOptions] your plots should appear. If things don't work as expected check if the luminosity plot files are being generated, check the log for errors and confirm the [DisplayOptions] settings.

Gary

f4n...@gmail.com

unread,
Mar 3, 2022, 6:36:16 AM3/3/22
to weewx-user
It was the skin.conf, now they appear, thanks!

Is there a way to add "lux" to the lux reading in the graph and current conditions list? Could i just add it in weewx.conf?

In the current conditions list, the lux number reads like this "70070.000000". Can i add something like lux = %.1f to weewx.conf?

gjr80

unread,
Mar 4, 2022, 6:50:21 PM3/4/22
to weewx-user
Before I answer a quick WeeWX units 101. The WeeWX unit system is the core that allows WeeWX to convert between units (eg C to F), format observation data in reports and add unit labels. The system is predicated on each observation being allocated to a unit group (eg outTemp, inTemp, dewpoint etc are allocated to group_temperature). In essence this tells WeeWX that each of these observations are a temperature, so WeeWX knows how to convert to other temperature units, format the numeric data and what unit labels to use.

There is a bit of history to light related observations in WeeWX. Without going into the details the WeeWX extended schema includes a field named illuminance that belongs to group_illuminance which uses the unit lux. There is no field named luminosity in the WeeWX extended schema. Consequently, when you use a field named luminosity in reports and plots etc WeeWX will still happily display the data but you don't get any unit labels, formatting of numeric values, unit conversion etc. So how to fix? Simple, you need to tell WeeWX about the data in field luminosity. This is covered to a certain extent in the Customization Guide under the section Customizing units and unit groups. In your case though the preferred approach would be to add a couple of lines to extensions.py (located in /home/weewx/bin/user or /usr/share/weewx/user depending on your WeeWX install), something like the following should work (untested):

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

Save extensions.py and restart WeeWX. Your plots and reports should now contain properly formatted/labelled luminosity data.

Gary

f4n...@gmail.com

unread,
Mar 5, 2022, 7:26:36 AM3/5/22
to weewx-user
Thanks a lot Gary, this was somehow better to understand for me than in the Customization Guide.

And it works, now the zeros behind the dot are gone. My SDR setup is displaying both lx and w/m2 fine now. This was rather easy to do with just adding it a second time to the sensor map and adding the right conversions, but now I wonder how I could achieve this on the Interceptor driver instance too?  

Could I just add radiation = radiation, as well as luminosity = radiation*126,7 to the corrections section or is there more needed to generate a second plot for it? Kind of like when someone would want to output the temperature both in celsius and farenheit, how is this done?

gjr80

unread,
Mar 5, 2022, 7:01:13 PM3/5/22
to weewx-user
The same general approach can be applied to any driver; (1) configure the driver to provide whatever observations you require (in the case of SDR this involves setting up the sensor map, likewise for the interceptor driver, other drivers you may need to do nothing) (2) if WeeWX cannot calculate your derived observation using StdWxCalculate you can use  StdCalibrate to calculate simple derived observations.

I can't say what you need to put in the interceptor driver sensor map, this depends on how you are using the interceptor driver (it operates in a number of modes) and what hardware you are intercepting. Once you have the observation data being emitted from the interceptor driver just use that field name in StdCalibrate.

C to F is a little different, WeeWX knows how to convert from C to F and F to C but it does not know how to convert between W/m2 and lux. For temperature you can just use a tag in a report to specify whether you want C or F and WeeWX will automatically handle the conversion, formatting and labeling, so you could use:

$current.outTemp.degree_C ($current.outTemp.degree_F)

to display something like:

35.2 C (95.4 F)

Since WeeWX does not know how to convert between W/m2 and lux to do the same for radiation and luminosity you need to calculate luminosity yourself, either through StdCalibrate or some other method (a service or an xtype), and then add luminosity to a unit group (the extensions.py additions mentioned earlier) and then you could use something like:

$current.radiation ($current.luminosity)

to display something like

520 W/m2 (65884 lux)

In this case WeeWX is really just handling the formatting and labeling.

Gary
Reply all
Reply to author
Forward
0 new messages