Skip to content

Commit

Permalink
WU: Derive cloud icon from cloud cover percentage.
Browse files Browse the repository at this point in the history
  • Loading branch information
chaunceygardiner committed Aug 23, 2020
1 parent dfbd9ac commit 0b4828e
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions bin/user/forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -2543,7 +2543,20 @@ def create_records_from_five_day(fc, issued_ts, now, location=None):
r['event_ts'] = event_ts
r['hour'] = hour
r['duration'] = 12 * 3600
r['clouds'] = WUForecast.WU_SKY_DICT.get(fc['daypart'][0]['wxPhraseShort'][daypart_index])
# Clouds
cloud_cover_pct = fc['daypart'][0]['cloudCover'][daypart_index]
if cloud_cover_pct == 0:
r['clouds'] = 'CL'
elif cloud_cover_pct < 25:
r['clouds'] = 'FW'
elif cloud_cover_pct < 50:
r['clouds'] = 'SC'
elif cloud_cover_pct == 50:
r['clouds'] = 'BK'
elif cloud_cover_pct < 75:
r['clouds'] = 'B1'
else:
r['clouds'] = 'OV'
if half_day_index == 0:
r['tempMax'] = Forecast.str2float(
'temperatureMax', fc['temperatureMax'][half_day_index], WU_KEY)
Expand Down Expand Up @@ -2593,14 +2606,6 @@ def create_records_from_five_day(fc, issued_ts, now, location=None):

return records, msgs

WU_SKY_DICT = {
'Sunny': 'CL',
'M Sunny': 'FW',
'P Sunny': 'SC',
'P Cloudy': 'B1',
'M Cloudy': 'B2',
'Cloudy': 'OV'}

str2precip_dict = {
# nws precip strings
'Rain': 'rain',
Expand Down

0 comments on commit 0b4828e

Please sign in to comment.