BobAtchley / weewx-ws6in1

weewx driver for the 6 in 1 PC weather station clones
GNU General Public License v3.0
5 stars 6 forks source link

rainRate not calculated and stored in database on backfill #5

Closed ArendPWS closed 3 years ago

ArendPWS commented 3 years ago

After cleaning up my database from erroneous data caused by the previous issues, I noticed that the rainRate field in the database shows no data but only zeroes after WeeWX performs a complete backfill. Below is my WeeWX config. Besides the unneeded Beaufort (not in database) and ET parameters, all the other (derived) parameters are calculated and stored correctly. What could be the cause for this behaviour of not calculating and storing the rainRate?

[StdWXCalculate]

[[Calculations]]
    # How to calculate derived quantities.  Possible values are:
    #  hardware        - use the value provided by hardware
    #  software        - use the value calculated by weewx
    #  prefer_hardware - use value provide by hardware if available,
    #                      otherwise use value calculated by weewx

    pressure = prefer_hardware
    altimeter = prefer_hardware
    appTemp = prefer_hardware
    barometer = prefer_hardware
    beaufort = prefer_hardware
    cloudbase = prefer_hardware
    dewpoint = prefer_hardware
    ET = prefer_hardware
    heatindex = prefer_hardware
    humidex = prefer_hardware
    inDewpoint = prefer_hardware
    maxSolarRad = prefer_hardware
    rainRate = prefer_hardware
    windchill = prefer_hardware
    windrun = prefer_hardware
BobAtchley commented 3 years ago

I have the same settings (slightly different order and I don't have the beaufort). When running normally the driver is pulling off readings off the console every 12 seconds and I assume the rainrate provided by the console reflects that time difference.

When backfilling the readings are dependent on how you set your console. Mine are at 5 minute intervals, so rain rate is presumably averaged over this interval. If you have a longer period then the rainrate will be averaged over the longer period.

Of course weewx records at 5 minute intervals, I'm not sure what it does with the 12 second data.

I'm not sure that fully explains it. Of course its not raining here and I clear the console data at the beginning of each month, but I'll have a check when it next rains to see whats been recorded and what gets back filled.

ArendPWS commented 3 years ago

Those zeroes could/should mean that something is being calculated and that the result is 0? If there was no required data available I guess the resulting output would be 'None'. The code used by WeeWX to calculate the rainRate is in /bin/weewx/wxservices.py.

When backfilling the readings are dependent on how you set your console. Mine are at 5 minute intervals, so rain rate is presumably averaged over this interval. If you have a longer period then the rainrate will be averaged over the longer period.

My settings are equal to yours: 5 minutes. I had a quick look at the Weewx code, but haven't figured out yet how the calculation is done. If I understand more about how it works, I will let you know.

ArendPWS commented 3 years ago

I haven't found an answer yet to the question why there are no valid entries regarding rainRate after a backfill. But I have found some interesting differences between WeeWX and the console in the way the rainRate is calculated. The console uses a sliding window of an hour to perform the calculation opposed to WeeWX which uses a sliding window of 900 seconds (15 minutes). After WeeWX has performed its calculation, the result is scaled to an hour. Looking at my data this makes a big difference. I found an example for the 17th of august this year. The console shows a maximum rain rate of 20 mm/h where WeeWX shows a rain rate of 80 mm/h. That is exactly a factor of 4.

ArendPWS commented 3 years ago

Problem solved, but I had to make some changes to your driver as rainRate calculated by the console wasn't present in a packet. You had assigned/mapped the rainRate of the console to packet ['hourRain']. Assigning/mapping the calculation of the console to ['rainRate'] made the backfill work. After applying these changes running backfill started filling the database with the rainRate values from the console memory. Making this change also means that the rainrate of the console is now available for observations. In case someone prefers the WeeWX calculation instead of the console calculation the WeeWX configuration should be modified like this:

[StdWXCalculate] [[Calculations]] rainRate = software

I haven't tested the behaviour on backfill when one chooses to prefer the option rainRate = software. It takes a lot of time for WeeWX to do a backfill, all this time (2 hours in my case) no new entries were stored in memory (so losing data).

I have also added packet ['heatindex'] as this was missing from your driver. Same story here: if one prefers the WeeWX calculation then WeeWX conf should be modified like this.

[StdWXCalculate] [[Calculations]] heatindex = software

Please take a look at the code in my fork to make things more clear. Besides the aformentioned changes I also added some general comments to the files in the fork. Let me know what your opinion is on these changes.

WS6in1 fork

BobAtchley commented 3 years ago

Just to let you know I have a new version ready to upload (based on your changes) but I want to test the rainrate first ... and of course its not raining (and no sign of any rain for the next 5 days - who says it rains in Britain all the time). Thanks for your time and effort in sorting this.

BobAtchley commented 3 years ago

After a long wait ... at last some rain. Everything seems to be working as expected. I think I prefer WeeWx calculation of RainRate as short sharp shower intensity is lost using the Console. I have no particular preference on the HeatIndex so have set it to hardware.