From: Alexander Vasarab Date: Fri, 5 Mar 2021 03:38:01 +0000 (-0800) Subject: Fix bug in which MesoWest HS unit was incorrect X-Git-Tag: v3.2.4^2~1^2 X-Git-Url: https://wylark.com/src/infoex-autowx.git/commitdiff_plain/c3f872e24d2f52b3cfaf441dfa6c5d2174a273fc Fix bug in which MesoWest HS unit was incorrect --- diff --git a/infoex-autowx.py b/infoex-autowx.py index fd01e04..c3144a4 100755 --- a/infoex-autowx.py +++ b/infoex-autowx.py @@ -528,6 +528,10 @@ def get_mesowest_data(begin, end, station): # we want mph if element_cd in ('wind_speed', 'wind_gust'): remote_data[element_cd] = kn_to_mph(remote_data[element_cd]) + + # mesowest provides HS in mm, not cm; we want cm + if element_cd == 'snow_depth' and station['units'] == 'metric': + remote_data[element_cd] = mm_to_cm(remote_data[element_cd]) else: remote_data[element_cd] = None else: @@ -625,5 +629,9 @@ def kn_to_mph(kn): """convert knots to miles per hour""" return kn * 1.150779 +def mm_to_cm(mm): + """convert millimeters to centimetrs""" + return mm / 10.0 + if __name__ == "__main__": sys.exit(main())