Skip to content

Instantly share code, notes, and snippets.

@mumblepins
Created July 20, 2016 00:46
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mumblepins/d4e6f2189200cbd0914e217a2e4adde9 to your computer and use it in GitHub Desktop.
Save mumblepins/d4e6f2189200cbd0914e217a2e4adde9 to your computer and use it in GitHub Desktop.
Accuweather Realfeel temperature calculator
# Based on patent https://www.google.com/patents/US7251579
# Not responsible if you use this for anything other than personal use
from math import sqrt
def realfeel(W, #windspeed mph
A, #pressure mb
T, # temperature F
UV, # UV Index
D, # Dew Point F
P2, # preciptation Factor from 0-5
):
if W<4:
Wa=W/2+2
elif W<56:
Wa=W
else:
Wa=56
# print Wa
WSP2=(80-T)*(0.566+0.25*sqrt(Wa)-0.0166*Wa)*((sqrt(A/10))/10)
WSP1=sqrt(W)*((sqrt(A/10))/10)
# print WSP2
SI2 = UV # UV index is already in hectoJoules/m^2 ?
if D >= (55+sqrt(W)):
Da=D
else:
Da=55+sqrt(W)
# print Da
H2=(Da-55-sqrt(W))**2/30
# print H2
if T>= 65:
MFT=80-WSP2+SI2+H2-P2
else:
MFT=T-WSP1+SI2+H2-P2
return MFT
print realfeel(5,1013,70,6,50,0)
@AFishNamedFish
Copy link

AFishNamedFish commented Jun 26, 2018

Great script!

Just curious, what do you use for the "precipitation factor" value?

AccuWeather (as well as the other weather services) does not appear to display this figure on their weather webpages. An online search for the term reveals that it is not an industry-used term, so I wonder if this figure is an AccuWeather proprietary calculation.

Update:

Never mind, I understand how it is calculated now, after clicking on the patent link.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment