| 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-10-07 12:20:59 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, lon_col = NULL, tz = NULL )daily_to_hourly_temp( data, date_col, t_min_col, t_max_col, lat_col, lon_col = NULL, tz = NULL )
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). |
lon_col |
Optional unquoted name of the column containing the longitude (decimal degrees). Default is |
tz |
Optional numeric value indicating the time zone offset from UTC in hours (e.g., -3). Default is |
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), lon = rep(-50.6, 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) ) # Standard usage (solar time) daily_to_hourly_temp(daily_series, date, tmin, tmax, lat) # With longitude, time zone, and custom alpha parameter via ... daily_to_hourly_temp( daily_series, date, tmin, tmax, lat, lon_col = lon, tz = -3 )# Sample daily dataset representing 5 continuous days daily_series <- tibble::tibble( date = as.Date("2026-06-01") + 0:4, lat = rep(-27.3, 5), lon = rep(-50.6, 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) ) # Standard usage (solar time) daily_to_hourly_temp(daily_series, date, tmin, tmax, lat) # With longitude, time zone, and custom alpha parameter via ... daily_to_hourly_temp( daily_series, date, tmin, tmax, lat, lon_col = lon, tz = -3 )
Calculates the astronomical day length (photoperiod) in decimal hours.
estimate_daylength(lat, doy)estimate_daylength(lat, doy)
lat |
Latitude in decimal degrees (negative for South). |
doy |
A numeric vector of day of the year (Julian day, 1 to 365/366) or
a vector of |
A numeric vector of day length values in decimal hours.
estimate_daylength(lat = -27.28, doy = 172) # Winter solstice estimate_daylength(lat = -27.28, doy = 355) # Summer solsticeestimate_daylength(lat = -27.28, doy = 172) # Winter solstice estimate_daylength(lat = -27.28, doy = 355) # Summer solstice
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, lon = NULL, tz = NULL, alpha = 2.75, beta = 1.4, gamma = 2.75 )estimate_hourly_temp( t_min, t_max, t_min_next, lat, doy, lon = NULL, tz = NULL, 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). |
lon |
Optional. Longitude of the location in decimal degrees (negative for West).
Default is |
tz |
Optional. Time zone offset from UTC in hours (e.g., -3 for UTC-3).
Default is |
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.
# Using default local solar time estimate_hourly_temp(t_min = 12, t_max = 25, t_min_next = 13, lat = -27.28, doy = 150) # Accounting for civil time with longitude and time zone offset estimate_hourly_temp( t_min = 12, t_max = 25, t_min_next = 13, lat = -27.28, doy = 150, lon = -50.58, tz = -3 )# Using default local solar time estimate_hourly_temp(t_min = 12, t_max = 25, t_min_next = 13, lat = -27.28, doy = 150) # Accounting for civil time with longitude and time zone offset estimate_hourly_temp( t_min = 12, t_max = 25, t_min_next = 13, lat = -27.28, doy = 150, lon = -50.58, tz = -3 )
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)
Calculates the solar noon time in decimal hours. By default, it returns local solar noon (12.0 h), but it can compute civil standard clock time when longitude and time zone offset are provided.
estimate_solar_noon(doy, lon = NULL, tz = NULL)estimate_solar_noon(doy, lon = NULL, tz = NULL)
doy |
A numeric vector of day of the year (Julian day, 1 to 365/366) or
a vector of |
lon |
Optional. Longitude in decimal degrees (negative for West). If omitted, local solar noon is returned (12.0). |
tz |
Optional. Time zone offset from UTC in hours (e.g., -3 for UTC-3). |
A numeric vector representing solar noon in decimal hours (0 to 24).
# Local solar noon (default) estimate_solar_noon(doy = 180) # Civil clock time for solar noon with longitude and UTC offset estimate_solar_noon(doy = 180, lon = -50.58, tz = -3)# Local solar noon (default) estimate_solar_noon(doy = 180) # Civil clock time for solar noon with longitude and UTC offset estimate_solar_noon(doy = 180, lon = -50.58, tz = -3)
Computes sunrise time in decimal hours based on latitude, day of the year, and solar noon.
estimate_sunrise(lat, doy, solar_noon = 12)estimate_sunrise(lat, doy, solar_noon = 12)
lat |
Latitude in decimal degrees (negative for South). |
doy |
A numeric vector of day of the year (Julian day, 1 to 365/366) or
a vector of |
solar_noon |
Optional. Numeric vector or scalar indicating solar noon in decimal hours. Default is 12.0. |
A numeric vector containing sunrise times in decimal hours.
# Sunrise on summer solstice for southern hemisphere (lat = -27.28) estimate_sunrise(lat = -27.28, doy = 355)# Sunrise on summer solstice for southern hemisphere (lat = -27.28) estimate_sunrise(lat = -27.28, doy = 355)
Computes sunset time in decimal hours based on latitude, day of the year, and solar noon.
estimate_sunset(lat, doy, solar_noon = 12)estimate_sunset(lat, doy, solar_noon = 12)
lat |
Latitude in decimal degrees (negative for South). |
doy |
A numeric vector of day of the year (Julian day, 1 to 365/366) or
a vector of |
solar_noon |
Optional. Numeric vector or scalar indicating solar noon in decimal hours. Default is 12.0. |
A numeric vector containing sunset times in decimal hours.
estimate_sunset(lat = -27.28, doy = 355)estimate_sunset(lat = -27.28, doy = 355)