Skip to content

Commit

Permalink
If windGustDir is missing, substitute windDir.
Browse files Browse the repository at this point in the history
  • Loading branch information
tkeffer committed Feb 13, 2022
1 parent 279bb45 commit 9dc4da8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 9 additions & 2 deletions bin/weewx/wxxtypes.py
Expand Up @@ -98,11 +98,18 @@ def calc_windDir(self, key, data, db_manager):
return ValueTuple(val, 'degree_compass', 'group_direction')

def calc_windGustDir(self, key, data, db_manager):
# Return the current gust direction if windGust is non-zero, otherwise, None
if 'windGust' not in data or 'windGustDir' not in data:
"""If windGustDir is missing, substitute windDir.
Set windGustDir to None if windGust is zero."""
if 'windGust' not in data:
raise weewx.CannotCalculate
if self.force_null and data['windGust'] == 0:
# windGust is zero. Force windGustDir to None
val = None
elif 'windGustDir' not in data:
# windGustDir is missing. If available, substitute windDir.
if 'windDir' not in data:
raise weewx.CannotCalculate
val = data['windDir']
else:
val = data['windGustDir']
return ValueTuple(val, 'degree_compass', 'group_direction')
Expand Down
2 changes: 2 additions & 0 deletions docs/changes.txt
Expand Up @@ -9,6 +9,8 @@ Fixed spelling mistakes in the Norwegian translations. Thanks to Aslak! PR#746
Supply a sensible default context for group_deltatime when no context has been
specified.

If windGustDir is missing, substitute windDir.


4.6.2 02/10/2022
Removed diagnostic code that was inadverently left in the titlebar.inc file
Expand Down

0 comments on commit 9dc4da8

Please sign in to comment.