Skip to content

Commit

Permalink
Added wind chill temperature to acquisition data
Browse files Browse the repository at this point in the history
  • Loading branch information
RemingtonGerras committed Oct 17, 2023
1 parent e021f7a commit 9554c8c
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion socs/agents/vantagepro2/drivers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import array as arr
import struct
import time
import numpy as np

from serial import Serial

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 9554c8c

Please sign in to comment.