These functions add biologically useful variables to a weather data frame. Column arguments are supplied unquoted. The original data frame is returned with one additional column.
Usage
derive_dew_point(data, temp, rh, name = "dew_point")
derive_vpd(data, temp, rh, name = "vpd")
derive_temperature_range(data, tmax, tmin, name = "temp_range")
derive_leaf_wetness_from_rh(
data,
rh,
threshold = 90,
name = "leaf_wetness_est"
)
derive_leaf_wetness_from_rh_temp(
data,
rh,
temp,
rh_threshold = 90,
temp_range = NULL,
name = "leaf_wetness_est"
)
derive_favorable_condition(data, condition, name = "favorable")Arguments
- data
A data frame.
- temp, rh, tmax, tmin
Columns in
data.- name
Name of the new column.
- threshold, rh_threshold
Numeric threshold used to create binary wetness or favorability variables.
- temp_range
Optional numeric vector of length two. When supplied, estimated leaf wetness is one only when RH is high and temperature is inside this range.
- condition
A logical expression evaluated in
data.
Details
derive_dew_point() uses the Magnus approximation with constants
a = 17.625 and b = 243.04. derive_vpd() computes saturation vapor
pressure from temperature and actual vapor pressure from relative humidity.
Relative humidity is interpreted as percent from 0 to 100, and VPD is returned
in kPa. Dew point is returned as NA_real_ when relative humidity is zero
because the logarithmic Magnus approximation has no finite value at zero.
Examples
weather <- data.frame(temp = c(20, 24), rh = c(85, 95), rain = c(0, 1))
weather |>
derive_dew_point(temp, rh) |>
derive_vpd(temp, rh) |>
derive_leaf_wetness_from_rh(rh, threshold = 90)
#> temp rh rain dew_point vpd leaf_wetness_est
#> 1 20 85 0 17.40087 0.3507422 0
#> 2 24 95 1 23.14882 0.1491959 1
