[StdCalibrate] Wind Logic

148 views
Skip to first unread message

Rory Gillies

unread,
Jan 15, 2025, 11:53:42 AM1/15/25
to weewx-user
I know I could just try this but interested to hear if it would work, or if I have any other options. WeeWX 5.1.

Is it possible to use logic in StdCalibrate in weewx.con? Something like this:

[StdCalibrate]
    if windSpeed == 0 windspeed = windspeed + 15
    if windDir == NULL windDir = windDir + 235

The reason is I have a dying anemometer and it's going to take a couple of weeks to get a replacement installed (it's on my chimney 8m above the ground). When the wind blows from SSW to WSW above 20mph it sometimes drops to zero every few loop packets (other times it is perfect).

Screenshot 2025-01-15 at 16.49.12.png

I know the observations will be technically incorrect but better than no wind at all!

michael.k...@gmx.at

unread,
Jan 15, 2025, 12:47:38 PM1/15/25
to weewx-user
Yes it is. I have a station with two Anemometers and I mix them in the way, that always the higher windSpeed/windGust will be used, if both are there, or the one that's there. Anemometers freeze or sometime I have Signal strength issues. I always take the direction of a specific one (an ultrasonic with heating, that won't freeze), except it isn't there. It's quite a brainf*ck, but it works. Some other Corrections are also done:

[StdCalibrate]
   
    [[Corrections]]
        
        radiation = luminosity/126.7 if luminosity is not None else None    #gw1000 fix
        lightning_distance = lightning_distance if lightning_strike_count > 0 else None
        windSpeed = ws90_windSpeed if 'windSpeed' not in locals() else windSpeed if 'ws90_windSpeed' not in locals() else ws90_windSpeed if ws90_windSpeed > windSpeed else windSpeed
        windGust = ws90_windGust if 'windGust' not in locals() else windGust if 'ws90_windGust' not in locals() else ws90_windGust if ws90_windGust > windGust else windGust
        windDir = ws90_windDir if 'ws90_windDir' in locals() and ws90_windDir is not None else windDir




michael.k...@gmx.at

unread,
Jan 15, 2025, 12:48:53 PM1/15/25
to weewx-user

michael.k...@gmx.at

unread,
Jan 15, 2025, 1:09:54 PM1/15/25
to weewx-user

For your specific case I'd just kick zero wind loop packets out:

windSpeed = None if windSpeed == 0 else windSpeed, loop

The windDir should be "None" if windSpeed is zero anyway, but to be sure:

windDir = None if windSpeed == 0 else windDir, loop

Rory Gillies

unread,
Jan 16, 2025, 4:00:54 AM1/16/25
to weewx-user
Thanks Michael,

Based on the values being calculated in order (as it says in the docs) I tried the following which didn't work (although no errors when starting WeeWX):

[StdCalibrate]
  [[Corrections]]
    windSpeed = 20 if windSpeed == 0 else windSpeed == windSpeed * 1.15
    windGust = windSpeed + 10 if windGust == 0 else windGust == windGust * 1.15
    windDir = windDir if windDir is not None else windDir == 220


So I reversed it based on windDir being null which didn't work either:

windSpeed = windSpeed * 1.15 if winDir is not None else windSpeed == 20
windGust = windGust * 1.15 if windDir is not None else windGust == windSpeed + 10
windDir = windDir if windDir is not None else windDir == 220

This is the overnight plot, you can see it went off completely for a couple of hours after 04:00. I was working on it around between 22:00 and 00:00 when it started to drop.

Screenshot 2025-01-16 at 08.51.41.png
Also, I noticed a strange effect with the force_null setting, if I set it to True windDir appears to stay at the last known direction, if I set it as False windDir moves to north, I thought this was supposed to work the other way round?

Thanks,

Rory

Graham Eddy

unread,
Jan 16, 2025, 5:10:20 AM1/16/25
to WeeWX User
python syntax: should be = not == in the ‘else’s

semantics: presumably testing as they make no sense
⊣GE⊢

On 16 Jan 2025, at 8:00 pm, 'Rory Gillies' via weewx-user <weewx...@googlegroups.com> wrote:

Thanks Michael,

Based on the values being calculated in order (as it says in the docs) I tried the following which didn't work (although no errors when starting WeeWX):

[StdCalibrate]
  [[Corrections]]
    windSpeed = 20 if windSpeed == 0 else windSpeed == windSpeed * 1.15
    windGust = windSpeed + 10 if windGust == 0 else windGust == windGust * 1.15
    windDir = windDir if windDir is not None else windDir == 220


So I reversed it based on windDir being null which didn't work either:

