| Title: | Agricultural Climate Data Processing and Agrometeorological Tools |
|---|---|
| Description: | Tools for downloading and processing climate data of agricultural interest. |
| Authors: | Joao Batista Tolentino Jr. [aut, cre]
|
| Maintainer: | Joao Batista Tolentino Jr. <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-06-18 06:21:13 UTC |
| Source: | https://github.com/joaobtj/agriclimr |
Takes a daily data frame containing temperature extrema and average relative humidity, reconstructs the hourly parameters internally, and computes the hourly leaf wetness presence along with its daily operational hour sum.
daily_to_hourly_lwd( data, date_col, t_min_col, t_max_col, rh_daily_col, lat_col, rh_threshold = 85 )daily_to_hourly_lwd( data, date_col, t_min_col, t_max_col, rh_daily_col, lat_col, rh_threshold = 85 )
data |
A data frame containing the daily weather records. |
date_col |
Unquoted name of the column containing the Date object. |
t_min_col |
Unquoted name of the column containing the current day's minimum temperature (°C). |
t_max_col |
Unquoted name of the column containing the current day's maximum temperature (°C). |
rh_daily_col |
Unquoted name of the column containing the daily average relative humidity (%). |
lat_col |
Unquoted name of the column containing the latitude (decimal degrees). |
rh_threshold |
A single numeric value indicating the RH percentage above which leaf wetness is assumed to occur. Default is 85% based on optimized regional validations. |
A tibble (data frame) expanded to hourly resolution (24 rows per original daily row)
with four columns: datetime (POSIXct), temperature_hourly (°C), rh_hourly (\
leaf_wetness_hourly (binary 0/1), and lwd_daily_sum (total wet hours in that day).
# Sample daily dataset matching your exact input structure with 5 continuous days daily_series <- tibble::tibble( date = as.Date("2026-06-01") + 0:4, lat = rep(-27.3, 5), tmin = c(12.0, 13.5, 11.0, 10.5, 14.0), tmax = c(22.0, 24.5, 21.0, 19.5, 23.0), rh_mean = c(80, 75, 85, 90, 70) ) daily_to_hourly_lwd(daily_series, date, tmin, tmax, rh_mean, lat, rh_threshold = 85)# Sample daily dataset matching your exact input structure with 5 continuous days daily_series <- tibble::tibble( date = as.Date("2026-06-01") + 0:4, lat = rep(-27.3, 5), tmin = c(12.0, 13.5, 11.0, 10.5, 14.0), tmax = c(22.0, 24.5, 21.0, 19.5, 23.0), rh_mean = c(80, 75, 85, 90, 70) ) daily_to_hourly_lwd(daily_series, date, tmin, tmax, rh_mean, lat, rh_threshold = 85)
Takes a daily data frame containing temperature extrema and average relative humidity, reconstructs the hourly temperature internally, and uses it to generate a 24-hour profile of relative humidity for each day. Returns a clean time-series data frame with combined datetime.
daily_to_hourly_rh(data, date_col, t_min_col, t_max_col, rh_daily_col, lat_col)daily_to_hourly_rh(data, date_col, t_min_col, t_max_col, rh_daily_col, lat_col)
data |
A data frame containing the daily weather records. |
date_col |
Unquoted name of the column containing the Date object. |
t_min_col |
Unquoted name of the column containing the current day's minimum temperature (°C). |
t_max_col |
Unquoted name of the column containing the current day's maximum temperature (°C). |
rh_daily_col |
Unquoted name of the column containing the daily average relative humidity (%). |
lat_col |
Unquoted name of the column containing the latitude (decimal degrees). |
A tibble (data frame) expanded to hourly resolution (24 rows per original daily row)
with three columns: datetime (POSIXct), temperature_hourly (°C), and rh_hourly (%).
# Sample daily dataset matching your exact input structure with 5 continuous days daily_series <- tibble::tibble( date = as.Date("2026-06-01") + 0:4, lat = rep(-27.3, 5), tmin = c(12.0, 13.5, 11.0, 10.5, 14.0), tmax = c(22.0, 24.5, 21.0, 19.5, 23.0), rh_mean = c(80, 75, 85, 90, 70) ) daily_to_hourly_rh(daily_series, date, tmin, tmax, rh_mean, lat)# Sample daily dataset matching your exact input structure with 5 continuous days daily_series <- tibble::tibble( date = as.Date("2026-06-01") + 0:4, lat = rep(-27.3, 5), tmin = c(12.0, 13.5, 11.0, 10.5, 14.0), tmax = c(22.0, 24.5, 21.0, 19.5, 23.0), rh_mean = c(80, 75, 85, 90, 70) ) daily_to_hourly_rh(daily_series, date, tmin, tmax, rh_mean, lat)
Takes a data frame containing daily records (minimum and maximum temperatures) and expands it into an hourly data frame (24 rows per day) using a sine-exponential reconstruction model. Returns a clean time-series data frame with combined datetime.
daily_to_hourly_temp(data, date_col, t_min_col, t_max_col, lat_col)daily_to_hourly_temp(data, date_col, t_min_col, t_max_col, lat_col)
data |
A data frame containing the daily weather records. |
date_col |
Unquoted name of the column containing the Date object. |
t_min_col |
Unquoted name of the column containing the current day's minimum temperature (°C). |
t_max_col |
Unquoted name of the column containing the current day's maximum temperature (°C). |
lat_col |
Unquoted name of the column containing the latitude (decimal degrees). |
A tibble (data frame) expanded to hourly resolution (24 rows per original daily row)
with two columns: datetime (POSIXct) and temperature_hourly (°C).
# Sample daily dataset representing 5 continuous days daily_series <- tibble::tibble( date = as.Date("2026-06-01") + 0:4, lat = rep(-27.3, 5), tmin = c(12.0, 13.5, 11.0, 10.5, 14.0), tmax = c(22.0, 24.5, 21.0, 19.5, 23.0) ) daily_to_hourly_temp(daily_series, date, tmin, tmax, lat)# Sample daily dataset representing 5 continuous days daily_series <- tibble::tibble( date = as.Date("2026-06-01") + 0:4, lat = rep(-27.3, 5), tmin = c(12.0, 13.5, 11.0, 10.5, 14.0), tmax = c(22.0, 24.5, 21.0, 19.5, 23.0) ) daily_to_hourly_temp(daily_series, date, tmin, tmax, lat)
Reconstructs a 24-hour profile of hourly relative humidity values based on daily average relative humidity, daily average temperature, and a vector of hourly temperatures. It assumes that the actual vapor pressure remains constant throughout the day.
estimate_hourly_rh(rh_daily, t_daily, t_hourly)estimate_hourly_rh(rh_daily, t_daily, t_hourly)
rh_daily |
A single numeric value representing the daily average relative humidity (%). |
t_daily |
A single numeric value representing the daily average temperature (°C). |
t_hourly |
A numeric vector of length 24 containing the hourly temperatures (°C). |
A numeric vector of length 24 containing estimated hourly relative humidity values (%).
daily_rh <- 80 daily_t <- 20 hourly_t <- c(16, 15, 14, 14, 15, 17, 19, 21, 23, 24, 25, 25, 24, 23, 22, 21, 20, 19, 18, 17, 17, 16, 16, 16) estimate_hourly_rh(rh_daily = daily_rh, t_daily = daily_t, t_hourly = hourly_t)daily_rh <- 80 daily_t <- 20 hourly_t <- c(16, 15, 14, 14, 15, 17, 19, 21, 23, 24, 25, 25, 24, 23, 22, 21, 20, 19, 18, 17, 17, 16, 16, 16) estimate_hourly_rh(rh_daily = daily_rh, t_daily = daily_t, t_hourly = hourly_t)
Reconstructs a 24-hour hourly temperature profile from daily minimum, maximum, and the next day's minimum temperatures using a sine-exponential model.
estimate_hourly_temp( t_min, t_max, t_min_next, lat, doy, alpha = 2.75, beta = 1.4, gamma = 2.75 )estimate_hourly_temp( t_min, t_max, t_min_next, lat, doy, alpha = 2.75, beta = 1.4, gamma = 2.75 )
t_min |
Single numeric value of the current day's minimum temperature (°C). |
t_max |
Single numeric value of the current day's maximum temperature (°C). |
t_min_next |
Single numeric value of the next day's minimum temperature (°C). |
lat |
Latitude of the location in decimal degrees. |
doy |
Day of the year (Julian day, 1 to 365/366). |
alpha |
Parameters for the time lag between solar noon and maximum temperature (hours). Default is 2.75. |
beta |
Parameters for the time lag between minimum temperature and sunrise (hours). Default is 1.40. |
gamma |
Parameter representing the temperature characteristics decay rate at night. Default is 2.75. |
A numeric vector of length 24 containing the reconstructed hourly temperatures (°C) from 00:00 to 23:00.
estimate_hourly_temp(t_min = 12, t_max = 25, t_min_next = 13, lat = -27.28, doy = 150)estimate_hourly_temp(t_min = 12, t_max = 25, t_min_next = 13, lat = -27.28, doy = 150)
Estimates the number of hours of leaf wetness based on a Relative Humidity (RH) threshold. This is a standard empirical approach used in agricultural meteorology to predict plant disease risks.
estimate_lwd_rh(rh, threshold = 90)estimate_lwd_rh(rh, threshold = 90)
rh |
A numeric vector containing hourly Relative Humidity values (0 to 100). |
threshold |
A numeric value indicating the RH percentage above which leaf wetness is assumed to occur. Default is 90%. |
A numeric vector of the same length as rh containing binary
values: 1 (wet) or 0 (dry).
hourly_rh <- c(85, 88, 91, 95, 92, 87, 80) estimate_lwd_rh(hourly_rh, threshold = 90)hourly_rh <- c(85, 88, 91, 95, 92, 87, 80) estimate_lwd_rh(hourly_rh, threshold = 90)