Skip to content

Commit

Permalink
v2.4.0.b9: Add support for the following icons in WU forecasts: tstms…
Browse files Browse the repository at this point in the history
…, hail, dirzzle, sleet, frzngdrzl, frzngrain, flurries.
  • Loading branch information
chaunceygardiner committed Aug 25, 2020
1 parent 0d7f1ab commit 4dd390c
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 13 deletions.
53 changes: 42 additions & 11 deletions bin/user/forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@
from weewx.engine import StdService
from weewx.cheetahgenerator import SearchList

VERSION = "3.4.0b8"
VERSION = "3.4.0b9"

if weewx.__version__ < "4":
raise weewx.UnsupportedFeature(
Expand Down Expand Up @@ -2561,16 +2561,34 @@ def create_records_from_five_day(fc, issued_ts, now, location=None):
precip_type = fc['daypart'][0]['precipType'][daypart_index]
precip_chance = fc['daypart'][0]['precipChance'][daypart_index]
if precip_chance > 0 and (precip_type == 'rain' or precip_type == 'snow'):
if precip_chance < 30:
r[precip_type] = 'S'
elif precip_chance < 60:
r[precip_type] = 'C'
elif precip_chance < 80:
r[precip_type] = 'L'
elif precip_chance < 100:
r[precip_type] = 'O'
else:
r[precip_type] = 'D'
r[precip_type] = WUForecast.code_from_precip_chance(precip_chance)
# ThunderStorms
#wu_tstms_dict = {
# 0: None,
# 1: 'S',
# 2: 'C',
# 3: 'L',
# 4: 'O',
# 5: 'D'}
#thunder_index = fc['daypart'][0]['thunderIndex'][daypart_index]
#if thunder_index > 0:
# r['tstms'] = wu_tstms_dict[thunder_index]
# Look for other precip in iconCode
icon_code = fc['daypart'][0]['iconCode'][daypart_index]
if icon_code == 4 or icon_code == 37 or icon_code == 38 or icon_code == 47:
r['tstms'] = WUForecast.code_from_precip_chance(precip_chance)
if icon_code == 4 or icon_code == 17 or icon_code == 35:
r['hail'] = WUForecast.code_from_precip_chance(precip_chance)
if icon_code == 9:
r['drizzle'] = WUForecast.code_from_precip_chance(precip_chance)
if icon_code == 6 or icon_code == 7 or icon_code == 18:
r['sleet'] = WUForecast.code_from_precip_chance(precip_chance)
if icon_code == 8:
r['frzngdrzl'] = WUForecast.code_from_precip_chance(precip_chance)
if icon_code == 10:
r['frzngrain'] = WUForecast.code_from_precip_chance(precip_chance)
if icon_code == 13:
r['flurries'] = WUForecast.code_from_precip_chance(precip_chance)
if half_day_index == 0:
r['tempMax'] = Forecast.str2float(
'temperatureMax', fc['temperatureMax'][half_day_index], WU_KEY)
Expand Down Expand Up @@ -2717,6 +2735,19 @@ def create_records_from_five_day(fc, issued_ts, now, location=None):
'24': 'BS',
}

@staticmethod
def code_from_precip_chance(precip_chance):
if precip_chance < 30:
return 'S'
elif precip_chance < 60:
return 'C'
elif precip_chance < 80:
return 'L'
elif precip_chance < 100:
return 'O'
else:
return 'D'

@staticmethod
def str2pc(s):
"""parse a wu wx string for the precipitation type and likeliehood
Expand Down
2 changes: 1 addition & 1 deletion install.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def loader():
class ForecastInstaller(ExtensionInstaller):
def __init__(self):
super(ForecastInstaller, self).__init__(
version="3.4.0b8",
version="3.4.0b9",
name='forecast',
description='Generate and display weather and tide forecasts.',
author="Matthew Wall",
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Installation instructions:

1) run the installer:

wee_extension --install weewx-forecast-3.4.0b8.zip
wee_extension --install weewx-forecast-3.4.0b9.zip

2) modify weewx.conf for your location:

Expand Down

0 comments on commit 4dd390c

Please sign in to comment.