windSpeed = windSpeed * 1.15 if winDir is not None else windSpeed == 20
windGust = windGust * 1.15 if windDir is not None else windGust == windSpeed + 10
windDir = windDir if windDir is not None else windDir == 220

This is the overnight plot, you can see it went off completely for a couple of hours after 04:00. I was working on it around between 22:00 and 00:00 when it started to drop.

--
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 visit https://groups.google.com/d/msgid/weewx-user/cd6cbe95-9bb7-42f5-8e40-b17937659d3an%40googlegroups.com.
<Screenshot 2025-01-16 at 08.51.41.png>

Rory Gillies

unread,
Jan 16, 2025, 5:33:55 AM1/16/25
to weewx-user
Hi Graham,

If I use '=' instead of '==' then weewx throws an error and exits:

2025-01-16T10:28:04.198797+00:00 weewx5 python3[2361]:   File "StdCalibrate", line 1
2025-01-16T10:28:04.198850+00:00 weewx5 python3[2361]:     windSpeed * 1.15 if winDir is not None else windSpeed = 20
2025-01-16T10:28:04.198911+00:00 weewx5 python3[2361]:                                                           ^
2025-01-16T10:28:04.198978+00:00 weewx5 python3[2361]: SyntaxError: invalid syntax
2025-01-16T10:28:04.199068+00:00 weewx5 weewxd[2361]: CRITICAL __main__:     ****                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-01-16T10:28:04.199130+00:00 weewx5 weewxd[2361]: CRITICAL __main__:     ****    File "StdCalibrate", line 1
2025-01-16T10:28:04.199179+00:00 weewx5 weewxd[2361]: CRITICAL __main__:     ****      windSpeed * 1.15 if winDir is not None else windSpeed = 20
2025-01-16T10:28:04.199230+00:00 weewx5 weewxd[2361]: CRITICAL __main__:     ****                                                            ^
2025-01-16T10:28:04.199314+00:00 weewx5 weewxd[2361]: CRITICAL __main__:     ****  SyntaxError: invalid syntax
2025-01-16T10:28:04.199402+00:00 weewx5 weewxd[2361]: CRITICAL __main__:     ****  Exiting.


Message has been deleted

Graham Eddy

unread,
Jan 16, 2025, 5:41:43 AM1/16/25
to WeeWX User
i mis-spoke. no assignment in ‘else’ e.g.
windSpeed = 20 if windSpeed == 0 else windSpeed*1.15
note: in this case, if windSpeed is None, then None*1.15 throws an error (silently, without enough debug level) and no action is taken i.e. it remains None
⊣GE⊢

michael.k...@gmx.at

unread,
Jan 16, 2025, 5:42:06 AM1/16/25
to weewx-user
this should be:

windSpeed * 1.15 if winDir is not None else 20

That being said, it shouldn't because it' s just a randomly guessed value.

michael.k...@gmx.at

unread,
Jan 16, 2025, 5:43:31 AM1/16/25
to weewx-user
Rory, did you try my proposed correction? Throwing away wrong values is imho the better choice over replacing them with other wrong values

Rory Gillies

unread,
Jan 16, 2025, 6:33:45 AM1/16/25
to weewx-user
Hi Michael,

Thanks for that. The problem is that it can drop out for a few hours with higher wind from SSW to WSW which skews the average windspeed. I use WXSim for forecasting so it's better to have a least some wind rather than none at the wrong direction. Both are wrong, but injecting a random value roughly around the average wind speed from roughly the right direction is - IMHO - better overall. The problem will go away when the contractor comes to replace it with a sonic anemometer at the beginning of February. The issue only occurs when the wind is above 20mph from around the SW. This is the second Davis anemometer that's died on me, the first one lasted just over a year was replaced under warranty but that doesn't cover the £300 to get it up on the roof! This one was installed last March so not even a year working.

If I throw away the erroneous values will that keep the correct wind speed average? Also, I use RTGD and it will stop after a while if it doesn't get any wind packets, which means a manual restart of WeeWX to get it running again.

You can see the problem here: www.360shetland.co.uk/weather

Cheers,

Rory

michael.k...@gmx.at

unread,
Jan 16, 2025, 8:03:46 AM1/16/25
to weewx-user
A "None" reading, a.k.a. missing values won't affect the average of the known values. So, assume the wind is constantly blowing at 20mph and you miss half of the the values, the calculated average is still 20mph. No (0, zero) wind has no direction, because it is a vector with zero length, which will be stored "None/null" in memry/database, at least in the weewx database. There won't be a zero wind value with a direction, if not manipulated elsewhere.
Reply all
Reply to author
Forward
0 new messages