NuWeather: update temperature colour scheme

This commit is contained in:
James Lu 2022-12-15 18:50:33 -08:00
parent 4e132d708c
commit 31c97a646b

View File

@ -84,22 +84,22 @@ def format_temp(displaymode, f=None, c=None):
c = (f - 32) * 5/9 c = (f - 32) * 5/9
f = float(f) f = float(f)
if f < 10: # Roughly inspired by https://www.esri.com/arcgis-blog/products/arcgis-pro/mapping/a-meaningful-temperature-palette/
color = 'light blue' if f > 100:
elif f < 32: color = '4' # red
color = 'teal' elif f > 85:
elif f < 50: color = '7' # orange
color = 'blue' elif f > 75:
elif f < 60: color = '8' # yellow
color = 'light green' elif f > 60:
elif f < 70: color = '9' # light green
color = 'green' elif f > 40:
elif f < 80: color = '11' # cyan
color = 'yellow' elif f > 10:
elif f < 90: color = '12' # light blue
color = 'orange'
else: else:
color = 'red' color = '15' # light grey
# Show temp values to one decimal place # Show temp values to one decimal place
c = '%.1f' % c c = '%.1f' % c
f = '%.1f' % f f = '%.1f' % f
@ -114,7 +114,7 @@ def format_temp(displaymode, f=None, c=None):
s = '%sC' % c s = '%sC' % c
else: else:
raise ValueError("Unknown display mode for temperature.") raise ValueError("Unknown display mode for temperature.")
return ircutils.mircColor(s, color) return f'\x03{color.zfill(2)}{s}\x03'
def wind_direction(angle): def wind_direction(angle):
"""Returns wind direction (N, W, S, E, etc.) given an angle.""" """Returns wind direction (N, W, S, E, etc.) given an angle."""