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

Why pressure is not used to calculate relative humidity? #518

Open
fabeit opened this issue Jun 27, 2015 · 10 comments
Open

Why pressure is not used to calculate relative humidity? #518

fabeit opened this issue Jun 27, 2015 · 10 comments

Comments

@fabeit
Copy link

fabeit commented Jun 27, 2015

@mdietze
In this formula to convert RH to SH pressure is not included, why? Isn't RH dependent on pressure?

' converts relative humidity to specific humidity

' @title RH to SH

' @param rh relative humidity (proportion, not %)

' @param T absolute temperature (Kelvin)

' @export

' @author Mike Dietze

' @Aliases rh2rv

rh2qair <- function(rh, T){
qair <- rh * 2.541e6 * exp(-5415.0 / T) * 18/29
return(qair)
}

@ankurdesai
Copy link
Contributor

It should be, but for atmospheric sea level surface pressure range, the effect is relatively small.
see: http://www.humidity-calculator.com/index.php http://www.humidity-calculator.com/index.php
and: http://www.humidity-calculator.com/index.php http://www.humidity-calculator.com/index.php

It should essentially be the reverse of qcshum in metutils which goes from SH to RH.
Use Clausius-Clapeyron approximation to get saturation vapor pressure (Es in Pa) from Tair
Multiple Rh by Es to get vapor pressure (E) in Pa
Convert E to SH (or AH) in kg/kg based on air pressure (in Pa)

rh2qair looks like an approximation. A good test would be qair2rh(rh2qair(R,T) should return R within approximation


Ankur R Desai, Associate Professor
University of Wisconsin - Madison, Atmospheric and Oceanic Sciences
http://flux.aos.wisc.edu http://flux.aos.wisc.edu/ desai@aos.wisc.edu mailto:desai@aos.wisc.edu
O: +1-608-520-0305 / M: +1-608-218-4208

On Jun 27, 2015, at 3:41 AM, fabeuw notifications@github.com wrote:

@mdietze https://github.com/mdietze
In this formula to convert RH to SH pressure is not included, why? Isn't RH dependent on pressure?
##' converts relative humidity to specific humidity
##' @title https://github.com/title RH to SH
##' @param https://github.com/param rh relative humidity (proportion, not %)
##' @param https://github.com/param T absolute temperature (Kelvin)
##' @export https://github.com/export
##' @author https://github.com/author Mike Dietze
##' @Aliases https://github.com/aliases rh2rv
rh2qair <- function(rh, T){
qair <- rh * 2.541e6 * exp(-5415.0 / T) * 18/29
return(qair)
}


Reply to this email directly or view it on GitHub #518.

@mdietze
Copy link
Member

mdietze commented Jun 30, 2015

If anyone, whether a professor in atmospheric science or otherwise, wants to submit a pull request with a more accurate version I'd be happy for the update.

@fabeit
Copy link
Author

fabeit commented Jun 30, 2015

I actually tried both rh2qair and then used qair2rh and solved for qair, the difference is indeed small.

summary(ncep) calculated with rh2qair function from @mdietze
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.01080 0.01533 0.01602 0.01605 0.01684 0.02020
summary(ncep) calculated with qair2rh function from @dlebauer solved for qair
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.01083 0.01544 0.01614 0.01617 0.01695 0.02034

@ankurdesai
Copy link
Contributor

Wait till you get to the mountains. Also, one expects Kelvin, the other Celcius. fix is on the way.


Ankur R Desai, Associate Professor
University of Wisconsin - Madison, Atmospheric and Oceanic Sciences
http://flux.aos.wisc.edu http://flux.aos.wisc.edu/ desai@aos.wisc.edu mailto:desai@aos.wisc.edu
O: +1-608-520-0305 / M: +1-608-218-4208

On Jun 30, 2015, at 12:40 PM, fabeuw notifications@github.com wrote:

I actually tried both rh2qair and then used qair2rh and solved for qair, the difference is indeed small.

summary(ncep) calculated with rh2qair function from @mdietze https://github.com/mdietze
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.01080 0.01533 0.01602 0.01605 0.01684 0.02020
summary(ncep) calculated with qair2rh function from @dlebauer https://github.com/dlebauer solved for qair
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.01083 0.01544 0.01614 0.01617 0.01695 0.02034


Reply to this email directly or view it on GitHub #518 (comment).

@ankurdesai
Copy link
Contributor

But it’s so much more fun to just whine about it :)

Well just made a pull request to make the function be exactly correct, but not break existing calls to it.

Two issues:
qair2rh works in Celcius and millibar, and assigns a default pressure of 1 ATM if one is not passed
rh2qair works in Kelvin

rh2qair is called in met2CF Ameriflux/CSV/ALMA and temporal downscaling, two of these functions don’t read in pressure currently. qair2rh is called in met2model for BIOCRO/SIPNET and temporal downscaling. So 7 functions need to be changed if we want a) to make all this be in SI units and b) pass pressure around in both cases.

For now, the pull request allows a pressure in Pa to be passed to rh2qair, but doesn’t otherwise change functionality.


Ankur R Desai, Associate Professor
University of Wisconsin - Madison, Atmospheric and Oceanic Sciences
http://flux.aos.wisc.edu http://flux.aos.wisc.edu/ desai@aos.wisc.edu mailto:desai@aos.wisc.edu
O: +1-608-520-0305 / M: +1-608-218-4208

On Jun 30, 2015, at 6:23 AM, Michael Dietze notifications@github.com wrote:

If anyone, whether a professor in atmospheric science or otherwise, wants to submit a pull request with a more accurate version I'd be happy for the update.


Reply to this email directly or view it on GitHub #518 (comment).

@fabeit
Copy link
Author

fabeit commented Jun 30, 2015

great, thanks for that. Yes why not just have all the same units?!

@mdietze
Copy link
Member

mdietze commented Jun 30, 2015

Thanks @ankurdesai, I just merged that pull request. I'm going to leave this issue open so we remember to go back and standardize units and pass pressure explicitly.

@dlebauer
Copy link
Member

dlebauer commented Jul 1, 2015

Yes why not just have all the same units?!

@fabeuw I think the answer is different authors.

pass pressure explicitly

@mdietze some data sources don't provide pressure, thus the defaults. We could use an elevation correction (e.g. the rgbif package has a function elevation that takes latlon).

@ashiklom
Copy link
Member

@mdietze @ankurdesai Have we remembered to "go back and standardize units and pass pressure explicitly?". Is it still worth keeping this issue open? (Keeping in mind that closed issues are still 100% searchable, and can always be re-opened.)

@github-actions
Copy link

github-actions bot commented May 1, 2020

This issue is stale because it has been open 365 days with no activity.

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

No branches or pull requests

6 participants