Anyway, thank you for helping me with this one!
For the record:
I have two pieces of hardware, one is using a classic anemometer with cups, the other one is an ultrasonic device. With very low wind speeds, the classic one shows zero wind, while the ultrasonic one shows low, but very plausible values. The ultrasonic one also doesn't freeze or gets blocked by snow, because is has a heating. On the other hand, the ultrasonic device often misses wind gusts and lacks accuracy in wet conditions.
In short, the closes approach to represent reality is: always use the values from the sensor, which is showing the higher reading.
Also, the Wind direction of the ultrasonic device has a better resolution and no vane that sometimes doesn't move, even in wind speeds, the classic anemometer is rotating.
So the second thing is: always use windDir from the ultrasonic device.
Both readings arrive in the same loop packet, their names are "windSpeed" and "ws90_windSpeed" (the latter ultrasonic), together with their gust speed and direction, except for situations, the sensor's data cannot be received by the console. So my first approach
[StdCalibrate]
[[Corrections]]
windSpeed = ws90_windSpeed if ws90 if ws90_windSpeed > windSpeed else windSpeed
windGust = ws90_windGust if ws90_windGust > windGust else windGust
windDir = ws90_windDir if ws90_windDir is not None else windDir
is working, but only in cases, both of the readings are present.
Yesterday, windSpeed (from the classic device) was missing, where ws90_windSpeed was there. The result was, no windSpeed was recorded as at all, due to a python NameError, which was silently ignored.
try:
event.record[obs_type] = eval(self.corrections[obs_type], {'math': math},
event.record)
except (TypeError, NameError):
pass
So, if this should work as intended, we need to check if windSpeed is there, or not.
What I want is to
- store whatever wind speed/gust is the higher, if both are present
- store whatever wind speed/gust, when only one is present
- store the ultrasonic wind direction if present, or else the other one
For now, I use these expressions, and the loop packets look good, and there shouldn't be a need to check for both being present:
[StdCalibrate]
[[Corrections]]
# For each type, an arbitrary calibration expression can be given.
# It should be in the units defined in the StdConvert section.
# Example:
#foo = foo + 0.2
windSpeed = ws90_windSpeed if 'windSpeed' not in locals() or ws90_windSpeed > windSpeed else windSpeed
windGust = ws90_windGust if 'windGust' not in locals() or ws90_windGust > windGust else windGust
windDir = ws90_windDir if 'ws90_windDir' in locals() and ws90_windDir is not None else windDir
I think this way I think I get my desired results, but after a long week my brain is a bit overloaded. So if anybody with cognitive capacities left could check if my expressions really make that much sense: very much appreciated :)