Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Apparent Temperature #206

Open
GlennGoddard opened this issue Jan 11, 2023 · 2 comments
Open

Add Apparent Temperature #206

GlennGoddard opened this issue Jan 11, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@GlennGoddard
Copy link
Contributor

New Feature

I always wanted a better 'feels like temperature' that incorporates sun light, I finally found it. I just didn't know it was call apparent temperature.

def calculate_apparent_temperature(temperature, relative_humidity, wind_speed, solar_radiation):
    # Constants
    T = temperature  # Air Temperature
    rh = relative_humidity  # relative humidity
    v = wind_speed  # Wind speed
    Sr = solar_radiation  # Solar Radiation
    
    # Apparent temperature calculation
    e = 6.11 * math.pow(10, (7.5 * T) / (237.3 + T)) * rh # Vapor pressure 
    w = 0.62198 * e / (273.16 + T) #Humidity index
    AT = T + 0.348 * e - 0.7 * v + 0.7 * Sr # Apparent temperature formula
    return AT

Additional context

I won't overload you with PRs at this time. I will wait until 'Current Conditions' is done.
This is just the bulk of the calculation, making it pretty comes later.

@GlennGoddard GlennGoddard added the enhancement New feature or request label Jan 11, 2023
@GlennGoddard
Copy link
Contributor Author

GlennGoddard commented Jan 11, 2023

oh, we could do vapor pressure and humidity index as their own sensors also.
I did see that you had vapor pressure in your original UDP repository but I don't see it here, is there a reason or just forgot?

@GlennGoddard
Copy link
Contributor Author

Updated, still testing. Waiting for an 80F day.

// Apparent Temperature: The perceived temperature in degrees Fahrenheit derived from either a combination of temperature and wind (Wind Chill) or temperature and humidity (Heat Index) for the indicated hour. When the temperature at a particular grid point falls to 50 F or less, wind chill will be used for that point for the Apparent Temperature. When the temperature at a grid point rises above 80 F, the heat index will be used for Apparent Temperature. Between 51 and 80 F, the Apparent Temperature will be the ambient air temperature
// https://meteor.geol.iastate.edu/~ckarsten/bufkit/apparent_temperature.html

T = msg.temperature
rh = msg.humidity
v = msg.wind_speed
sr = msg.sr  // Solar Radiation
wind_chill = msg.wind_chill
c1 = -42.38
c2 = 2.049
c3 = 10.14
c4 = -0.2248
c5 = -0.006838
c6 = -0.05482
c7 = 0.001228
c8 = 0.0008528
c9 = -0.00000199

HI = c1 + c2*T + c3*rh + c4*T*rh + c5*T*T + c6*rh*rh + c7*T*T*rh + c8*T*rh*rh + c9*T*T*rh*rh

if (T <= 50) {
    AT = wind_chill;
} else if (T <= 80){
    AT = T;
} else{
    AT = HI;
}

AT = Math.round(AT*100)/100
//AT = (Math.round(((AT * 1.8) + 32)*100))/100
msg.payload = AT
return msg;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant