Title: | Dynamic Multi Environment Phenology-Model |
---|---|
Description: | Mechanistically models/predicts the phenology (macro-phases) of 10 crop plants (trained on a big dataset over 80 years derived from the German weather service (DWD) <https://opendata.dwd.de/>). Can be applied for remote sensing purposes, dynamically check the best subset of available covariates for the given dataset and crop. |
Authors: | Flavian Tschurr |
Maintainer: | Flavian Tschurr <[email protected]> |
License: | LGPL (>= 3) |
Version: | 0.1.2 |
Built: | 2025-03-03 04:32:54 UTC |
Source: | https://github.com/ftschurr/dymep |
DRC function: asymptotic_prediction
asymptotic_prediction(x, params)
asymptotic_prediction(x, params)
x |
input variable |
params |
list of input parameter; Asym a numeric parameter representing the horizontal asymptote on the right side (very large values of input). ; lrc a numeric parameter representing the natural logarithm of the rate constant; c0 a numeric parameter representing the x for which the response is zero. |
value with asymptotic response
asymptotic_prediction(5,list("Asym_value"=0.5, "lrc_value"=0.2, "c0_value"=4)) # visualization asymptote <- lapply(seq(0, 10, 0.1), asymptotic_prediction, list("Asym_value"=0.5, "lrc_value"=0.2, "c0_value"=4)) plot(seq(0, 10, 0.1), asymptote)
asymptotic_prediction(5,list("Asym_value"=0.5, "lrc_value"=0.2, "c0_value"=4)) # visualization asymptote <- lapply(seq(0, 10, 0.1), asymptotic_prediction, list("Asym_value"=0.5, "lrc_value"=0.2, "c0_value"=4)) plot(seq(0, 10, 0.1), asymptote)
check what crops and corresponding phenology phases are available at the moment. Chose a crop (crop_abbrev), phenological phase from the output of this function further usage
available_crops_and_phases()
available_crops_and_phases()
dataframe with available crops and phenology phases
available_crops_and_phases()
available_crops_and_phases()
available_environmental_covariates check what environmental covariates are implemented, use or alter prediction these abbreviations and the corresponding unit
available_environmental_covariates()
available_environmental_covariates()
dataframe with available environmental covariates
available_environmental_covariates()
available_environmental_covariates()
Empirically models/predicts the phenology (macro-phases) of 10 crop plants (trained on a big dataset over 80 years derived from the German weather service (DWD)). Can be applied for remote sensing purposes, environmental inputs can be chosen from a range of pre-trained response curves and applied to the trained crops and phenological phases. No retraining is done within the use of this package.
available <- available_crops_and_phases() #what is the best environmental covariates for one or multiple phases? # check what covairates are implemented in the model available_covariates <- available_environmental_covariates() best_DyMEP_model(env_covariates = c("tas","tasmin","VPD","SPI", "global_radiation","tasmax","RH"), pheno_phases = c("sowing-emergence","jointing-heading"), crop_abbrev = "WW") # create a list of wanted phases and corresponding environmental covariates phase_covariate_list <- list("sowing-emergence" = c("tasmin","VPD","SPI"), "emergence-jointing"= c("tas","tasmin","VPD","SPI"), "jointing-heading" = c("global_radiation","tas","SPI")) # alternatively you can create this input list directly like this with the # best available model: phase_covariate_list <- best_DyMEP_model(env_covariates = c("tas","tasmin","VPD","SPI","global_radiation","tasmax","RH"), pheno_phases = c("sowing-emergence","emergence-jointing","jointing-heading"), crop_abbrev = "WW", output_list_for_prediction = TRUE) # create dummy environmental data environmental_data <- data.frame("DATE" = seq.Date( from = as.Date("2021-01-01"), to = as.Date("2023-12-31"),by=1), "tas"=runif(1095,min=-10,max=40), "RH"=runif(1095,min=0,max=100), "tasmin"=runif(1095,min=-10,max=40), "tasmax"=runif(1095,min=-5,max=40), "VPD" = runif(1095,min=0,max=40), "SPI"= runif(1095,min=-1,max=4), "global_radiation"= runif(1095,min=0,max=3500)) pheno_phase_prediction(phase_covariate_list = phase_covariate_list, environmental_data = environmental_data, phase_starting_date =as.Date("2021-01-01"), crop_abbrev = "WW") # you can also get a more detailed output, containing detailed predictions # and the parameters of the used DRC curves: detailed_output <- pheno_phase_prediction( phase_covariate_list = phase_covariate_list, environmental_data = environmental_data, phase_starting_date =as.Date("2021-01-01"), crop_abbrev = "WW", output_type = "detailed_information") # this output can be visualised like: # get overview plot of the prediction DyMEP_prediction_visualizer(detailed_output) # check the DRC curves of the used model DyMEP_DRC_visualizer(detailed_output)
available <- available_crops_and_phases() #what is the best environmental covariates for one or multiple phases? # check what covairates are implemented in the model available_covariates <- available_environmental_covariates() best_DyMEP_model(env_covariates = c("tas","tasmin","VPD","SPI", "global_radiation","tasmax","RH"), pheno_phases = c("sowing-emergence","jointing-heading"), crop_abbrev = "WW") # create a list of wanted phases and corresponding environmental covariates phase_covariate_list <- list("sowing-emergence" = c("tasmin","VPD","SPI"), "emergence-jointing"= c("tas","tasmin","VPD","SPI"), "jointing-heading" = c("global_radiation","tas","SPI")) # alternatively you can create this input list directly like this with the # best available model: phase_covariate_list <- best_DyMEP_model(env_covariates = c("tas","tasmin","VPD","SPI","global_radiation","tasmax","RH"), pheno_phases = c("sowing-emergence","emergence-jointing","jointing-heading"), crop_abbrev = "WW", output_list_for_prediction = TRUE) # create dummy environmental data environmental_data <- data.frame("DATE" = seq.Date( from = as.Date("2021-01-01"), to = as.Date("2023-12-31"),by=1), "tas"=runif(1095,min=-10,max=40), "RH"=runif(1095,min=0,max=100), "tasmin"=runif(1095,min=-10,max=40), "tasmax"=runif(1095,min=-5,max=40), "VPD" = runif(1095,min=0,max=40), "SPI"= runif(1095,min=-1,max=4), "global_radiation"= runif(1095,min=0,max=3500)) pheno_phase_prediction(phase_covariate_list = phase_covariate_list, environmental_data = environmental_data, phase_starting_date =as.Date("2021-01-01"), crop_abbrev = "WW") # you can also get a more detailed output, containing detailed predictions # and the parameters of the used DRC curves: detailed_output <- pheno_phase_prediction( phase_covariate_list = phase_covariate_list, environmental_data = environmental_data, phase_starting_date =as.Date("2021-01-01"), crop_abbrev = "WW", output_type = "detailed_information") # this output can be visualised like: # get overview plot of the prediction DyMEP_prediction_visualizer(detailed_output) # check the DRC curves of the used model DyMEP_DRC_visualizer(detailed_output)
Visualizes the Dose-Response Curves (DRC) for each phenological phase and environmental covariate.
DyMEP_DRC_visualizer(detailed_output)
DyMEP_DRC_visualizer(detailed_output)
detailed_output |
Output of the pheno_phase_prediction function with output_type = "detailed_information". |
Returns plots showing the DRC curves for each phenological phase and environmental covariate. Each row represents a phenology phase.
phase_covariate_list <- best_DyMEP_model(env_covariates = c("tas","tasmin","VPD","SPI","global_radiation","tasmax","RH"), pheno_phases = c("sowing-emergence","emergence-jointing","jointing-heading"), crop_abbrev = "WW", output_list_for_prediction = TRUE) # create dummy environmental data environmental_data<- data.frame("DATE"=seq.Date(from = as.Date("2021-01-01"), to = as.Date("2023-12-31"),by=1), "tas"=runif(1095,min=-10,max=40), "RH"=runif(1095,min=0,max=100), "tasmin"=runif(1095,min=-10,max=40), "tasmax"=runif(1095,min=0,max=40), "VPD" = runif(1095,min=0,max=40), "SPI"= runif(1095,min=-1,max=4), "global_radiation"= runif(1095,min=0,max=3500)) DyMEP_DRC_visualizer(detailed_output = pheno_phase_prediction( phase_covariate_list = phase_covariate_list, environmental_data = environmental_data, phase_starting_date =as.Date("2021-01-01"), crop_abbrev = "WW", output_type = "detailed_information") )
phase_covariate_list <- best_DyMEP_model(env_covariates = c("tas","tasmin","VPD","SPI","global_radiation","tasmax","RH"), pheno_phases = c("sowing-emergence","emergence-jointing","jointing-heading"), crop_abbrev = "WW", output_list_for_prediction = TRUE) # create dummy environmental data environmental_data<- data.frame("DATE"=seq.Date(from = as.Date("2021-01-01"), to = as.Date("2023-12-31"),by=1), "tas"=runif(1095,min=-10,max=40), "RH"=runif(1095,min=0,max=100), "tasmin"=runif(1095,min=-10,max=40), "tasmax"=runif(1095,min=0,max=40), "VPD" = runif(1095,min=0,max=40), "SPI"= runif(1095,min=-1,max=4), "global_radiation"= runif(1095,min=0,max=3500)) DyMEP_DRC_visualizer(detailed_output = pheno_phase_prediction( phase_covariate_list = phase_covariate_list, environmental_data = environmental_data, phase_starting_date =as.Date("2021-01-01"), crop_abbrev = "WW", output_type = "detailed_information") )
Visualizes the predictions of the DyMEP model.
DyMEP_prediction_visualizer(detailed_output)
DyMEP_prediction_visualizer(detailed_output)
detailed_output |
Output of the pheno_phase_prediction function with output_type = "detailed_information". |
A plot with one panel per phenology phase, showing the environmental covariate responses, the GLM prediction, and the phase prediction (points).
timestamp
Description of timestamp column.
phase_covariate_list <- best_DyMEP_model(env_covariates = c("tas","tasmin","VPD","SPI","global_radiation","tasmax","RH"), pheno_phases = c("sowing-emergence","emergence-jointing", "jointing-heading"), crop_abbrev = "WW", output_list_for_prediction = TRUE) # Create dummy environmental data environmental_data <- data.frame("DATE" = seq.Date(from = as.Date("2021-01-01"), to = as.Date("2023-12-31"), by = 1), "tas" = runif(1095, min = -10, max = 40), "RH" = runif(1095, min = 0, max = 100), "tasmin" = runif(1095, min = -10, max = 40), "tasmax" = runif(1095, min = 0, max = 40), "VPD" = runif(1095, min = 0, max = 40), "SPI" = runif(1095, min = -1, max = 4), "global_radiation" = runif(1095, min = 0, max = 3500)) DyMEP_prediction_visualizer(detailed_output = pheno_phase_prediction( phase_covariate_list = phase_covariate_list, environmental_data = environmental_data, phase_starting_date = as.Date("2021-01-01"), crop_abbrev = "WW", output_type = "detailed_information"))
phase_covariate_list <- best_DyMEP_model(env_covariates = c("tas","tasmin","VPD","SPI","global_radiation","tasmax","RH"), pheno_phases = c("sowing-emergence","emergence-jointing", "jointing-heading"), crop_abbrev = "WW", output_list_for_prediction = TRUE) # Create dummy environmental data environmental_data <- data.frame("DATE" = seq.Date(from = as.Date("2021-01-01"), to = as.Date("2023-12-31"), by = 1), "tas" = runif(1095, min = -10, max = 40), "RH" = runif(1095, min = 0, max = 100), "tasmin" = runif(1095, min = -10, max = 40), "tasmax" = runif(1095, min = 0, max = 40), "VPD" = runif(1095, min = 0, max = 40), "SPI" = runif(1095, min = -1, max = 4), "global_radiation" = runif(1095, min = 0, max = 3500)) DyMEP_prediction_visualizer(detailed_output = pheno_phase_prediction( phase_covariate_list = phase_covariate_list, environmental_data = environmental_data, phase_starting_date = as.Date("2021-01-01"), crop_abbrev = "WW", output_type = "detailed_information"))
apply the prediction with glm model
envpredutils.pheno_phase_prediction_glm_model( env_data_pheno_phase, pheno_phase, crop_abbrev, model, output_type = "dates" )
envpredutils.pheno_phase_prediction_glm_model( env_data_pheno_phase, pheno_phase, crop_abbrev, model, output_type = "dates" )
env_data_pheno_phase |
environmental data required to predict the phase |
pheno_phase |
phenological phase |
crop_abbrev |
abbreviation of the crop |
model |
the selected model to predict the wanted phenological phase |
output_type |
either "dates" or "detailed_information"; defines what output of the model they user wants to have as return, default is set to "dates". If a user wants to get the response parameters, curves, predictions and model thresholds, it should be chosen "detailed_information" output = "dates" will return a dataframe with the stages and according dates output = "detailed_information" will return a list with the dates, but also the corresponding dose response parameters and predictions |
final output, either detailed (if output_type = "detailed_information") as list, or data.frame with dates if output_type = "dates"
broken stick model according to an env variable
non_linear_prediction(env_variate, params)
non_linear_prediction(env_variate, params)
env_variate |
value of a environmental covariate |
params |
list of input parameter; base_value: minimal value; slope estimated value, slope of the linear phase |
value with non_linear response
non_linear_prediction(1,list("base_value"=5,"slope_value"=1)) # visualization non_linear <- lapply(seq(0, 10, 0.1), non_linear_prediction, list("base_value"=5,"slope_value"=1)) plot(seq(0, 10, 0.1), non_linear)
non_linear_prediction(1,list("base_value"=5,"slope_value"=1)) # visualization non_linear <- lapply(seq(0, 10, 0.1), non_linear_prediction, list("base_value"=5,"slope_value"=1)) plot(seq(0, 10, 0.1), non_linear)
predict one or all phenological phases
pheno_phase_prediction( phase_covariate_list, environmental_data, phase_starting_date, crop_abbrev, output_type = "dates", external_params_path = NULL )
pheno_phase_prediction( phase_covariate_list, environmental_data, phase_starting_date, crop_abbrev, output_type = "dates", external_params_path = NULL )
phase_covariate_list |
list like: list("sowing-emergence" = c("tas","VPD","SPI"), "emergence-jointing" = c("tas")) indicating per phenological phase the covariates to use. List of of phenological phases must be consecutive! |
environmental_data |
data.frame with the necessary environmental data, one column must be "DATE" (as.Date format), the others with the names of the environmental covariates (e.g. tas, tasmin etc.) |
phase_starting_date |
starting date of the first phase which will be predicted (object of class "Date" (use as.Date())) |
crop_abbrev |
abbreviation of the crop to be modeled (valid crop_abbrevs can be found with available_crops_and_phases()) |
output_type |
either "dates" or "detailed_information"; defines what output of the model they user wants to have as return, default is set to "dates". If a user wants to get the response parameters, curves, predictions and model thresholds, it should be chosen "detailed_information" output = "dates" will return a dataframe with the stages and according dates output = "detailed_information" will return a list with the dates, but also the corresponding dose response parameters and predictions |
external_params_path |
path where additional crop parameters should be stored if not possible to download in to the regular R repository. The default is NULL, which will use the regular R repository as path |
returns the end-date of each phase
either return an object of class 'DyMEP', if detailed_information is selected as output_type, from a dataframe containing phenology data, or
pheno_phase_prediction(phase_covariate_list = list( "sowing-emergence" = c("tasmin","VPD","SPI","tasmax","tas","RH", "global_radiation"), "emergence-jointing"= c("tasmin","VPD","SPI","tasmax","tas","RH", "global_radiation"), "jointing-heading" = c("tasmin","VPD","SPI","tasmax","tas","RH", "global_radiation")), environmental_data <- data.frame("DATE" = seq.Date( from = as.Date("2021-01-01"), to = as.Date("2023-12-31"),by=1), "tas"=runif(1095,min=-10,max=40), "RH"=runif(1095,min=0,max=100), "tasmin"=runif(1095,min=-10,max=40), "tasmax"=runif(1095,min=-5,max=40), "VPD" = runif(1095,min=0,max=40), "SPI"= runif(1095,min=-1,max=4), "global_radiation"= runif(1095,min=0,max=3500)), phase_starting_date =as.Date("2021-01-01"), crop_abbrev = "WW")
pheno_phase_prediction(phase_covariate_list = list( "sowing-emergence" = c("tasmin","VPD","SPI","tasmax","tas","RH", "global_radiation"), "emergence-jointing"= c("tasmin","VPD","SPI","tasmax","tas","RH", "global_radiation"), "jointing-heading" = c("tasmin","VPD","SPI","tasmax","tas","RH", "global_radiation")), environmental_data <- data.frame("DATE" = seq.Date( from = as.Date("2021-01-01"), to = as.Date("2023-12-31"),by=1), "tas"=runif(1095,min=-10,max=40), "RH"=runif(1095,min=0,max=100), "tasmin"=runif(1095,min=-10,max=40), "tasmax"=runif(1095,min=-5,max=40), "VPD" = runif(1095,min=0,max=40), "SPI"= runif(1095,min=-1,max=4), "global_radiation"= runif(1095,min=0,max=3500)), phase_starting_date =as.Date("2021-01-01"), crop_abbrev = "WW")
linear model according to an env variable
reg_linear_prediction(env_variate, params)
reg_linear_prediction(env_variate, params)
env_variate |
value of a environmental covariate |
params |
list of input parameter; intercept estimated value, slope of the linear phase |
value with reg_linear response
reg_linear_prediction(1,list("intercept_value"=1, "slope_value"=5)) # visualization reg_linear <- lapply(seq(0, 10, 0.1), reg_linear_prediction, list("intercept_value"=-1,"slope_value"=1)) plot(seq(0, 10, 0.1), reg_linear)
reg_linear_prediction(1,list("intercept_value"=1, "slope_value"=5)) # visualization reg_linear <- lapply(seq(0, 10, 0.1), reg_linear_prediction, list("intercept_value"=-1,"slope_value"=1)) plot(seq(0, 10, 0.1), reg_linear)
DRC function: WangEngels_prediction
WangEngels_prediction(x, params)
WangEngels_prediction(x, params)
x |
effective env_variable value |
params |
list of input parameter; xmin_value represents the minimal env_variable value above which growth response will happen ; xopt_value: optimal growth point, env_variable values here have the highest response; xmax_value represents the maximal env_variable value above which no growth response will happen according to the wang engel model. |
value with WangEngels response
WangEngels_prediction(10, params = list("xmin_value"=1, "xopt_value"=25, "xmax_value"=35, "r_value"=0.5)) # visualization WangEngels <- lapply(seq(0, 40, 0.1), WangEngels_prediction, list("xmin_value"=1, "xopt_value"=25, "xmax_value"=35, "r_value"=0.5)) plot(seq(0, 40, 0.1), WangEngels)
WangEngels_prediction(10, params = list("xmin_value"=1, "xopt_value"=25, "xmax_value"=35, "r_value"=0.5)) # visualization WangEngels <- lapply(seq(0, 40, 0.1), WangEngels_prediction, list("xmin_value"=1, "xopt_value"=25, "xmax_value"=35, "r_value"=0.5)) plot(seq(0, 40, 0.1), WangEngels)