Skip to content

Instantly share code, notes, and snippets.

@UnforeseenOcean
Created July 1, 2021 02:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save UnforeseenOcean/6b759562a61af8c6907b0315b7a68200 to your computer and use it in GitHub Desktop.
Save UnforeseenOcean/6b759562a61af8c6907b0315b7a68200 to your computer and use it in GitHub Desktop.
Apparent temperature calculation
# Apparent temperature calculation ("Feels Like" temperature)
# T: Temperature in Fahrenheit, H: Relative Humidity
# -42.58 + (2.049 * T) + (10.14 * H) + (-0.2248 * T * H) + (-0.006838 * T^2) + (-0.05482 * H^2) + (0.001228 * T^2 * H) + (0.0008528 * T * H^2) + (-0.00000199 * T^2 * H^2)
import math
T = float(input("Enter temperature in Celsius: "))
H = float(input("Enter Relative Humidity: "))
# Convert the temperature from C to F for calculation
T = (T * 9/5)+32
# Source: https://meteor.geol.iastate.edu/~ckarsten/bufkit/apparent_temperature.html
result = -42.58 + (2.049 * T) + (10.14 * H) + (-0.2248 * T * H) + (-0.006838 * math.pow(T, 2)) + (-0.05482 * math.pow(H, 2)) + (0.001228 * math.pow(T, 2) * H) + (0.0008528 * T * math.pow(H, 2)) + (-0.00000199 * math.pow(T, 2) * math.pow(H, 2))
print("\n")
print("Fahrenheit:", result)
print("Celsius: ", (result-32)*5/9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment