From 9554c8c4cfb7865ad373b32661637cc702a4fe88 Mon Sep 17 00:00:00 2001 From: Remington Gerras Date: Tue, 17 Oct 2023 14:05:20 -0300 Subject: [PATCH 1/3] Added wind chill temperature to acquisition data --- socs/agents/vantagepro2/drivers.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/socs/agents/vantagepro2/drivers.py b/socs/agents/vantagepro2/drivers.py index bd6f822ae..a06262070 100644 --- a/socs/agents/vantagepro2/drivers.py +++ b/socs/agents/vantagepro2/drivers.py @@ -1,6 +1,7 @@ import array as arr import struct import time +import numpy as np from serial import Serial @@ -51,12 +52,22 @@ def calc_crc(data): crc = crc % 65536 return crc - def F_to_C(temp): """Function to convert fahrenheit measurement to celsius""" return (temp - 32) * (5 / 9) +def wind_chill(temp, wind): + """Function to calculate wind chill temperature. Only valid if temp < 50F. + Taken from https://www.calculator.net/wind-chill-calculator.html + If temp > 50F, need to use heat index instead... + + Temp: Temperature in Fahrenheit + wind: Speed in miles per hour + """ + + chill = 35.75 + 0.6215*temp - 35.75*np.power(wind,0.16) + 0.4275*temp*np.power(wind,0.16) + return chill class VantagePro2: """Allows communication to Vantage Pro 2 Weather Monitor Module. @@ -318,6 +329,11 @@ def receive_data(self): loop_data['time_sunrise'] = byte_data[75] loop_data['time_sunset'] = byte_data[76] + # Add wind chill temperature to observation data + temp = byte_data[9] / 10.0 + wind_speed = byte_data[10] + loop_data['wind_chill_temp'] = F_to_C(wind_chill(temp, wind_speed)) + # Correct UV Index by a factor of 10 and fix overflow uvi = loop_data['UV'] if uvi < 0: From 8b607101b63313a14846aab8dce979d02599ab4f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Oct 2023 17:10:35 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- socs/agents/vantagepro2/drivers.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/socs/agents/vantagepro2/drivers.py b/socs/agents/vantagepro2/drivers.py index a06262070..ce75ac959 100644 --- a/socs/agents/vantagepro2/drivers.py +++ b/socs/agents/vantagepro2/drivers.py @@ -1,8 +1,8 @@ import array as arr import struct import time -import numpy as np +import numpy as np from serial import Serial # some commands require a CRC code (cyclic redundancy check) - @@ -52,11 +52,13 @@ def calc_crc(data): crc = crc % 65536 return crc + def F_to_C(temp): """Function to convert fahrenheit measurement to celsius""" return (temp - 32) * (5 / 9) + def wind_chill(temp, wind): """Function to calculate wind chill temperature. Only valid if temp < 50F. Taken from https://www.calculator.net/wind-chill-calculator.html @@ -66,9 +68,10 @@ def wind_chill(temp, wind): wind: Speed in miles per hour """ - chill = 35.75 + 0.6215*temp - 35.75*np.power(wind,0.16) + 0.4275*temp*np.power(wind,0.16) + chill = 35.75 + 0.6215 * temp - 35.75 * np.power(wind, 0.16) + 0.4275 * temp * np.power(wind, 0.16) return chill + class VantagePro2: """Allows communication to Vantage Pro 2 Weather Monitor Module. Contains commands to be issued and member variables that store From d3f0f85cff56973c751435c8c78dd8786c3da40c Mon Sep 17 00:00:00 2001 From: Brian Koopman Date: Thu, 29 Feb 2024 11:07:18 -0500 Subject: [PATCH 3/3] Limit wind chill calc upper range --- socs/agents/vantagepro2/drivers.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/socs/agents/vantagepro2/drivers.py b/socs/agents/vantagepro2/drivers.py index ce75ac959..70e8103d4 100644 --- a/socs/agents/vantagepro2/drivers.py +++ b/socs/agents/vantagepro2/drivers.py @@ -67,6 +67,9 @@ def wind_chill(temp, wind): Temp: Temperature in Fahrenheit wind: Speed in miles per hour """ + # Calculation not valid above 50 F + if temp > 50: + return temp chill = 35.75 + 0.6215 * temp - 35.75 * np.power(wind, 0.16) + 0.4275 * temp * np.power(wind, 0.16) return chill