Recalculate rainrate values

111 views
Skip to first unread message

Maarten van der Hoeven

unread,
Jan 14, 2023, 9:45:54 AM1/14/23
to weewx-user
Hi. I have a Davis Vantage Pro 2. StdWxCalculate says that rainrate should be taken from 'prefered hardware'.

However, I needed to add some rainticks into the database, to correct daily rainfall sums (long story, tipping bucket broke down). I want to recalculate all rainrate values.

What is the way to do that?

I tried wee_database --drop-daily and --rebuild-daily, but the stored rainrate values remain the same (which makes sense, as in StdWxCalculate it should take them from hardware, which Davis provides). But now, I want to recalculate rainrate values, based on the rain-values that's already in the database.

Can this be done? How?

gjr80

unread,
Jan 14, 2023, 5:17:09 PM1/14/23
to weewx-user
You should try using the --calc-missing action with wee_database. --calc-missing will calculate any missing derived observations in your database, rainRate is a derived observation as far as WeeWX is concerned, you may have prefer_hardware against rainRate in StdWXCalculate but that should not matter in this case (prefer_hardware simply means try to get the observation from the station/driver and if you can't calculate it). wee_database does not interrogate your station/driver for data in any way.

Note that for wee_database to consider an observation to be 'missing' the corresponding database field(s) must be empty or have been set to null/None. Being set to 0 (zero) is not considered empty nor is saving a zero length string (as can happen sometimes when using a graphical frontend to edit your database) and hence will not be re-calculated. Assuming you are dealing with a small segment of your data, you may wish to use the --from and --to command line options when using --calc-missing to limit the date span to be re-calculated.

Gary

Maarten van der Hoeven

unread,
Jan 15, 2023, 5:02:56 AM1/15/23
to weewx-user
Hi, thx for the response.I must be overlooking something, as the rainrate becomes zero. I took just one day, January 12, 2023. Below what I did:

1. Stop weewx: /etc/init.d/weewx stop

2. Set rainrate to NULL for 12-01-2023
 SQL: update archive set rainrate = NULL where date_format(from_unixtime(dateTime), '%d-%m-%Y') LIKE '12-01-2023';

3. Check for NULL (just a snippet) from 12-01-2023
SQL: select date_format(from_unixtime(dateTime), '%d-%m-%Y %H:%i') as datumtijd, round(rain,1) as rain,round(rainrate,1) as rainrate from archive where rain > 0 and date_format(from_unixtime(dateTime), '%d-%m-%Y') LIKE '12-01
-2023';
+------------------+------+----------+
| datumtijd        | rain | rainrate |
+------------------+------+----------+
| 12-01-2023 00:18 |  0.2 |     NULL |
| 12-01-2023 11:07 |  0.2 |     NULL |
| 12-01-2023 11:58 |  1.0 |     NULL |
| 12-01-2023 12:00 |  0.5 |     NULL |
| 12-01-2023 12:01 |  0.5 |     NULL |
| 12-01-2023 12:02 |  0.5 |     NULL |
| 12-01-2023 12:03 |  0.5 |     NULL |
<snip>

4. Run wee_database --calc-missing --date=2023-01-12
Using configuration file /etc/weewx/weewx.conf
Using database binding 'wx_binding', which is bound to database 'archive_mysql'
Missing derived observations will be calculated from 2023-01-12 00:00:01 CET (1673478001) through to 2023-01-13 00:00:00 CET (1673564400) inclusive.
Proceed (y/n)? y
Calculating missing derived observations...
Type beaufort has been deprecated. Use unit beaufort instead.
Processing record: 1440; Last record: 2023-01-13 00:00:00 CET (1673564400)
Recalculating daily summaries...
Records processed: 1000; time: 2023-01-12 16:40:00 CET (1673538000)
Finished recalculating daily summaries
Missing derived observations calculated in 1.33 seconds

5. Check for rainrate
SQL: select date_format(from_unixtime(dateTime), '%d-%m-%Y %H:%i') as datumtijd, round(rain,1) as rain,round(rainrate,1) as rainrate from archive where rain > 0 and date_format(from_unixtime(dateTime), '%d-%m-%Y') LIKE '12-01-2023';
+------------------+------+----------+
| datumtijd        | rain | rainrate |
+------------------+------+----------+
| 12-01-2023 00:18 |  0.2 |      0.0 |
| 12-01-2023 11:07 |  0.2 |      0.0 |
| 12-01-2023 11:58 |  1.0 |      0.0 |
| 12-01-2023 12:00 |  0.5 |      0.0 |
| 12-01-2023 12:01 |  0.5 |      0.0 |
| 12-01-2023 12:02 |  0.5 |      0.0 |
| 12-01-2023 12:03 |  0.5 |      0.0 |
| 12-01-2023 12:04 |  0.5 |      0.0 |
| 12-01-2023 12:05 |  0.5 |      0.0 |
| 12-01-2023 12:06 |  0.5 |      0.0 |
| 12-01-2023 12:07 |  0.5 |      0.0 |
| 12-01-2023 12:08 |  0.5 |      0.0 |
| 12-01-2023 12:09 |  0.5 |      0.0 |
| 12-01-2023 12:10 |  0.5 |      0.0 |
| 12-01-2023 12:11 |  0.5 |      0.0 |
| 12-01-2023 12:12 |  0.5 |      0.0 |
| 12-01-2023 12:13 |  0.5 |      0.0 |



What am I overlooking/missing?


Op zaterdag 14 januari 2023 om 23:17:09 UTC+1 schreef gjr80:

gjr80

unread,
Jan 15, 2023, 5:59:08 PM1/15/23
to weewx-user
You have overlooked nothing, it is I that overlooked something. There is a known issue with wee_database --calc-missing whereby it cannot calculate rainRate and returns 0.0, at the moment the issue has been identified but not addressed. I need to find and implement a solution. The good thing is you have your corrected rainfall data saved to database and when we get the --calc-missing rainRate issue resolved it will be a simple matter to recalculate the missing rainRate data.

Gary

Reply all
Reply to author
Forward
0 new messages