Skip to content

Commit

Permalink
Merge pull request #27 from PaulMelloy/dev
Browse files Browse the repository at this point in the history
update main branch to prerelease version 0.0.0.9003
  • Loading branch information
PaulMelloy authored Nov 19, 2024
2 parents 28942d2 + 3ffc53e commit 6ac0004
Show file tree
Hide file tree
Showing 25 changed files with 163 additions and 120 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
^pkgdown$
^\.github$
.Rprofile
^cran-comments\.md$
codemeta.json
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
.httr-oauth
.DS_Store
inst/doc
docs
.Rprofile
19 changes: 9 additions & 10 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
Package: cercospoRa
Title: Mechanistic Epidemiological Model for Cercospora Leaf Spot of Sugar Beet
Version: 0.0.0.9002
Title: Process based Epidemiological Model for Cercospora Leaf Spot of Sugar Beet
Version: 0.0.0.9003
Authors@R: c(
person(given = "Paul",
family = "Melloy",
role = c("aut", "cre", "trl"),
role = c("aut", "cre", "trl","cph"),
email = "[email protected]",
comment = c(ORCID = "0000-0003-4253-7167",
"Translated equations from literature and developed package.")),
person(given = "Rene",
family = "Heim",
role = c("aut"),
role = c("aut", "cph"),
email = "[email protected]",
comment = c(ORCID = "0000-0002-0666-2588",
"Code review and development of leaf area index model")),
Expand All @@ -30,10 +30,10 @@ Authors@R: c(
family = "Mahlein",
role = c("ctb"),
comment = c(ORCID = "0000-0003-1091-3690")))
Description: This package provides functions to recreate the negative prognosis
epidemiological model for describing when the model can't be certain a
chance Cercospora leaf spot (_Cercospora beticola_) epidemic has not
commenced. The model is based on the work of Wolf and Verreet
Description: This package provides functions to estimate sugar beet canopy
closure with remotely sensed LAI and estimate when action might be needed to
protect the crop from a Cercospora leaf spot (_Cercospora beticola_) epidemic
with a negative prognosis model based on the work of Wolf and Verreet
(2005 <https://apsjournals.apsnet.org/doi/abs/10.1094/PHYTO-95-0269>).
License: MIT + file LICENSE
Encoding: UTF-8
Expand All @@ -59,8 +59,7 @@ VignetteBuilder: knitr
Remotes:
PaulMelloy/epiphytoolR
Depends:
R (>= 2.10)
R (>= 4.0.0)
LazyData: true
URL: https://paulmelloy.github.io/cercospoRa/
BugReports: https://github.com/PaulMelloy/cercospoRa/issues

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
YEAR: 2023
YEAR: 2024
COPYRIGHT HOLDER: cercospoRa authors
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ export(read_sb_growth_parameter)
import(data.table)
importFrom(Rdpack,reprompt)
importFrom(data.table,":=")
importFrom(terra,plot)
11 changes: 9 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# cercospoRa (development version)
# cercospoRa (development version)

# cercospoRa 0.0.0.9003
## New Features and minor improvements
- Four functions have been added to deal with spatial heterogeneity:
- `read_sb_growth_parameter`: read in and format raster images to allow
Expand All @@ -10,11 +12,16 @@
- Example datasets have been provided to check the functions.
It consists of a folder containing two LAI maps computed from UAV images.

## Features removed
- Removed methods from Racca paper and set them to a new branch
[plus_racca](https://github.com/PaulMelloy/cercospoRa/tree/plus_racca)

## Documentation fixes
- add metadata
- Further simplification of `main` and `dev` branches to only the Wolf and
Verreet functions.
- add badge
- add badge
- spelling and grammar fixes


# cercospoRa 0.0.0.9001
Expand Down
12 changes: 6 additions & 6 deletions R/calc_DIV.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#' Calculate daily infection values
#'
#' This function calculates the daily infection values for *Cercospora berticola*
#' This function calculates the daily infection values for *Cercospora beticola*
#' on sugar beet. Functions were adapted from \insertCite{wolf_factors_2005}{cercospoRa}
#' and \insertCite{wolf_zum_2001}{cercospoRa}
#'
#' @param date_time POSIX_ct, date time the weather recording was taken
#' @param Tm numeric, temperature, in celcius' at time increment in `date_time`
#' @param Tm numeric, temperature, in Celsius' at time increment in `date_time`
#' @param RH numeric, relative humidity (%) at time increment in `date_time`
#' @param rain numeric, volume of rain in millimeters recorded between time recordings
#' @param rain numeric, volume of rain in millimetres recorded between time recordings
#' @param dat data.frame, containing column names "times","temp","rh","rain" with
#' each of the respective arguments for input. provided as a convenience
#'
#' @return data.table, with probability of infection for each day, between 0 and 1
#' Undertaken with two methods by Wolf \insertCite{wolf_factors_2005}{cercospoRa}
#' under the `DIV` column and method by Racca et. al \insertCite{racca_cercbet_2007}{cercospoRa}
#' under the `DIV` column and method by Racca et al. \insertCite{racca_cercbet_2007}{cercospoRa}
#' described in the `DIV_racca` column.
#' @export
#' @references \insertAllCited{}
Expand Down Expand Up @@ -68,8 +68,8 @@ calc_DIV <- function(date_time, Tm,RH, rain,dat){
"moist_ind") := list(temperature_index(temp),
moisture_index(rh,rain,70))]

DIV <- dat[, list(DIV = mean(fifelse(test = Tm_index == 0 | moist_ind == 0,
yes = 0, no = (Tm_index * moist_ind)))),
DIV <- dat[, list(DIV = round(mean(fifelse(test = Tm_index == 0 | moist_ind == 0,
yes = 0, no = Tm_index * moist_ind)),digits = 7)),
by = c("Year", "Month", "Day")]

return(DIV)
Expand Down
8 changes: 5 additions & 3 deletions R/calc_c_closure.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#' Calculate growth rate(r) and LAI0 at time t0
#' Calculate canopy closure date
#'
#' @details
#' Calculates canopy closure dates from LAI and growth rate parameters
#'
#'
#' @param param_rxt Output of the function \link{calc_r_x0}, which produces a
#' list containing parameters that are necessary to calculate `c_closure`.
Expand All @@ -12,8 +16,6 @@
#' @return `c_closure` date at which 90% canopy closure is reached at each location.
#'
#' @export
#'
#'
#' @examples
#' img_dir <- system.file("extdata", "uav_img",package = "cercospoRa")
#' epidemic_onset_param <-
Expand Down
16 changes: 8 additions & 8 deletions R/calc_epidemic_onset.R
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#' Calculate epidemic onset
#'
#' @param start posixct, start date in which to begin calculating the epidemic
#' @param start POSIXct, start date in which to begin calculating the epidemic
#' onset, if not specified, the first date in the weather data will be used.
#' @param end posixct, end date, last date to complete calculating the epidemic
#' @param end POSIXct, end date, last date to complete calculating the epidemic
#' onset, if not specified, the last date in the weather data will be used.
#' @param c_closure POSIXct formatted date to start the model running the model
#' This is usually at canopy closure (Wolf)
#' @param weather data.table, formatted with `epiphytoolR::format_weather`
#' @param cultivar_sus character, susceptibility of the cultivar in "R" resistant,
#' "S" susceptible, "MR" moderately resistant ect.
#'
#' @return `$wolf_date:` If the input weather is conducive for epidemic, the function returns a
#' POSIX_ct date when epidemic commences. If no epidemic occurs, a numeric,
#' proportion indicating the progress an epidemic is returned
#' `racca_percent:` If the input weather is conducive for epidemic, the function returns a
#' POSIX_ct date when epidemic commences. If no epidemic occurs, a numeric,
#' proportion indicating the progress an epidemic is returned
#' @return `$wolf_date:` If the input weather is conducive for epidemic, the
#' function returns a POSIX_ct date when epidemic commences. If no epidemic
#' occurs, a numeric, proportion indicating the progress an epidemic is returned
#' `racca_percent:` If the input weather is conducive for epidemic, the function
#' returns a POSIX_ct date when epidemic commences. If no epidemic occurs, a
#' numeric, proportion indicating the progress an epidemic is returned
#' @export
#'
#' @examples
Expand Down
5 changes: 2 additions & 3 deletions R/calc_epidemic_onset_from_image.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#' Calculate epidemic onset from image
#'
#' @param start posixct, start date in which to begin calculating the epidemic
#' @param start POSIXct, start date in which to begin calculating the epidemic
#' onset, if not specified, the first date in the weather data will be used.
#' @param end posixct, end date, last date to complete calculating the epidemic
#' @param end POSIXct, end date, last date to complete calculating the epidemic
#' onset, if not specified, the last date in the weather data will be used.
#' @param c_closure map of canopy closure dates formatted as number of days since
#' 1970-01-01. It defines the date to start running the model (Wolf)
#' @param weather data.table, formatted with `epiphytoolR::format_weather`
#' @param cultivar_sus character, susceptibility of the cultivar in "R" resistant,
#' "S" susceptible, "MR" moderately resistant ect.
#' @importFrom terra plot
#' @return `$wolf_date:` If the input weather is conducive for epidemic, the function returns a
#' POSIX_ct date when epidemic commences. If no epidemic occurs, a numeric,
#' proportion indicating the progress an epidemic is returned
Expand Down
24 changes: 15 additions & 9 deletions R/calc_r_x0.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
#' Calculate growth rate(r) and LAI0 at time t0
#' Calculate growth rate and LAI at t0
#'
#' @param param_r Output of the function \link[cercospoRa]{read_sb_growth_parameter}, which
#' produces a list containing the LAI images and the associated dates
#' @details
#' Fits a non-linear model to remotely sensed LAI values and estimates the leaf
#' area index (LAI) and growth rate _r_ at the start of the time window _t0_.
#'
#'
#' @param param_r Output of the function \link[cercospoRa]{read_sb_growth_parameter},
#' which produces a list containing the LAI images and the associated dates
#' @param min_r minimum growth rate for sugar beet. Default `min_r` is fixed to
#' 0.02 to ensure that the growth rate at the inflexion point of the sigmiod is
#' 0.02 to ensure that the growth rate at the inflexion point of the sigmoid is
#' at least 1 unit of LAI per month.
#' @param max_r manimum growth rate for sugar beet. Default `max_r` is fixed to
#' @param max_r maximum growth rate for sugar beet. Default `max_r` is fixed to
#' 0.05 to ensure that the growth rate at the inflexion point of the sigmoid is
#' at most 2.5 units of LAI per month.
#' @param k carrying capaciy, which is the maximum LAI that can be attained.
#' @param k carrying capacity, which is the maximum LAI that can be attained.
#' This value can be cultivar-dependent. The default is fixed to 6
#'
#' @return `param_rxt:` list containing parameters that are necessary to calculate `c_closure`. These parameters are `r`, the
#' growth rate, `x0`, the initial LAI value, and `t0`, the initial date.
#' @return `param_rxt:` list containing parameters that are necessary to calculate
#' `c_closure`. These parameters are `r`, the growth rate, `x0`, the initial LAI
#' value, and `t0`, the initial date.
#'
#' @export
#'
Expand Down Expand Up @@ -55,7 +61,7 @@ calc_r_x0 <- function(param_r,
#' Fit non-linear model to raster layers
#'
#' @param xyi Spatrast stack
#' @param k carrying capaciy, which is the maximum LAI that can be attained.
#' @param k carrying capacity, which is the maximum LAI that can be attained.
#' This value can be cultivar-dependent. The default is fixed to 6
#' @param tm numeric, form of dates from each raster layer in `xyi`
#' @param t0 numeric, form of date from first raster layer in `xyi`
Expand Down
1 change: 1 addition & 0 deletions R/latent_period.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#' @return numeric, Latent period for a given hour. `ref = "jarroudi"` returns
#' latent period in days.
#' @references \insertRef{wolf_factors_2005}{cercospoRa}; equation 4
#'
#' \insertRef{el_jarroudi_weather-based_2021}{cercospoRa}; equation 1
latent_period <- function(Tm, ref = "wolf"){
if(ref == "wolf"){
Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
42 changes: 28 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,18 @@
<!-- badges: end -->
<br>

`cercospoRa` is a mechanistic epidemiological model for estimating epidemics of
_Cercospora beticola_ in sugar beet farms, available as an R package.
This R package, `cercospoRa`, takes steps to automate the epidemiological
modelling of Cercospora leaf spot epidemics in _Cercospora beticola_ in sugar
beet farms, available as an R package.
The package contains functions to use remotely sensed spatially explicit empirical
data to estimate leaf area index (LAI) when the crop canopy closes.
Crop canopy closure is a key variable in modelling the estimating when growers
will need to be vigilant and protect their crop with fungicides to prevent a
yield limiting cercospora leaf spot epidemic.

`cercospoRa` uses functions described by Wolf and Verreet (2005) "Factors
Affecting the Onset of Cercospora Leaf Spot Epidemics in Sugar Beet and
Establishment of Disease-Monitoring Thresholds" _Phytopathology_

<br>

Expand All @@ -28,14 +38,15 @@ remotes::install_github(repo = "PaulMelloy/cercospoRa")
## Getting started
### Format weather data
```r
library(data.table)
library(epiphytoolR)
library(cercospoRa)

# Inspect raw weather station data
head(cercospoRa::weathr)
```

`weathr` is a data.table containing weather data recorded at a sugar beet field
`weathr` is a `data.table` containing weather data recorded at a sugar beet field
trial observing the spread and severity of *C. beticola*.

```r
Expand Down Expand Up @@ -97,8 +108,8 @@ calc_epidemic_onset(c_closure = as.POSIXct("2022-07-01"),
cultivar_sus = 5)

```
This returns a `POSIXct` date for the onset of an epidemic for the susceptible and
more resistant cultivar.
This returns a `POSIXct` date for the onset of an epidemic for the susceptible
and more resistant cultivar.
If the input weather data does not provide a window where a epidemic onset date
is met, the proportional progress towards an epidemic is returned.

Expand All @@ -116,22 +127,25 @@ This produces a `data.table` detailing the daily infection value for each day us
the method described in Wolf and Verreet (2005).

**Note:** Missing humidity values do not prevent the model from running and these
days are assumed to not progress the model. The Racca and Jörg model returns `NA` values
and the Wolf model returns `0` as seen in the `calc_DIV(dat = bris_formated)` function
output.
days are assumed to not progress the model. The Racca and Jörg model returns `NA`
values and the Wolf model returns `0`.

<br>

## Notes for contributors
The `main` branch is the production branch and only provides functions to recreate
the model described in Wolf and Verreet (2005) as explained in the paper.
The `main` branch is locked, please contribute to the `dev` branch.
The `dev` (development) branch also includes functions to recreate other *C. beticola*
mechanistic models published by Racca and Jörg (2007) and auxiliary functions which
might be helpful for future versions.
The `main` branch is locked, please contribute to the `dev` branch.
The `plus_racca` (development) branch also includes functions to recreate other
*C. beticola* mechanistic models published by Racca and Jörg (2007) and auxiliary
functions which might be helpful for future versions.

<br>

## References
Wolf, P. F., & Verreet, J. A. (2005). Factors Affecting the Onset of Cercospora Leaf Spot Epidemics in Sugar Beet and Establishment of Disease-Monitoring Thresholds. *Phytopathology*, 95(3), 269-274.
Racca, P., and Jörg, E. (2007). CERCBET 3 – a forecaster for epidemic development of *Cercospora beticola*. *EPPO Bulletin*, 37(2), 344-349.
Wolf, P. F., & Verreet, J. A. (2005). Factors Affecting the Onset of Cercospora
Leaf Spot Epidemics in Sugar Beet and Establishment of Disease-Monitoring
Thresholds. *Phytopathology*, 95(3), 269-274.

Racca, P., and Jörg, E. (2007). CERCBET 3 – a forecaster for epidemic development
of *Cercospora beticola*. *EPPO Bulletin*, 37(2), 344-349.
8 changes: 5 additions & 3 deletions codemeta.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"@type": "SoftwareSourceCode",
"@id": "https://github.com/PaulMelloy/cercospoRa",
"@id": "https://paulmelloy.github.io/cercospoRa/",
"identifier": "cercospoRa",
"description": "This package provides functions to recreate the negative prognosis epidemiological model for describing when the model can't be certain a chance Cercospora leaf spot (_Cercospora beticola_) epidemic has not commenced. The model is based on the work of Wolf and Verreet (2005 <https://apsjournals.apsnet.org/doi/abs/10.1094/PHYTO-95-0269>).",
"name": "cercospoRa: Mechanistic Epidemiological Model for Cercospora Leaf Spot of Sugar Beet",
Expand Down Expand Up @@ -219,7 +219,9 @@
},
"SystemRequirements": null
},
"fileSize": "2515.082KB",
"fileSize": "2515.167KB",
"relatedLink": "https://paulmelloy.github.io/cercospoRa/",
"releaseNotes": "https://github.com/PaulMelloy/cercospoRa/blob/master/NEWS.md"
"releaseNotes": "https://github.com/PaulMelloy/cercospoRa/blob/master/NEWS.md",
"readme": "https://github.com/PaulMelloy/cercospoRa/blob/main/README.md",
"developmentStatus": "https://www.repostatus.org/#active"
}
5 changes: 5 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## R CMD check results

0 errors | 0 warnings | 1 note

* This is a new release.
8 changes: 4 additions & 4 deletions man/calc_DIV.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6ac0004

Please sign in to comment.