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

Humidity differences in py and r #119

Open
1 task
Wangjiayi1115 opened this issue Sep 12, 2024 · 4 comments
Open
1 task

Humidity differences in py and r #119

Wangjiayi1115 opened this issue Sep 12, 2024 · 4 comments
Assignees
Milestone

Comments

@Wangjiayi1115
Copy link

Describe the bug

Here are the differences we have identified:

  • calculation of humidity

humidity

In py the calculation is link

hi = tdb + 5 / 9 * ((6.112 * 10 ** (7.5 * tdb / (237.7 + tdb)) * rh / 100) - 10)

In R the calculation is link

ta+5/9*(6.11*exp(5417.753*(1/273.15-1/(calcDewp(ta, rh)+273.15)))-10)

R Implementation:
The calculation uses the dew point temperature (calcDewp) as an intermediate step.This approach is based on the Clausius-Clapeyron equation, leveraging the dew point to determine vapor pressure before calculating the Humidex.

Python Implementation:
The calculation skips the dew point temperature and directly computes the saturated vapor pressure using Tetens’ formula.
It simplifies the process by directly using the dry bulb temperature and relative humidity to calculate vapor pressure.
@FedericoTartarini and Marcel to review

@FedericoTartarini
Copy link
Collaborator

@Wangjiayi1115 precision and attention to details is very important.

  1. This function is not called humidity but instead it is called humidex.
  2. From this pull request it is also not clear to me if this affects the results.

The rest of the pull request is great since it describes the issue.

Marcel, I cannot tag you again in this issue.

I am using the code from:
image

Where did you get your equation?

@marcelschweiker
Copy link
Collaborator

Mine was implemented by a colleague from Karlsruhe. He used Masterton and Richarddson (1979)
image
So, we have two options to proceed:
a) add the other version to each package to have two versions each and clarify which is which by giving them unique names.
b) change R to be in line with py as you used a more up-to-date version
I am fine with both and lean towards b.

@FedericoTartarini
Copy link
Collaborator

FedericoTartarini commented Sep 17, 2024

As you proposed in option a) we can keep both equations. In python, I will add an input to the humidex function similar to what I did for the PMV model
pythermalcomfort.models.pmv.pmv(tdb, tr, vr, rh, met, clo, wme=0, standard='ISO', units='SI', limit_inputs=True, airspeed_control=True)
In this case I will call it model and by defalt will be set to "rana" the other option will be "masterton". In the documentation I will also provide additional informations about the models.

@marcelschweiker What do you think?

@marcelschweiker
Copy link
Collaborator

Sounds good. Suggest then the same approach for R, i.e. having two alternatives and selection via "model" variable

@FedericoTartarini FedericoTartarini added this to the v3 milestone Oct 16, 2024
@FedericoTartarini FedericoTartarini self-assigned this Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants