Skip to contents

function to convert humidity to absolute humidity using Tetens formula, assuming standard atmosphere conditions.

Usage

rh2q(rh, temp = 15)

Arguments

rh

vector (or data.frame) of relative humidity (in percentage)

temp

vector (or data.frame) of temperature (in Celsius)

Value

value of data.frame with time and the absolute humidity, units are g/g

Note

default values are from standard atmosphere (288.15 K / 15 C)

if rh and temp arguments are data.frame, both need to have the same number of lines and columns, first column (time column) will be ignored.

Examples

# for a singfle value
rh2q(rh = 99, temp = 25)
#> [1] 0.0202236

# vector of rh values
rh2q(rh = c(0,seq(1,100, by = 4)), temp = 25)
#>  [1] 0.0000000000 0.0002042788 0.0010213938 0.0018385089 0.0026556240
#>  [6] 0.0034727390 0.0042898541 0.0051069692 0.0059240843 0.0067411993
#> [11] 0.0075583144 0.0083754295 0.0091925445 0.0100096596 0.0108267747
#> [16] 0.0116438897 0.0124610048 0.0132781199 0.0140952350 0.0149123500
#> [21] 0.0157294651 0.0165465802 0.0173636952 0.0181808103 0.0189979254
#> [26] 0.0198150404

# vector of values for rh and temp
rh2q(rh = c(0,seq(1,100, by = 4)), temp = 10:35)
#>  [1] 0.000000e+00 8.348345e-05 4.462669e-04 8.583979e-04 1.324373e-03
#>  [6] 1.849004e-03 2.437438e-03 3.095175e-03 3.828085e-03 4.642429e-03
#> [11] 5.544880e-03 6.542546e-03 7.642986e-03 8.854241e-03 1.018485e-02
#> [16] 1.164389e-02 1.324097e-02 1.498631e-02 1.689070e-02 1.896560e-02
#> [21] 2.122310e-02 2.367603e-02 2.633791e-02 2.922304e-02 3.234651e-02
#> [26] 3.572424e-02

# rh is data.frame and temp is a value
times <- seq(as.POSIXct('2024-01-01',tz = 'UTC'),
             as.POSIXct('2024-01-02',tz = 'UTC'),
             by = 'hour')
rh2q(rh   = data.frame(time = times, a = seq(1,100, by = 4)),temp = 25)
#>                   time            a
#> 1  2024-01-01 00:00:00 0.0002042788
#> 2  2024-01-01 01:00:00 0.0010213938
#> 3  2024-01-01 02:00:00 0.0018385089
#> 4  2024-01-01 03:00:00 0.0026556240
#> 5  2024-01-01 04:00:00 0.0034727390
#> 6  2024-01-01 05:00:00 0.0042898541
#> 7  2024-01-01 06:00:00 0.0051069692
#> 8  2024-01-01 07:00:00 0.0059240843
#> 9  2024-01-01 08:00:00 0.0067411993
#> 10 2024-01-01 09:00:00 0.0075583144
#> 11 2024-01-01 10:00:00 0.0083754295
#> 12 2024-01-01 11:00:00 0.0091925445
#> 13 2024-01-01 12:00:00 0.0100096596
#> 14 2024-01-01 13:00:00 0.0108267747
#> 15 2024-01-01 14:00:00 0.0116438897
#> 16 2024-01-01 15:00:00 0.0124610048
#> 17 2024-01-01 16:00:00 0.0132781199
#> 18 2024-01-01 17:00:00 0.0140952350
#> 19 2024-01-01 18:00:00 0.0149123500
#> 20 2024-01-01 19:00:00 0.0157294651
#> 21 2024-01-01 20:00:00 0.0165465802
#> 22 2024-01-01 21:00:00 0.0173636952
#> 23 2024-01-01 22:00:00 0.0181808103
#> 24 2024-01-01 23:00:00 0.0189979254
#> 25 2024-01-02 00:00:00 0.0198150404

# using both rh and temp are data.frames
rh2q(rh   = data.frame(time = times, a = seq(1,100, by = 4)),
     temp = data.frame(time = times, a = 11:35))
#>                   time            a
#> 1  2024-01-01 00:00:00 8.348345e-05
#> 2  2024-01-01 01:00:00 4.462669e-04
#> 3  2024-01-01 02:00:00 8.583979e-04
#> 4  2024-01-01 03:00:00 1.324373e-03
#> 5  2024-01-01 04:00:00 1.849004e-03
#> 6  2024-01-01 05:00:00 2.437438e-03
#> 7  2024-01-01 06:00:00 3.095175e-03
#> 8  2024-01-01 07:00:00 3.828085e-03
#> 9  2024-01-01 08:00:00 4.642429e-03
#> 10 2024-01-01 09:00:00 5.544880e-03
#> 11 2024-01-01 10:00:00 6.542546e-03
#> 12 2024-01-01 11:00:00 7.642986e-03
#> 13 2024-01-01 12:00:00 8.854241e-03
#> 14 2024-01-01 13:00:00 1.018485e-02
#> 15 2024-01-01 14:00:00 1.164389e-02
#> 16 2024-01-01 15:00:00 1.324097e-02
#> 17 2024-01-01 16:00:00 1.498631e-02
#> 18 2024-01-01 17:00:00 1.689070e-02
#> 19 2024-01-01 18:00:00 1.896560e-02
#> 20 2024-01-01 19:00:00 2.122310e-02
#> 21 2024-01-01 20:00:00 2.367603e-02
#> 22 2024-01-01 21:00:00 2.633791e-02
#> 23 2024-01-01 22:00:00 2.922304e-02
#> 24 2024-01-01 23:00:00 3.234651e-02
#> 25 2024-01-02 00:00:00 3.572424e-02