diff --git a/.github/workflows/check-standard.yaml b/.github/workflows/check-standard.yaml index 0ab27aed..89caaebc 100644 --- a/.github/workflows/check-standard.yaml +++ b/.github/workflows/check-standard.yaml @@ -47,15 +47,9 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: - pak-version: rc - # about pak-version: - # Ubuntu doesn't install the proper version of XML see https://github.com/r-lib/actions/issues/559. Remove when fixed. - # see also: https://stackoverflow.com/questions/73243945/pkgdown-action-failing-at-build-xml - # Temporarily forcing ggplot2 to v3.5.2 on main branch (see https://github.com/SticsRPacks/CroPlotR/issues/84) extra-packages: | any::rcmdcheck SticsRPacks/SticsRFiles@main - ggplot2@3.5.2 needs: check - uses: r-lib/actions/check-r-package@v2 @@ -77,8 +71,7 @@ jobs: repository: SticsRPacks/SticsRTests event-type: R-CMD-check client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}", "repo": "${{ github.event.repository.name }}"}' - - - name: Wait for SticsRTests workflow to complete (block-and-fail) + - name: Wait for SticsRTests workflow to complete (block-and-fail) uses: actions/github-script@v6 with: github-token: ${{ secrets.TRIGGER_PAT }} diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 1344a749..5bca2299 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -29,12 +29,6 @@ jobs: extra-packages: any::covr needs: coverage - - name: Force ggplot2 version 3.5.2 - run: | - install.packages("remotes") - remotes::install_version("ggplot2", version = "3.5.2", upgrade = "never") - shell: Rscript {0} - - name: Test coverage run: | covr::codecov( diff --git a/.github/workflows/vdiffr.yaml b/.github/workflows/vdiffr.yaml index 5a9ea730..96346e5f 100644 --- a/.github/workflows/vdiffr.yaml +++ b/.github/workflows/vdiffr.yaml @@ -5,7 +5,7 @@ on: jobs: snapshot_comparison: - runs-on: ubuntu-latest # Replace with the appropriate runner for your needs + runs-on: ubuntu-latest # Replace with the appropriate runner for your needs steps: - name: Checkout repository @@ -18,18 +18,12 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: - pak-version: rc - # about pak-version: - # Ubuntu doesn't install the proper version of XML see https://github.com/r-lib/actions/issues/559. Remove when fixed. - # see also: https://stackoverflow.com/questions/73243945/pkgdown-action-failing-at-build-xml - # Temporarily forcing ggplot2 to v3.5.2 on main branch (see https://github.com/SticsRPacks/CroPlotR/issues/84) extra-packages: | any::testthat any::rcmdcheck any::remotes any::vdiffr any::zip - ggplot2@3.5.2 SticsRPacks/SticsRFiles@main needs: check @@ -39,7 +33,8 @@ jobs: Rscript -e "pkg_version <- 'Latest'; tmpdir <- '${{ runner.temp }}'; testthat::test_file('tests/testthat/test-dynamic-plots.R', stop_on_failure=FALSE); testthat::test_file('tests/testthat/test-scatter-plots.R', stop_on_failure=FALSE)" - name: Cache the snapshot scripts - run: | # Move the scripts and data from tests/testthat to the tmpdir directory so that both run use the same scripts + run: + | # Move the scripts and data from tests/testthat to the tmpdir directory so that both run use the same scripts mv tests/testthat/* ${{ runner.temp }}/ - name: Checkout CroPlotR main branch @@ -66,4 +61,3 @@ jobs: - name: Compare snapshots run: | Rscript -e "tmpdir <- '${{ runner.temp }}'; testthat::test_file('${{ runner.temp }}/vdiffr/test-snapshots.R', stop_on_failure=TRUE)" - diff --git a/DESCRIPTION b/DESCRIPTION index 217e0b48..9afba78d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -15,6 +15,7 @@ Authors@R: c( comment = c(ORCID = "0000-0002-4044-4322")), person("Michel", "Giner", , "michel.giner@cirad.fr", role = "aut", comment = c(ORCID = "0000-0002-9310-2377")), + person("Valentine", "Rahier", role = "ctb"), person("Amine", "Barkaoui", role = "ctb"), person("Patrick", "Lutz", role = "ctb") ) @@ -36,6 +37,7 @@ Depends: Imports: cli, dplyr, + ggh4x (>= 0.3.1), ggplot2, ggrepel, gridExtra, @@ -57,4 +59,4 @@ Encoding: UTF-8 Language: en-US LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.2 +RoxygenNote: 7.3.3 diff --git a/NAMESPACE b/NAMESPACE index fb8aa1f7..ff254ac1 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -67,6 +67,7 @@ importFrom(parallel,parLapply) importFrom(parallel,stopCluster) importFrom(plyr,join_all) importFrom(reshape2,melt) +importFrom(rlang,":=") importFrom(rlang,.data) importFrom(stats,cor) importFrom(stats,lm) @@ -75,4 +76,3 @@ importFrom(stats,qt) importFrom(stats,sd) importFrom(stats,var) importFrom(tidyselect,vars_select_helpers) -importFrom(utils,head) diff --git a/R/aesthetics.R b/R/aesthetics.R index 678d7a46..5b0a0d4a 100644 --- a/R/aesthetics.R +++ b/R/aesthetics.R @@ -1,24 +1,40 @@ -#' Template aesthetics -#' -#' This function returns a template list of aesthetics for a plot, including -#' color, shape, linetype, and group. -#' -#' @return A list of aesthetics for a plot. -#' -#' @keywords internal -template_aesthetics <- function() { - aesthetics <- list( - "plot" = list( - "color" = list(NULL), "shape" = list(NULL), - "linetype" = list(NULL), "group" = list(NULL) - ), - "versions" = list("shape" = list(NULL), "linetype" = list(NULL)) - ) - return(aesthetics) -} +#' Detects if a situation is a mixture +#' +#' This function checks if the situation is a mixture based on +#' the presence of a column named "Dominance" and the uniqueness +#' of its values. +#' +#' @param sim_situation A data frame containing the simulated data for +#' one situation. +#' @return A logical value indicating if the situation is a mixture. +#' @examples +#' \dontrun{ +#' sim_data <- data.frame( +#' Dominance = c("Principal", "Principal", "Associated", "Associated") +#' ) +#' CroPlotR:::detect_mixture(sim_data) +#' # Output: TRUE +#' +#' sim_data <- data.frame(Dominance = c("Single Crop", "Single Crop")) +#' CroPlotR:::detect_mixture(sim_data) +#' # Output: FALSE +#' +#' sim_data <- data.frame(lai = c(1, 1.2)) +#' CroPlotR:::detect_mixture(sim_data) +#' # Output: FALSE +#' } +detect_mixture <- function(sim_situation) { + is_Dominance <- grep("Dominance", x = colnames(sim_situation), fixed = TRUE) + if (length(is_Dominance) > 0) { + is_mixture <- length(unique(sim_situation[[is_Dominance]])) > 1 + } else { + is_mixture <- FALSE + } + return(is_mixture) +} -#' Detect items cases +#' Detect items cases for dynamic plots #' #' This function detects the cases for computing the aesthetics of a plot based on #' whether it is a mixture or not, whether it has one or multiple versions, and @@ -46,7 +62,7 @@ detect_mixture_version_overlap <- function(is_mixture, one_version, overlap) { return(case) } -#' Detect items cases +#' Detect items cases for scatter plots #' #' This function detects the cases for computing the aesthetics of a plot based on #' whether it is a mixture or not, whether it has one or multiple versions, and @@ -54,86 +70,51 @@ detect_mixture_version_overlap <- function(is_mixture, one_version, overlap) { #' #' @param is_mixture A logical value indicating whether the crop is a mixture or not. #' @param one_version A logical value indicating whether the plot has one or multiple versions (e.g. of the model). -#' @param several_sit A logical value indicating whether there are one or several situations to plot. +#' @param has_distinct_situations A logical value indicating whether there are one or several situations to plot. #' #' @return A character string indicating the case for computing the aesthetics of the plot. #' #' @keywords internal -detect_mixture_version_situations <- function(is_mixture, one_version, several_sit) { - case <- switch(paste(is_mixture, !one_version, several_sit), - "TRUE TRUE TRUE" = "mixture_versions_situations", - "TRUE TRUE FALSE" = "mixture_versions_no_situations", - "TRUE FALSE TRUE" = "mixture_no_versions_situations", - "TRUE FALSE FALSE" = "mixture_no_versions_no_situations", +detect_mixture_version_situations <- function(is_mixture, one_version, has_distinct_situations) { + case <- switch(paste(is_mixture, !one_version, has_distinct_situations), + "TRUE TRUE TRUE" = "mixture_versions", + "TRUE TRUE FALSE" = "mixture_versions", + "TRUE FALSE TRUE" = "mixture_no_versions", + "TRUE FALSE FALSE" = "mixture_no_versions", "FALSE TRUE TRUE" = "non_mixture_versions_situations", - "FALSE TRUE FALSE" = "non_mixture_versions_no_situations", + "FALSE TRUE FALSE" = "non_mixture_versions_per_situations", "FALSE FALSE TRUE" = "non_mixture_no_versions_situations", - "FALSE FALSE FALSE" = "non_mixture_no_versions_no_situations" + "FALSE FALSE FALSE" = "non_mixture_no_versions_per_situations" ) return(case) } -#' Manages the aesthetics of the graphics -#' -#' @description Manages the shape, color and line type of the graphics according -#' to their content -#' -#' @param sim A simulation list of data.frames -#' @param obs An observation list of data.frames -#' @param type The type of plot required, either "dynamic" or "scatter" -#' @param overlap A list of lists containing the variables to represent on the -#' same graph when `type = "dynamic"` -#' @param several_sit Boolean. Must be equal to `TRUE` if sim and obs gather -#' more than one situation and if situations should be differentiated -#' on the graph. -#' @param shape_sit Shape to differentiate between situations when -#' `all_situations= TRUE`. See details. -#' @param one_version Boolean. Must be `TRUE` if several versions will be -#' plotted on the same graph. -#' @param iVersion Integer. Version number of sim -#' @param dot_args List of dot arguments given to plot function -#' -#' @details The `shape_sit` argument can be: -#' * "none" (the default): Same shape for all situations. -#' * "txt": Writes the name of the situation above each point. -#' * "symbol": One shape for each situation. -#' * "group": One shape for each group of situations described in -#' `situation_group`. -#' -#' @return An aesthetics expression which will allow to manage the aesthetics -#' of the graphics +#' Detect items cases #' -#' @keywords internal +#' This function returns a unique string based on the type of plot, and +#' whether the situation is a mixture or not, if there is one or multiple +#' versions to plot, and if there is one or several situations to plot +#' into the same plot. +#' The output is used to choose the right plotting function in a switch. #' -aesthetics <- function(sim, obs = NULL, type = c("dynamic", "scatter"), - overlap = NULL, several_sit = FALSE, - shape_sit = c("none", "txt", "symbol", "group"), - one_version = TRUE, iVersion = 1, - dot_args = NULL) { - is_dominance <- grep("Dominance", x = colnames(sim), fixed = TRUE) - if (length(is_dominance) > 0) { - is_mixture <- length(unique(sim[[is_dominance]])) > 1 - } else { - is_mixture <- FALSE - } - is_mixture <- is_mixture && (length(unique(sim$Dominance)) > 1) - - aesthetics <- template_aesthetics() - +#' @param type The type of plot required, either 'dynamic' or 'scatter +#' @param is_mixture A logical value indicating whether the crop is a mixture or not. +#' @param one_version A logical value indicating whether the plot has one or multiple versions (e.g. of the model). +#' @param has_distinct_situations A logical value indicating whether there are one or several situations to plot. +#' @param overlap A logical value indicating whether there is any overlapping variables in the plot. +#' +#' @return A unique character string for the plot. +#' +#' @keywords internal +detect_item_case <- function(type, is_mixture, one_version, has_distinct_situations, overlap) { if (type == "dynamic") { - aesthetics <- aesthetics_dynamic( - sim, aesthetics, overlap, one_version, iVersion, dot_args, - is_mixture - ) + item_case <- detect_mixture_version_overlap(is_mixture, one_version, overlap) } else if (type == "scatter") { - aesthetics <- aesthetics_scatter( - sim, aesthetics, overlap, several_sit, one_version, iVersion, - dot_args, is_mixture - ) + item_case <- detect_mixture_version_situations(is_mixture, one_version, has_distinct_situations) } else { stop("type must be either 'dynamic' or 'scatter'") } - return(aesthetics) + return(item_case) } diff --git a/R/aesthetics_dynamic.R b/R/aesthetics_dynamic.R deleted file mode 100644 index 37288ee5..00000000 --- a/R/aesthetics_dynamic.R +++ /dev/null @@ -1,74 +0,0 @@ -#' Manages the aesthetics of the graphics for dynamic plots -#' -#' @description Manages the shape, color and line type of the graphics according -#' to their content -#' -#' @param sim A simulation list of data.frames -#' @param aesthetics Template aesthetics list -#' @param overlap A list of lists containing the variables to represent on the -#' same graph when `type = "dynamic"` -#' @param one_version Boolean. Must be `TRUE` if several versions will be -#' plotted on the same graph. -#' @param iVersion Integer. Version number of sim -#' @param dot_args List of dot arguments given to plot function -#' @param is_mixture Boolean indicating whether the crop is a mixture or not -#' -#' @return An aesthetics expression which will allow to manage the aesthetics -#' of the graphics -#' -#' @keywords internal -#' -aesthetics_dynamic <- function(sim, aesthetics = template_aesthetics(), - overlap = NULL, one_version = TRUE, - iVersion = 1, dot_args = NULL, - is_mixture = FALSE) { - # Define the cases using switch - item_case <- detect_mixture_version_overlap(is_mixture, one_version, overlap) - - # Manage the aesthetics according to the case: - if (item_case == "mixture_no_versions_no_overlap") { - aesthetics$plot$color <- - list("Plant" = quote(paste(.data$Dominance, ":", .data$Plant))) - aesthetics$plot$shape <- - list("Plant" = quote(paste(.data$Dominance, ":", .data$Plant))) - aesthetics$plot$group <- - list("Plant" = quote(paste(.data$Dominance, ":", .data$Plant))) - } else if (item_case == "non_mixture_versions_no_overlap") { - aesthetics$versions$color <- - list("Versions" = names(dot_args[iVersion])) - aesthetics$versions$shape <- list("Versions" = names(dot_args[iVersion])) - } else if (item_case == "non_mixture_no_versions_overlap") { - aesthetics$plot$color <- list("Variable" = quote(.data$variable)) - aesthetics$plot$shape <- list("Variable" = quote(.data$variable)) - aesthetics$plot$group <- list("Variable" = quote(.data$variable)) - } else if (item_case == "mixture_versions_no_overlap") { - aesthetics$versions$linetype <- - list("Versions" = names(dot_args[iVersion])) - aesthetics$versions$shape <- - list("Versions" = names(dot_args[iVersion])) - aesthetics$versions$color <- - list("Plant" = quote(paste(.data$Dominance, ":", .data$Plant))) - aesthetics$plot$group <- - list("Plant" = quote(paste(.data$Dominance, ":", .data$Plant))) - } else if (item_case == "non_mixture_versions_overlap") { - aesthetics$versions$color <- list("Variable" = quote(.data$variable)) - aesthetics$versions$linetype <- - list("Versions" = names(dot_args[iVersion])) - aesthetics$versions$shape <- list("Versions" = names(dot_args[iVersion])) - aesthetics$plot$color <- list("Variable" = quote(.data$variable)) - aesthetics$plot$group <- list("Variable" = quote(.data$variable)) - } else if (item_case == "mixture_no_versions_overlap") { - aesthetics$plot$linetype <- list("Variable" = quote(.data$variable)) - aesthetics$plot$shape <- list("Variable" = quote(.data$variable)) - aesthetics$plot$color <- - list("Plant" = quote(paste(.data$Dominance, ":", .data$Plant))) - aesthetics$plot$group <- NULL # ! do we need this? - } else if (item_case == "mixture_versions_overlap") { - aesthetics$versions$color <- list(quote(paste(.data$Combi))) - aesthetics$versions$shape <- list(quote(paste(.data$Combi))) - aesthetics$versions$linetype <- list(quote(paste(.data$Combi))) - aesthetics$plot$group <- list(quote(paste(.data$Combi))) - } - - return(aesthetics) -} diff --git a/R/aesthetics_scatter.R b/R/aesthetics_scatter.R deleted file mode 100644 index 83ae70ab..00000000 --- a/R/aesthetics_scatter.R +++ /dev/null @@ -1,70 +0,0 @@ -#' Manages the aesthetics of the graphics for scatter plots -#' -#' @description Manages the shape, color and line type of the graphics according -#' to their content -#' -#' @param sim A simulation list of data.frames -#' @param aesthetics Template aesthetics list -#' @param overlap A list of lists containing the variables to represent on the -#' same graph when `type = "dynamic"` -#' @param several_sit Boolean. Must be equal to `TRUE` if sim and obs gather -#' more than one situation and if situations should be differentiated -#' on the graph. -#' @param one_version Boolean. Must be `TRUE` if several versions will be -#' plotted on the same graph. -#' @param iVersion Integer. Version number of sim -#' @param dot_args List of dot arguments given to plot function -#' @param is_mixture Boolean indicating whether the crop is a mixture or not -#' -#' @return An aesthetics expression which will allow to manage the aesthetics -#' of the graphics -#' -#' @keywords internal -#' -aesthetics_scatter <- function(sim, aesthetics = template_aesthetics(), - overlap = NULL, several_sit = FALSE, - one_version = TRUE, iVersion = 1, - dot_args = NULL, is_mixture = FALSE) { - # Define the cases using switch - item_case <- detect_mixture_version_situations(is_mixture, one_version, several_sit) - - # Manage the aesthetics according to the case: - if (item_case == "mixture_no_versions_no_situations") { - aesthetics$plot$color <- - list("Plant" = quote(paste(.data$Dominance, ":", .data$Plant))) - } else if (item_case == "non_mixture_versions_no_situations") { - aesthetics$versions$color <- list("Versions" = names(dot_args[iVersion])) - aesthetics$versions$linetype <- - list("Versions" = names(dot_args[iVersion])) - } else if (item_case == "non_mixture_no_versions_situations") { - aesthetics$plot$color <- list("Situation" = quote(paste(.data$Sit_Name))) - } else if (item_case == "mixture_versions_no_situations") { - if (iVersion == 1) { - aesthetics$versions$color <- - list("Versions" = quote(paste(names(dot_args[1])))) - aesthetics$versions$linetype <- - list("Versions" = quote(paste(names(dot_args[1])))) - } else { - aesthetics$versions$color <- - list("Versions" = quote(paste(names(dot_args[iVersion])))) - aesthetics$versions$linetype <- - list("Versions" = names(dot_args[iVersion])) - } - aesthetics$plot$shape <- - list("Plant" = quote(paste(.data$Dominance, ":", .data$Plant))) - } else if (item_case == "non_mixture_versions_situations") { - aesthetics$versions$color <- list("Versions" = names(dot_args[iVersion])) - aesthetics$versions$linetype <- - list("Versions" = names(dot_args[iVersion])) - aesthetics$plot$shape <- list("Situation" = quote(.data$Sit_Name)) - } else if (item_case == "mixture_no_versions_situations") { - aesthetics$plot$color <- - list("Plant" = quote(paste(.data$Dominance, ":", .data$Plant))) - aesthetics$plot$shape <- list("Situation" = quote(.data$Sit_Name)) - } else if (item_case == "mixture_versions_situations") { - aesthetics$versions$color <- list(quote(paste(.data$Combi))) - aesthetics$versions$linetype <- - list("Versions" = names(dot_args[iVersion])) - } - return(aesthetics) -} diff --git a/R/cat_situations.R b/R/cat_situations.R index 3a03d9bd..940d7868 100644 --- a/R/cat_situations.R +++ b/R/cat_situations.R @@ -10,9 +10,6 @@ #' (named by situation) #' @param obs_sd A list (each element= situation) of `data.frame`s for the #' standard deviation of the observations (named by situation) -#' @param force Continue if the plot is not possible ? E.g. no observations for -#' scatter plots. If `TRUE`, return `NULL`, else return an error (default). -#' @param verbose Boolean. Print information during execution. #' #' @return A list of three : a list (each element=version) of a list of a single #' simulations `data.frame` named "all_situations", a list of a single @@ -20,21 +17,20 @@ #' #' @keywords internal cat_situations <- - function(list_sim = NULL, obs = NULL, obs_sd = NULL, force = FALSE, - verbose = TRUE) { + function(list_sim = NULL, obs = NULL, obs_sd = NULL) { sits <- lapply(list_sim, names) V_names <- names(list_sim) list_sim <- lapply(seq_along(list_sim), function(x) { - allsim <- bind_rows(list_sim[[x]], .id = "Sit_Name") + allsim <- bind_rows(list_sim[[x]], .id = "sit_name") # Add dominance and plant in sim data of sole crops if one of the other # situations is a mixture if ("Dominance" %in% colnames(allsim)) { for (sit_name in sits[[x]]) { if (length(unique(obs[[sit_name]]$Plant)) == 1) { - allsim$Plant[allsim$Sit_Name == sit_name] <- + allsim$Plant[allsim$sit_name == sit_name] <- unique(obs[[sit_name]]$Plant) } } @@ -52,18 +48,57 @@ cat_situations <- # situations <- names(obs) if (!is.null(obs)) { # bind the obs into a single dataframe - obs <- list(bind_rows(obs, .id = "Sit_Name")) + obs <- list(bind_rows(obs, .id = "sit_name")) names(obs) <- "all_situations" } if (!is.null(obs_sd)) { - obs_sd <- list(bind_rows(obs_sd, .id = "Sit_Name")) + obs_sd <- list(bind_rows(obs_sd, .id = "sit_name")) names(obs_sd) <- "all_situations" } return(list(list_sim, obs, obs_sd)) } +#' Format simulation and observation into a long data frame over versions +#' +#' @description Format the list of simulation data and observation data +#' into a long data frame with a new column for the version +#' +#' @param list_sim A list (each element= version) of a list +#' (each element= situation) of simulations `data.frame`s +#' +#' @return A dataframe +#' +#' @keywords internal +cat_versions <- function(list_sim = NULL) { + version_names <- names(list_sim) + + # Adding the name of the version to each dataframe: + for (i in seq_along(list_sim)) { + for (j in seq_along(list_sim[[i]])) { + list_sim[[i]][[j]]$version <- version_names[i] + } + } + + # Binding the versions for each situation (the versions are in the same + # data frame for each situation): + df_situations <- list() + for (i in seq_along(list_sim)) { + # searching which situation in list_sim[[i]] is in df_situations: + # if it is, bind_rows, else, add it to df_situations + + for (j in names(list_sim[[i]])) { + if (j %in% names(df_situations)) { + df_situations[[j]] <- bind_rows(df_situations[[j]], list_sim[[i]][[j]]) + } else { + df_situations[[j]] <- list_sim[[i]][[j]] + } + } + } + + return(df_situations) +} #' Format simulation data and observation data in order to represent some #' situations as a contiguous sequence @@ -126,7 +161,7 @@ cat_successive <- } if (new_name != "") { obs[[new_name]] <- - dplyr::bind_cols(new_obs, data.frame("Sit_Name" = col_obs)) + dplyr::bind_cols(new_obs, data.frame("sit_name" = col_obs)) } } } @@ -164,7 +199,7 @@ cat_successive <- sim[[sit]] <- NULL } sim[[new_name]] <- - dplyr::bind_cols(new_sim, data.frame("Sit_Name" = col_sim)) + dplyr::bind_cols(new_sim, data.frame("sit_name" = col_sim)) } sim }) @@ -193,21 +228,59 @@ add_situation_col <- function(dot_args, obs, obs_sd = NULL) { for (i in seq_along(dot_args)) { sit_names <- names(dot_args[[i]]) for (j in sit_names) { - dot_args[[i]][[j]]$Sit_Name <- j + dot_args[[i]][[j]]$sit_name <- j } } sit_names <- names(obs) for (j in sit_names) { - obs[[j]]$Sit_Name <- j + obs[[j]]$sit_name <- j } if (!is.null(obs_sd)) { sit_names <- names(obs_sd) for (j in sit_names) { - obs_sd[[j]]$Sit_Name <- j + obs_sd[[j]]$sit_name <- j } } return(list(dot_args, obs, obs_sd)) } + + +#' Format situations +#' +#' Format the data into a list of situations, with the situation repeated +#' as a column name, and the version also as a column name. In the case +#' of `all_situations==TRUE`, the situations are concatenated together +#' into one situation called "all_situations" (the data is a list of +#' one situation). The true situation name is still kept in the column +#' `sit_name` though. +#' +#' @param dot_args The dot arguments (the simulations). +#' @param obs The observations. +#' @param obs_sd The standard deviation of the observations. +#' @param all_situations Boolean. Do we need all situations treated +#' separately or as one. +#' @param v_names The version names. +#' +#' @return The categorized situations. +#' @keywords internal +cat_with_situation <- function(dot_args, obs, obs_sd, all_situations, v_names) { + # function body + if (all_situations) { + # If all_situations, cat all situations together for each version: + list_data <- cat_situations(dot_args, obs, obs_sd) + sim <- unlist(list_data[[1]], recursive = FALSE) + names(sim) <- v_names + sim <- list(all_situations = bind_rows(sim, .id = "version")) + } else { + # If not all_situations, add a column to each data.frame to identify the + # situation: + list_data <- add_situation_col(dot_args, obs, obs_sd) + # And bind the version data.frames together: + sim <- cat_versions(list_data[[1]]) + } + + return(list(sim = sim, obs = list_data[[2]], obs_sd = list_data[[3]])) +} diff --git a/R/cropr_formatting.R b/R/cropr_formatting.R index 8a82a531..3ac9493a 100644 --- a/R/cropr_formatting.R +++ b/R/cropr_formatting.R @@ -10,17 +10,14 @@ #' @param type The type of plot required, either "dynamic" or "scatter" #' @param select_dyn Which data to plot when `type= "dynamic"`? See details. #' @param select_scat Which data to plot when `type= "scatter"`? See details. -#' @param all_situations Boolean (default = FALSE). If `TRUE`, plot all -#' situations on the same graph. -#' If `TRUE`, \code{sim} and \code{obs} are respectively an element of the first -#' element and the -#' second element of the output of cat_situations. #' @param successive A list of lists containing the situations to be represented #' as a contiguous sequence when type = "dynamic" (dates should be contiguous) #' when `type = "dynamic"` (implies that the situations are correctly ordered). #' @param reference_var Variable selected on x-axis when type is scatter and #' select_scat is res. It is possible to select between observation and #' simulation of the reference variable. +#' @param variable A character vector indicating the variables to be kept in +#' the formatted data frame. If NULL (default), all variables are kept. #' @param verbose Logical value for displaying information while running. #' #' @details The `select_dyn` argument can be: @@ -66,8 +63,9 @@ format_cropr <- function(sim, obs = NULL, obs_sd = NULL, type = c("dynamic", "scatter"), select_dyn = c("sim", "common", "obs", "all"), - select_scat = c("sim", "res"), all_situations = FALSE, + select_scat = c("sim", "res"), successive = NULL, reference_var = NULL, + variable = NULL, verbose = TRUE) { type <- match.arg(type, c("dynamic", "scatter"), several.ok = FALSE) select_dyn <- match.arg(select_dyn, c("sim", "common", "obs", "all"), @@ -78,25 +76,92 @@ format_cropr <- function(sim, obs = NULL, obs_sd = NULL, is_obs <- !is.null(obs) && isTRUE(nrow(obs) > 0) is_obs_sd <- !is.null(obs_sd) && isTRUE(nrow(obs_sd) > 0) - is_Dominance <- grep("Dominance", x = colnames(sim), fixed = TRUE) - if (length(is_Dominance) > 0) { - is_mixture <- length(unique(sim[[is_Dominance]])) > 1 - } else { - is_mixture <- FALSE + # Keep only the situations that are in both sim and obs if any + if (type == "scatter") { + if (!is_obs) { + stop("No observations found, impossible to make scatter plot.") + } + if ("sit_name" %in% colnames(obs) && "sit_name" %in% colnames(sim)) { + inter_sit <- intersect(unique(obs$sit_name), unique(sim$sit_name)) + obs <- filter(obs, .data$sit_name %in% inter_sit) + + if (is_obs_sd) { + obs_sd <- filter(obs_sd, .data$sit_name %in% inter_sit) + } + sim <- filter(sim, .data$sit_name %in% inter_sit) + } } - if (is_mixture && is_obs && is.null(obs$Plant)) { + is_mixture_sim <- detect_mixture(sim) + is_mixture_obs <- detect_mixture(obs) + + if (is_mixture_obs && is_obs && !("Plant" %in% colnames(obs))) { stop("Detected intercrop from simulation, but the 'Plant' column is missing from the observations.") } # Treating Dominance as a factor if any (for plotting reasons): - if (is_mixture) { - sim$Dominance <- factor(sim$Dominance, levels = c("Principal", "Associated")) + if (is_mixture_sim) { + sim$Dominance <- factor( + sim$Dominance, + levels = c("Principal", "Associated") + ) + } + + # Check variable names: + if (!is.null(variable)) { + variable <- unique(subst_parenth(variable)) + var_exist <- variable %in% unique(colnames(sim)) + if (!all(var_exist)) { + stop( + "Unknown variable(s) in input data.frame: ", + paste(variable[!var_exist], collapse = ", ") + ) + } + } + + # Defining variables to keep depending on the case: + if (is_mixture_sim || is_mixture_obs) { + rem_vars <- NULL + melt_vars <- c("Date", "Plant", "Dominance") + } else { + rem_vars <- c("Plant") + melt_vars <- "Date" + } + + if (!is.null(successive)) { + melt_vars <- c(melt_vars, "succession_date") + } + + if ("sit_name" %in% colnames(sim)) { + melt_vars <- c(melt_vars, "sit_name") } + # By default, we use the same variables to melt and then to join: + join_vars <- c(melt_vars, "variable") + + # But if there are several versions of the model, we add the version + # for melting, but not for joining because the obs and obs_sd are the + # same for all versions: + if ("version" %in% colnames(sim)) { + melt_vars_sim <- c(melt_vars, "version") + } else { + melt_vars_sim <- melt_vars + } + + # Identify which columns are character vectors: + string_cols <- names(sim)[sapply(sim, is.character)] + + if (!is.null(variable)) { + rem_vars <- setdiff(colnames(sim), c(melt_vars_sim, variable)) + } + + # Add them to the variables removed from the data frame, + # but remove the ones that are used for melting: + rem_vars <- setdiff(union(rem_vars, string_cols), melt_vars_sim) + # Adding Dominance to obs if any: - if (is_obs && is_mixture) { + if (is_obs && is_mixture_obs) { if (is.null(obs$Dominance)) { # Add Dominance to obs: corresp_table <- @@ -119,12 +184,26 @@ format_cropr <- function(sim, obs = NULL, obs_sd = NULL, } } - # Only plotting common variables: - if (is_obs && ((type == "dynamic" && select_dyn == "sim") || - (type == "dynamic" && select_dyn == "common") || type == "scatter")) { - # Plot all simulations, and only obs that are simulated - s_lower <- unlist(lapply(colnames(sim), tolower)) + if (!is_obs && select_dyn %in% c("obs", "common")) { + stop( + paste( + "No observations found, impossible to select", + "`select_dyn = 'obs'` or `select_dyn = 'common'`" + ) + ) + } + + # Take all simulated variables as lowercase: + s_lower <- unlist(lapply(colnames(sim), tolower)) + + # Take all observed variables as lowercase (if any): + if (is_obs) { o_lower <- unlist(lapply(colnames(obs), tolower)) + inter <- intersect(s_lower, o_lower) + + # Check if there are duplicated variable names in the observations, + # and take the values that are not NA to replace the NA values of the + # first column: if (length(o_lower) != length(unique(o_lower))) { double <- o_lower[which(duplicated(o_lower))] if (verbose) { @@ -141,71 +220,65 @@ format_cropr <- function(sim, obs = NULL, obs_sd = NULL, to_replace[1], drop = TRUE ] <- - obs_sd[which(is.na(obs_sd[, to_replace[1]])), to_replace[2], drop = TRUE] + obs_sd[ + which(is.na(obs_sd[, to_replace[1]])), to_replace[2], + drop = TRUE + ] } } } - inter <- intersect(s_lower, o_lower) + } else { + inter <- s_lower + } + + # Get common situations + inter_sit <- intersect(unique(obs$sit_name), unique(sim$sit_name)) + + # Plot all simulations, and only obs that are simulated + if (is_obs && (type == "scatter" || select_dyn %in% c("sim", "common"))) { ind <- colnames(obs)[which(o_lower %in% inter)] obs <- obs[, ind] if (is_obs_sd) { obs_sd <- obs_sd[, ind] } + # protection for call to summary (no sit_name): + if ("sit_name" %in% names(obs)) { + ind <- obs$sit_name %in% inter_sit + obs <- obs[ind, ] + if (is_obs_sd) { + ind <- obs_sd$sit_name %in% inter_sit + obs_sd <- obs_sd[ind, ] + } + } } - if (select_dyn == "obs" || select_dyn == "common" || type == "scatter") { - if (is_obs) { - # Plot all observations, and only sim that are observed - ind <- colnames(sim)[which(s_lower %in% inter)] - sim <- sim[, ind] - # If a variable name has a wrong case (meaning uppercase/lowercase) in the obs, - # We use the name from the simulation. It happens a lot for e.g. QNplante in STICS, - # users put QNPlante instead as a variable name in the obs. - diff <- setdiff(colnames(obs), colnames(sim)) - for (d in diff) { - colnames(obs)[which(tolower(colnames(obs)) == tolower(d))] <- - colnames(sim)[which(tolower(colnames(sim)) == tolower(d))] - } - obs <- obs[, unique(colnames(obs))] - } else { - return(NULL) + # Plot all observations, and only sim that are observed + if (is_obs && select_dyn %in% c("obs", "common") || type == "scatter") { + ind <- colnames(sim)[which(s_lower %in% inter)] + if ("version" %in% s_lower) { + ind <- unique(c(ind, "version")) + } + sim <- sim[, ind] + obs <- obs[, unique(colnames(obs))] + # protection for call to summary (no sit_name): + if ("sit_name" %in% names(sim)) { + ind <- sim$sit_name %in% inter_sit + sim <- sim[ind, ] } } - # Check if there are common variables with different lettering + # Check if there are common variables in sim/obs but with different casing: if (is_obs) { o_lower <- lapply(colnames(obs), tolower) + # If so, replace the variables in obs with the ones in sim: for (col in colnames(sim)) { if (tolower(col) %in% o_lower && !(col %in% colnames(obs))) { - colnames(sim)[which(colnames(sim) == col)] <- - colnames(obs)[which(o_lower == tolower(col))] + colnames(obs)[which(o_lower == tolower(col))] <- + colnames(sim)[which(colnames(sim) == col)] } } } - if (is_mixture) { - rem_vars <- NULL - melt_vars <- c("Date", "Plant", "Dominance") - } else { - rem_vars <- c("Plant") - melt_vars <- "Date" - } - if (!is.null(successive)) { - rem_vars <- c(rem_vars, "succession_date") - } - - - if ("Sit_Name" %in% colnames(sim)) { - melt_vars <- c(melt_vars, "Sit_Name") - } - - # Identify which columns are character vectors: - string_cols <- names(sim)[sapply(sim, is.character)] - - # Add them to the variables removed from the data frame, - # but remove the ones that are used for melting: - rem_vars <- setdiff(union(rem_vars, string_cols), melt_vars) - # Create data frame like sim or obs to change reference variable when # residual scatter plot if (!is.null(reference_var)) { @@ -220,14 +293,35 @@ format_cropr <- function(sim, obs = NULL, obs_sd = NULL, ref <- sim } else if (ref_type == "res") { ref <- semi_join(sim, obs, by = melt_vars) - ref[, ref_var] <- obs[, ref_var] - ref[, ref_var] + tmp_obs <- semi_join(obs, sim, by = melt_vars) + ref[, ref_var] <- dplyr::arrange(tmp_obs, ref$sit_name) %>% + dplyr::select(tidyselect::all_of(ref_var)) - ref[, ref_var] + } else { + stop( + "The variable name given in the `reference_var` argument ", + "should end with `_sim`, `_obs` or `_res`, found: ", + ref_type + ) + } + + # Return an error if the reference variable is not in the data: + if (!(ref_var %in% colnames(sim))) { + stop( + "The variable name (", ref_var, + ") given in the `reference_var` argument (", + reference_var, + ") is not in the simulation data frame. Available variables are: ", + paste(setdiff(colnames(sim), c(melt_vars, rem_vars)), collapse = ", ") + ) } + + # Make a dataframe with only the variables, and overwrite the values with + # the reference variable: ref_tmp <- dplyr::select(ref, -tidyselect::any_of(c(melt_vars, rem_vars))) for (col in colnames(ref_tmp)) { ref_tmp[, col] <- ref[, ref_var] } ref[, colnames(ref_tmp)] <- ref_tmp - ref <- ref %>% dplyr::select(-tidyselect::any_of(rem_vars)) %>% @@ -243,7 +337,11 @@ format_cropr <- function(sim, obs = NULL, obs_sd = NULL, df <- sim %>% dplyr::select(-tidyselect::any_of(rem_vars)) %>% - reshape2::melt(id.vars = melt_vars, na.rm = TRUE, value.name = "Simulated") + reshape2::melt( + id.vars = melt_vars_sim, + na.rm = TRUE, + value.name = "Simulated" + ) if (is_obs) { obs <- @@ -282,18 +380,23 @@ format_cropr <- function(sim, obs = NULL, obs_sd = NULL, df$variable <- as.character(df$variable) } - df <- dplyr::full_join(df, obs, by = c(melt_vars, "variable")) + df <- dplyr::full_join(df, obs, by = join_vars) # Add standard deviation to data frame if (is_obs_sd) { - df <- dplyr::full_join(df, obs_sd, by = c(melt_vars, "variable")) + df <- dplyr::full_join(df, obs_sd, by = join_vars) } # Add reference variable to data frame (when type is residual scatter) if (!is.null(reference_var)) { - df <- dplyr::full_join(df, ref, by = c(melt_vars, "variable")) + df <- dplyr::full_join(df, ref, by = join_vars) } } + # We want the residuals too if select_scat == "res" + if (select_scat == "res") { + df$Residuals <- df$Observed - df$Simulated + } + return(df) } diff --git a/R/cropr_plotting.R b/R/cropr_plotting.R index 4914e1d4..8a0a1e98 100644 --- a/R/cropr_plotting.R +++ b/R/cropr_plotting.R @@ -119,8 +119,7 @@ plot.cropr_simulation <- function( situation_group = situation_group, reference_var = reference_var, force = force, - verbose = verbose, - formater = format_cropr + verbose = verbose ) } @@ -159,7 +158,6 @@ autoplot.cropr_simulation <- function( situation_group = situation_group, reference_var = reference_var, force = force, - verbose = verbose, - formater = format_cropr + verbose = verbose ) } diff --git a/R/cropr_stats.R b/R/cropr_stats.R index dac4c671..4fdb7fd1 100644 --- a/R/cropr_stats.R +++ b/R/cropr_stats.R @@ -63,7 +63,6 @@ summary.cropr_simulation <- function( obs = obs, stat = stat, all_situations = all_situations, - verbose = verbose, - formater = format_cropr + verbose = verbose ) } diff --git a/R/extract_plot.R b/R/extract_plot.R index ccf1199b..a281e153 100644 --- a/R/extract_plot.R +++ b/R/extract_plot.R @@ -50,17 +50,30 @@ extract_plot <- function(plot, var = NULL, situation = NULL, force = FALSE, ) } stop("plot argument is not a named list") - } else { - situations_names <- names(plot) } ex <- plot - if (!is.null(var)) { - for (name in situations_names) { + if (!is.null(situations)) { + situations <- match.arg(situations, names(plot), several.ok = TRUE) + ex <- ex[situations] + } + + selected_vars <- var + if (!is.null(selected_vars)) { + for (name in names(ex)) { if (!is.null(class(ex[[name]]))) { - if (any(var %in% ex[[name]]$data$variable)) { + if (any(selected_vars %in% ex[[name]]$data$var)) { + gb <- ggplot2::ggplot_build(ex[[name]]) + layout <- gb$layout$layout %>% + dplyr::filter(.data$var %in% selected_vars) + ex[[name]]$facet$new_x_scales <- ex[[name]]$facet$new_x_scales[ + layout$PANEL + ] + ex[[name]]$facet$new_y_scales <- ex[[name]]$facet$new_y_scales[ + layout$PANEL + ] ex[[name]]$data <- ex[[name]]$data %>% - dplyr::filter(.data$variable %in% var) + dplyr::filter(.data$var %in% selected_vars) } else { ex[[name]] <- ggplot2::ggplot() + ggplot2::theme_void() @@ -68,9 +81,5 @@ extract_plot <- function(plot, var = NULL, situation = NULL, force = FALSE, } } } - if (!is.null(situations)) { - situations <- match.arg(situations, names(plot), several.ok = TRUE) - ex <- ex[situations] - } ex } diff --git a/R/generic_formatting.R b/R/generic_formatting.R index 557e3edb..d7ab9f19 100644 --- a/R/generic_formatting.R +++ b/R/generic_formatting.R @@ -4,7 +4,6 @@ #' parameters. #' #' @param df A data frame to be formatted (e.g. output from `format_cropr`). -#' @param var A character string indicating the variable to be formatted. #' @param overlap A logical value indicating whether there is any overlapping #' variables desired in the plot. #' @param situation_group A character string indicating the situation group. @@ -12,28 +11,26 @@ #' scatter). #' @param shape_sit A logical value indicating whether the shape should be #' based on the situation. -#' @param several_sit A logical value indicating whether there are several +#' @param has_distinct_situations A logical value indicating whether there +#' are several #' situations to plot. #' @param total_vers An integer indicating the total number of versions. -#' @param num_vers An integer indicating the id of the current version. #' -#' @return A formatted data frame. +#' @return A long data frame with the formatted data, with columns +#' Date, Plant, Dominance, sit_name, version, variable, Simulated, Observed. +#' Column "Combi" can also be added if there are three different +#' characteristics to plot. #' @keywords internal #' -generic_formatting <- function(df, var, overlap, situation_group, type, shape_sit, several_sit, total_vers, num_vers) { - # Filter selected variables - if (!is.null(var)) { - var <- unique(c(var, subst_parenth(var))) - var_exist <- var %in% unique(df$variable) - if (!all(var_exist)) { - stop( - "Unknown variable(s) in input data.frame: ", - paste(var[!var_exist], collapse = ", ") - ) - } - df <- df %>% dplyr::filter(.data$variable %in% var) - } - +generic_formatting <- function( + df, + overlap, + situation_group, + type, + shape_sit, + has_distinct_situations, + total_vers +) { # Replace NAs with "Single-crop" in Dominance in order to make # the legend understandable if ("Dominance" %in% colnames(df)) { @@ -56,16 +53,17 @@ generic_formatting <- function(df, var, overlap, situation_group, type, shape_si as.character(df$variable[which(is.na(df$group_var))]) } - # Change Sit_Name column with names of situation + # Change sit_name column with names of situation # groups if shape_sit=="group" - if (several_sit && shape_sit == "group" && !is.null(situation_group)) { + if (has_distinct_situations && shape_sit == "group" && + !is.null(situation_group)) { for (grp in seq_along(situation_group)) { sits <- situation_group[[grp]] if (!is.null(names(situation_group))) { - df$Sit_Name[which(df$Sit_Name %in% sits)] <- + df$sit_name[which(df$sit_name %in% sits)] <- names(situation_group)[[grp]] } else { - df$Sit_Name[which(df$Sit_Name %in% sits)] <- + df$sit_name[which(df$sit_name %in% sits)] <- paste(sits, collapse = ";") } } @@ -80,16 +78,16 @@ generic_formatting <- function(df, var, overlap, situation_group, type, shape_si data.frame( "Combi" = paste( - rep(paste0("Version_", num_vers), nrow(df)), + df$version, "|", df$variable, "|", paste(df$Dominance, ":", df$Plant) ) ) ) } - # NB: several_sit means one plot for all situation (or successive) and shape - # is symbol or group - if (type == "scatter" && several_sit && (total_vers > 1) && + # NB: has_distinct_situations means one plot for all situation (or + # successive) and shape is symbol or group + if (type == "scatter" && has_distinct_situations && (total_vers > 1) && ("Plant" %in% colnames(df))) { df <- dplyr::bind_cols( @@ -97,13 +95,16 @@ generic_formatting <- function(df, var, overlap, situation_group, type, shape_si data.frame( "Combi" = paste( - rep(paste0("Version_", num_vers), nrow(df)), - "|", df$Sit_Name, "|", + df$version, + "|", df$sit_name, "|", paste(df$Dominance, ":", df$Plant) ) ) ) } - return(df) + # Rename variable to var + df <- dplyr::rename(df, var = variable) + + df } diff --git a/R/generic_plotting.R b/R/generic_plotting.R index 667553d0..44ec8e40 100644 --- a/R/generic_plotting.R +++ b/R/generic_plotting.R @@ -1,367 +1,3 @@ -#' Generic plotting of a situation -#' -#' @description Plots outputs of a model (and observations) for one situation. -#' This function is used as a generic plotting function for any models. -#' To use it with your own model, please provide a wrapper function around your -#' model to format the outputs used by this function (see [format_cropr()] for a -#' template), and then provide your custom function as an argument to this one. -#' -#' @param sim A simulation data.frame -#' @param obs An observation data.frame (variable names must match) -#' @param obs_sd A data.frame of standard deviations of observations -#' @param select_dyn Which data to plot when `type= "dynamic"`? See details. -#' @param select_scat Which data to plot when `type= "scatter"`? See details. -#' @param var A vector of variables that should be displayed on the graph. -#' @param title The plot title -#' @param all_situations Boolean (default = TRUE). If `TRUE`, plot all -#' situations on the same graph. -#' @param overlap A list of lists containing the variables to represent on -#' the same graph when `type = "dynamic"`. -#' @param successive A list of lists containing the situations to be represented -#' as a contiguous sequence when `type = "dynamic"` -#' (implies that the situations are correctly ordered). -#' @param shape_sit Shape to differentiate between situations when -#' `all_situations= TRUE`. See details. -#' @param situation_group A list of lists of situations to gather when -#' `shape_sit= "group"`. -#' @param reference_var Variable selected on x-axis when type is scatter and -#' select_scat is res. It is possible to select -#' between observation and simulation of the reference variable. -#' (examples : reference_var = "lai_n_obs", reference_var = "mafruit_sim") -#' @param force Continue if the plot is not possible ? E.g. no observations for -#' scatter plots. If `TRUE`, return `NULL`, else return an error (default). -#' @param verbose Boolean. Print information during execution. -#' @param formater The function used to format the models outputs and -#' observations in a standard way. You can design your own function that format -#' one situation and provide it here. -#' -#' @details The `select_dyn` argument can be: -#' * "sim" (the default): all variables with simulations outputs, and -#' observations when there are some -#' * "common": variables with simulations outputs and observations in common -#' * "obs": all variables with observations, and simulations outputs -#' when there are some -#' * "all": all variables with any observations or simulations outputs -#' -#' @details The `select_scat` argument can be: -#' * "sim" (the default): plots observations in X and simulations in Y. -#' * "res": plots observations in X and residuals(observations-simulations)in Y. -#' -#' @details The `shape_sit` argument can be: -#' * "none" (the default): Same shape for all situations. -#' * "txt": Writes the name of the situation above each point. -#' * "symbol": One shape for each situation. -#' * "group": One shape for each group of situations described in -#' `situation_group`. -#' -#' @note The error bar will be equal to 2*`obs_sd` on each side of the point to -#' have 95% confidence. -#' -#' @importFrom rlang .data -#' @importFrom utils head -#' @return A ggplot object -#' @keywords internal -#' -plot_generic_situation <- function( - sim, - obs = NULL, - obs_sd = NULL, - type = c("dynamic", "scatter"), - select_dyn = c("sim", "common", "obs", "all"), - select_scat = c("sim", "res"), - var = var, - title = NULL, - all_situations = TRUE, - overlap = NULL, - successive = NULL, - shape_sit = c("none", "txt", "symbol", "group"), - situation_group = NULL, - total_vers = 1, - num_vers = 1, - reference_var = NULL, - force = FALSE, - verbose = TRUE, - formater -) { - is_obs <- !is.null(obs) && nrow(obs) > 0 - is_obs_sd <- !is.null(obs_sd) && nrow(obs_sd) > 0 - several_sit <- (all_situations || !is.null(successive)) && - shape_sit %in% c("symbol", "group") - - # Testing if the obs and sim have the same plants names: - if (is_obs && !is.null(obs$Plant) && !is.null(sim$Plant)) { - common_crops <- unique(sim$Plant) %in% unique(obs$Plant) - - if (any(!common_crops)) { - cli::cli_alert_warning(paste0( - "Observed and simulated crops are different. - Obs Plant: ", - "{.value {unique(obs$Plant)}}, - Sim Plant: {.value {unique(sim$Plant)}}" - )) - } - } - - formated_df <- formater( - sim, - obs, - obs_sd, - type, - select_dyn, - select_scat, - all_situations, - successive = successive, - reference_var = reference_var - ) - - # Apply some generic transformations to the data.frame: - formated_df <- generic_formatting( - formated_df, - var, - overlap, - situation_group, - type, - shape_sit, - several_sit, - total_vers, - num_vers - ) - - # In case obs is given but no common variables between obs and sim: - if (is.null(formated_df$Observed)) { - is_obs <- FALSE - } - - if ( - is.null(formated_df) || - (!is_obs && - (type == "scatter" || select_dyn == "common" || select_dyn == "obs")) - ) { - # No common observations and simulations when type=="scatter" or - # select_dyn=="common" or select_dyn=="obs" - if (verbose) { - cli::cli_alert_warning("No observations found for required variables") - } - if (force) { - return(NULL) - } else { - stop("No observations found. Use `force = TRUE` to avoid this error.") - } - } - - aesth <- aesthetics( - sim, - obs, - type = type, - overlap = overlap, - several_sit = several_sit, - shape_sit = shape_sit, - one_version = (total_vers == 1) - )$plot - - # Plot the simulations: - if (type == "dynamic") { - situation_plot <- - formated_df %>% - ggplot2::ggplot(ggplot2::aes( - y = .data$Simulated, - x = .data$Date, - linetype = !!aesth$linetype[[1]], - shape = !!aesth$shape[[1]], - color = !!aesth$color[[1]], - group = !!aesth$group[[1]] - )) + - # ggplot2::geom_line(na.rm = TRUE) + - ggplot2::labs( - color = names(aesth$color), - linetype = names(aesth$linetype), - shape = names(aesth$shape) - ) + - ggplot2::scale_shape_manual(values = c(0:40)) + - ggplot2::ggtitle(title) + - ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 90)) - # Facet based on variable or group_var according to overlap - if (is.null(overlap)) { - situation_plot <- situation_plot + - ggplot2::facet_wrap(. ~ .data$variable, scales = "free") - } else { - situation_plot <- situation_plot + - ggplot2::facet_wrap(. ~ .data$group_var, scales = "free") - # + ggplot2::theme(strip.text.x = ggplot2::element_blank()) - } - # Adding the observations if any: - # if (is_obs) { - # # situation_plot <- situation_plot + - # # ggplot2::geom_point( - # # ggplot2::aes( - # # y = .data$Observed - # # ), na.rm = TRUE) - # if (is_obs_sd) { - # situation_plot <- situation_plot + - # ggplot2::geom_errorbar(ggplot2::aes( - # ymin = .data$Observed - 2 * .data$Obs_SD, - # ymax = .data$Observed + 2 * .data$Obs_SD - # ), na.rm = TRUE) - # } - # } - # Add vertical lines if sim contains successive situations - if (!is.null(successive) && "Sit_Name" %in% colnames(sim)) { - successions <- head(unique(sim$succession_date), -1) - # NB: head(x, -1) removes the last value - situation_plot <- situation_plot + - ggplot2::geom_vline( - xintercept = successions, - linetype = "dashed", - color = "grey", - linewidth = 1 - ) - } - } else { - if (select_scat == "sim") { - situation_plot <- - formated_df %>% - dplyr::filter(!is.na(.data$Observed) & !is.na(.data$Simulated)) %>% - ggplot2::ggplot(ggplot2::aes( - y = .data$Simulated, - x = .data$Observed, - shape = !!aesth$shape[[1]], - linetype = !!aesth$linetype[[1]], - color = !!aesth$color[[1]] # , - )) + - ggplot2::geom_point(na.rm = TRUE) + - ggplot2::geom_abline( - intercept = 0, - slope = 1, - color = "grey30", - linetype = 2 - ) + - ggplot2::geom_smooth( - ggplot2::aes( - y = .data$Simulated, - x = .data$Observed, - group = 1 - ), - inherit.aes = FALSE, - method = lm, - color = "blue", - se = FALSE, - linewidth = 0.6, - formula = y ~ x, - fullrange = TRUE, - na.rm = TRUE - ) + - # Invisible points of coordinates (y,x) allowing to have both axes at - # the same scale - ggplot2::geom_point( - mapping = ggplot2::aes( - x = .data$Simulated, - y = .data$Observed - ), - alpha = 0, - na.rm = TRUE - ) - - if (is_obs_sd) { - situation_plot <- situation_plot + - ggplot2::geom_errorbarh( - ggplot2::aes( - xmin = .data$Observed - 2 * .data$Obs_SD, - xmax = .data$Observed + 2 * .data$Obs_SD - ), - na.rm = TRUE - ) - } - } - - if (select_scat == "res") { - situation_plot <- - if (is.null(reference_var)) { - formated_df %>% - ggplot2::ggplot(ggplot2::aes( - y = .data$Observed - .data$Simulated, - x = .data$Observed, - shape = !!aesth$shape[[1]], - linetype = !!aesth$linetype[[1]], - color = !!aesth$color[[1]], - group = .data$Sit_Name, - )) - } else { - formated_df %>% - ggplot2::ggplot(ggplot2::aes( - y = .data$Observed - .data$Simulated, - x = .data$Reference, - shape = !!aesth$shape[[1]], - linetype = !!aesth$linetype[[1]], - color = !!aesth$color[[1]], - group = .data$Sit_Name - )) - } - - situation_plot <- situation_plot + - ggplot2::ylab("Residuals") + - ggplot2::geom_point(na.rm = TRUE) + - ggplot2::geom_abline( - intercept = 0, - slope = 0, - color = "grey30", - linetype = 2 - ) + - ggplot2::geom_smooth( - data = situation_plot$data, - ggplot2::aes( - y = !!situation_plot$mapping$y, - x = !!situation_plot$mapping$x, - ), - inherit.aes = FALSE, - method = lm, - se = FALSE, - linewidth = 0.6, - formula = y ~ x, - fullrange = TRUE, - na.rm = TRUE - ) - # Invisible points of coordinates (y,x) allowing to have both axes at - # the same scale - # if (is.null(reference_var)) { - # ggplot2::geom_point(mapping = ggplot2::aes(x = .data$Observed - - # .data$Simulated, y = .data$Observed), alpha = 0, na.rm=TRUE) - # }else{ - # ggplot2::geom_point(mapping = ggplot2::aes(x = .data$Observed - - # .data$Simulated, y = .data$Reference), alpha = 0, na.rm=TRUE) - # } - } - - situation_plot <- situation_plot + - formated_df %>% - ggplot2::labs( - shape = names(aesth$shape), - linetype = names(aesth$linetype), - color = names(aesth$color) - ) + - ggplot2::facet_wrap(. ~ .data$variable, scales = "free") + - ggplot2::theme(aspect.ratio = 1) + - ggplot2::ggtitle(title) + - if (shape_sit == "txt") { - ggrepel::geom_text_repel( - ggplot2::aes(label = .data$Sit_Name), - na.rm = TRUE, - show.legend = FALSE, - max.overlaps = Inf - ) - } - - if (all_situations) { - situation_plot <- situation_plot + - ggplot2::ggtitle(ggplot2::element_blank()) - } - if (!is.null(reference_var)) { - situation_plot <- situation_plot + ggplot2::xlab(reference_var) - } - } - situation_plot -} - - #' Generic plotting function for all models #' #' @description Plots simulation outputs for one or several situations with or @@ -393,17 +29,13 @@ plot_generic_situation <- function( #' `all_situations= TRUE`. See details. #' @param situation_group A list of lists of situations to gather when #' `shape_sit= "group"`. -#' @param reference_var Variable selected on x-axis when type is scaĆ©tter and +#' @param reference_var Variable selected on x-axis when type is scatter and #' select_scat is res. It is possible to select #' between observation and simulation of the reference variable. #' (examples : reference_var = "lai_n_obs", reference_var = "mafruit_sim") #' @param force Continue if the plot is not possible ? E.g. no observations for #' scatter plots. If `TRUE`, return `NULL`, else return an error (default). #' @param verbose Boolean. Print information during execution. -#' @param formater The function used to format the models outputs and -#' observations in a standard way. You can design your own function -#' that format one situation and provide it here (see [plot_generic_situation()] -#' and [format_cropr()] for more information). #' #' @details The `select_dyn` argument can be: #' * "sim" (the default): all variables with simulations outputs, and @@ -430,391 +62,194 @@ plot_generic_situation <- function( #' a situation #' #' @keywords internal -plot_situations <- function( - ..., - obs = NULL, - obs_sd = NULL, - type = c("dynamic", "scatter"), - select_dyn = c("sim", "common", "obs", "all"), - select_scat = c("sim", "res"), - var = NULL, - title = NULL, - all_situations = TRUE, - overlap = NULL, - successive = NULL, - shape_sit = c("none", "txt", "symbol", "group"), - situation_group = NULL, - reference_var = NULL, - force = FALSE, - verbose = TRUE, - formater -) { - dot_args <- list(...) - - type <- match.arg(type, c("dynamic", "scatter"), several.ok = FALSE) - select_dyn <- match.arg( - select_dyn, - c("sim", "common", "obs", "all"), - several.ok = FALSE - ) - select_scat <- match.arg(select_scat, c("sim", "res"), several.ok = FALSE) - shape_sit <- match.arg( - shape_sit, - c("none", "txt", "symbol", "group"), - several.ok = FALSE +plot_situations <- function(..., obs = NULL, obs_sd = NULL, + type = c("dynamic", "scatter"), + select_dyn = c("sim", "common", "obs", "all"), + select_scat = c("sim", "res"), var = NULL, + title = NULL, all_situations = TRUE, + overlap = NULL, successive = NULL, + shape_sit = c("none", "txt", "symbol", "group"), + situation_group = NULL, reference_var = NULL, + force = FALSE, verbose = TRUE) { + args_list <- parse_plot_situations_args( + list(...), obs, obs_sd, type, select_dyn, select_scat, var, title, + all_situations, overlap, successive, shape_sit, situation_group, + reference_var, force, verbose ) - if (select_scat == "res" || shape_sit != "none") { - type <- "scatter" - } - - # Disable all_situations when type=="dynamic" temporarily - if (type == "dynamic") { - all_situations <- FALSE - } - - # Enable successive and overlap only when type=="dynamic" - if (!is.null(successive) || !is.null(overlap)) { - type <- "dynamic" - } - - # Text on scatter plots only if all_situations - if (shape_sit != "none") { - all_situations <- TRUE - } - - # Enable reference variable edit only when plotting residual scatter plot - if (!is.null(reference_var)) { - type <- "scatter" - select_scat <- "res" - } - - if (!is.null(situation_group)) { - shape_sit <- "group" - } - - if (shape_sit == "group" && is.null(situation_group)) { - if (verbose) { - cli::cli_alert_warning( - "Argument `situation_group` must be defined - when `shape_sit` is 'group'" - ) - } - if (force) { - return(NULL) - } else { - stop( - "Argument `situation_group` not defined. Use `force = TRUE` to avoid this error." - ) - } - } - - several_sit <- (all_situations || !is.null(successive)) && - shape_sit %in% c("symbol", "group") - - # Name the models: - v_names <- names(dot_args) - if (is.null(v_names) || length(v_names) < length(dot_args)) { - v_names <- paste0("Version_", seq_along(dot_args)) - names(dot_args) <- v_names - } - - # Don't show group in legend if only one: - if (length(v_names) == 1) { - showlegend <- FALSE - } else { - showlegend <- TRUE - } - - # If there are successive situations: - if (!is.null(successive)) { - # Cat situations that need to be represented as a contiguous sequence(dynamic) - list_rot <- cat_successive(dot_args, obs, successive) - dot_args <- list_rot[[1]] - obs <- list_rot[[2]] - } + dot_args <- args_list$dot_args + obs <- args_list$obs + obs_sd <- args_list$obs_sd + type <- args_list$type + select_dyn <- args_list$select_dyn + select_scat <- args_list$select_scat + var <- args_list$var + title <- args_list$title + all_situations <- args_list$all_situations + overlap <- args_list$overlap + successive <- args_list$successive + shape_sit <- args_list$shape_sit + situation_group <- args_list$situation_group + reference_var <- args_list$reference_var + force <- args_list$force + verbose <- args_list$verbose + v_names <- args_list$v_names + one_version <- args_list$one_version + has_distinct_situations <- args_list$has_distinct_situations + common_situations_models <- args_list$common_situations_models + is_obs <- args_list$is_obs + is_obs_sd <- args_list$is_obs_sd + + situations_outputs <- cat_with_situation( + dot_args, obs, obs_sd, all_situations, v_names + ) - # Intersect situations between versions - common_situations_models <- names(dot_args[[1]]) - if (length(dot_args) > 1) { - for (index in 2:length(dot_args)) { - common_situations_models <- intersect( - common_situations_models, - names(dot_args[[index]]) - ) - } - } + sim <- situations_outputs$sim + obs <- situations_outputs$obs + obs_sd <- situations_outputs$obs_sd - # In order to plot a single graph with all situations - if (all_situations) { - if (is.null(obs)) { - situations_names <- common_situations_models - } else { - situations_names <- intersect(common_situations_models, names(obs)) - # In case a simulation or an observation is missing - } - common_situations_models <- list("all_situations") - } - - if (length(title) == 1) { - if (!all_situations) { - title <- rep(title, length(common_situations_models)) - names(title) <- common_situations_models - } else { - title <- title - } - } - - if ( - !is.null(title) && - length(title) != length(common_situations_models) && - is.null(names(title)) - ) { - if (verbose) { - cli::cli_alert_danger( - "Situations number is different from model(s) - outputs, please name the {.code title} argument - with the situations names." - ) + # Testing if the obs and sim have the same plants names: + if (is_obs && "Plant" %in% colnames(obs) && "Plant" %in% colnames(sim)) { + common_crops <- unique(sim$Plant) %in% unique(obs$Plant) + if (any(!common_crops)) { + cli::cli_alert_warning(paste0( + "Observed and simulated crops are different. Observed: ", + "{.value {unique(obs$Plant)}}, Simulated: {.value {unique(sim$Plant)}}" + )) } - # Situations number is different from models outputs, can't guess - # which title is for which situation. - stop("title argument is not a named list") - } - - if (!is.null(title) && is.null(names(title))) { - # title is provided by the user, is not named, but has same length than - # common_situations_models, so we guess it: - names(title) <- common_situations_models - } - - # Restructure data into a list of one single element if all_situations - if (all_situations) { - list_data <- cat_situations(dot_args, obs, obs_sd) - dot_args <- list_data[[1]] - obs <- list_data[[2]] - obs_sd <- list_data[[3]] - } else { - list_data <- add_situation_col(dot_args, obs, obs_sd) - dot_args <- list_data[[1]] - obs <- list_data[[2]] - obs_sd <- list_data[[3]] } - general_plot <- list() - - for (iVersion in seq_along(dot_args)) { - for (j in common_situations_models) { - sim_plot <- - plot_generic_situation( - sim = dot_args[[iVersion]][[j]], - obs = obs[[j]], - obs_sd = obs_sd[[j]], - type = type, - select_dyn = select_dyn, - select_scat = select_scat, - var = var, - title = if (!is.null(title)) { - title - } else { - j - }, - all_situations = all_situations, - overlap = overlap, - successive = successive, - shape_sit = shape_sit, - situation_group = situation_group, - total_vers = length(dot_args), - num_vers = iVersion, - reference_var = reference_var, - force = force, - verbose = verbose, - formater = formater + formated_situation_list <- lapply( + common_situations_models, + function(x) { + df_sit <- format_cropr( + sim[[x]], + obs[[x]], + obs_sd[[x]], + type, select_dyn, select_scat, + successive = successive, + reference_var = reference_var, + verbose = verbose, + variable = var + ) %>% + generic_formatting( + overlap, situation_group, type, shape_sit, + has_distinct_situations, length(dot_args) ) - if (is.null(sim_plot)) { - if (length(v_names) == 1) { - warning( - "no common data found between simulation and observation for ", - j + if (is.null(df_sit) || ( + is.null(df_sit$Observed) && + ( + type == "scatter" || + select_dyn == "common" || + select_dyn == "obs" ) - } else { - warning( - "no common data found between simulation and observation for version `", - v_names[iVersion], - "`, and situation(s): ", - j + ) + ) { + # No common observations and simulations when type=="scatter" or + # select_dyn=="common" or select_dyn=="obs" + if (verbose) { + cli::cli_alert_warning( + "No observations found for required variables for situation ", + unique(df_sit$sit_name) ) } - next() - } - - # Initialize the plot whenever a plot is returned (can be NULL if no - # common sim/obs) - if (is.null(general_plot[[j]])) { - general_plot[[j]] <- sim_plot - if (showlegend) { - general_plot[[j]] <- general_plot[[j]] + ggplot2::labs("") - } - } - - aesth <- aesthetics( - dot_args[[iVersion]][[j]], - obs[[j]], - type = type, - overlap = overlap, - several_sit = several_sit, - shape_sit = shape_sit, - iVersion = iVersion, - one_version = (length(dot_args) == 1), - dot_args = dot_args - )$versions - - if (type == "dynamic") { - if (is.null(aesth$linetype[[1]]) && length(v_names) == 1) { - general_plot[[j]] <- - general_plot[[j]] + - ggplot2::geom_line(ggplot2::aes(), na.rm = TRUE) + if (force) { + df_sit <- NULL } else { - general_plot[[j]] <- - general_plot[[j]] + - ggplot2::geom_line( - data = sim_plot$data, - ggplot2::aes_( - color = aesth$color[[1]], - linetype = aesth$linetype[[1]] - ), - na.rm = TRUE - ) + stop("No observations found for situation ", unique(df_sit$sit_name)) } + } - # Add observations points if any - if (!is.null(obs[[j]]) && nrow(obs[[j]]) > 0) { - if (is.null(aesth$shape[[1]]) && length(v_names) == 1) { - general_plot[[j]] <- - general_plot[[j]] + - ggplot2::geom_point( - ggplot2::aes_(y = quote(.data$Observed)), - na.rm = TRUE - ) - } else { - general_plot[[j]] <- - general_plot[[j]] + - ggplot2::geom_point( - ggplot2::aes_( - y = quote(.data$Observed), - color = aesth$color[[1]], - shape = aesth$shape[[1]] - ), - na.rm = TRUE - ) - } - } + df_sit + } + ) - if (!is.null(obs_sd[[j]]) && (nrow(obs_sd[[j]]) > 0)) { - general_plot[[j]] <- - general_plot[[j]] + - ggplot2::geom_errorbar( - data = sim_plot$data, - ggplot2::aes_( - ymin = sim_plot$data$Observed - 2 * sim_plot$data$Obs_SD, - ymax = sim_plot$data$Observed + 2 * sim_plot$data$Obs_SD, - color = aesth$color[[1]], - linetype = aesth$linetype[[1]] - ), - width = 10, - na.rm = TRUE - ) - } - } else { - if (is.null(aesth$color[[1]])) { - general_plot[[j]] <- - general_plot[[j]] + - ggplot2::geom_point(ggplot2::aes_(), na.rm = TRUE) - } else { - general_plot[[j]] <- - general_plot[[j]] + - ggplot2::geom_point( - data = sim_plot$data, - ggplot2::aes_( - color = aesth$color[[1]] - ), - na.rm = TRUE - ) - } + names(formated_situation_list) <- common_situations_models - # Add regression line if any - if (!is.null(aesth$linetype[[1]])) { - general_plot[[j]] <- - general_plot[[j]] + - ggplot2::geom_smooth( - data = sim_plot$data, - ggplot2::aes_( - linetype = aesth$linetype[[1]], - y = quote(.data$Simulated), - x = quote(.data$Observed), - group = 1 - ), - inherit.aes = FALSE, - method = lm, - colour = "blue", - se = FALSE, - linewidth = 0.6, - formula = y ~ x, - fullrange = TRUE, - na.rm = TRUE - ) - } else { - general_plot[[j]] <- - general_plot[[j]] + - ggplot2::geom_smooth( - ggplot2::aes( - y = !!general_plot[[j]]$mapping$y, - x = !!general_plot[[j]]$mapping$x, - group = 1 - ), - inherit.aes = FALSE, - method = lm, - colour = "blue", - se = FALSE, - linewidth = 0.6, - formula = y ~ x, - fullrange = TRUE, - na.rm = TRUE - ) - } + p <- list() + for (i in common_situations_models) { + sim_situation <- formated_situation_list[[i]] + mixture <- detect_mixture(sim_situation) + item_case <- detect_item_case( + type, mixture, one_version, has_distinct_situations, overlap + ) - if (shape_sit == "txt") { - if (is.null(aesth$color[[1]])) { - general_plot[[j]] <- - general_plot[[j]] + - ggrepel::geom_text_repel( - data = sim_plot$data, - ggplot2::aes_(label = sim_plot$data$Sit_Name), - na.rm = TRUE, - show.legend = FALSE, - max.overlaps = Inf - ) - } else { - general_plot[[j]] <- - general_plot[[j]] + - ggrepel::geom_text_repel( - data = sim_plot$data, - ggplot2::aes_( - label = sim_plot$data$Sit_Name, - color = aesth$color[[1]], - ), - na.rm = TRUE, - show.legend = FALSE, - max.overlaps = Inf - ) - } - } - } + plot_title <- if (!is.null(title)) { + title[[i]] + } else if (type == "scatter" && all_situations == TRUE) { + "All situations" + } else { + i } + + p[[i]] <- switch(item_case, + # Dynamic plots: + "mixture_versions_overlap" = + plot_dynamic_mixture_versions_overlap(sim_situation, i, + title = plot_title + ), + "mixture_versions_no_overlap" = + plot_dynamic_mixture_versions(sim_situation, i, title = plot_title), + "mixture_no_versions_overlap" = + plot_dynamic_mixture_overlap(sim_situation, i, title = plot_title), + "mixture_no_versions_no_overlap" = plot_dynamic_mixture(sim_situation, i, + title = plot_title + ), + "non_mixture_versions_overlap" = + plot_dynamic_versions_overlap(sim_situation, i, title = plot_title), + "non_mixture_versions_no_overlap" = + plot_dynamic_versions(sim_situation, i, title = plot_title), + "non_mixture_no_versions_overlap" = + plot_dynamic_overlap(sim_situation, i, title = plot_title), + "non_mixture_no_versions_no_overlap" = + plot_dynamic(sim_situation, i, successive, title = plot_title), + + # Scatter plots: + "mixture_versions" = + plot_scat_mixture_versions( # per sit and all sit share the same call + sim_situation, i, select_scat, shape_sit, + reference_var, is_obs_sd, + title = plot_title + ), + "mixture_no_versions" = # per sit and all sit share the same call + plot_scat_mixture_allsit( + sim_situation, i, select_scat, shape_sit, + reference_var, is_obs_sd, + title = plot_title + ), + "non_mixture_versions_situations" = + plot_scat_versions_allsit( + sim_situation, i, select_scat, shape_sit, + reference_var, is_obs_sd, + title = plot_title + ), + "non_mixture_versions_per_situations" = + plot_scat_versions_per_sit( + sim_situation, i, select_scat, shape_sit, + reference_var, is_obs_sd, + title = plot_title + ), + "non_mixture_no_versions_situations" = + plot_scat_allsit( + sim_situation, i, select_scat, shape_sit, + reference_var, is_obs_sd, + title = plot_title, has_distinct_situations = has_distinct_situations, + one_version = one_version, mixture = mixture + ), + "non_mixture_no_versions_per_situations" = + plot_scat_allsit( + sim_situation, i, select_scat, shape_sit, + reference_var, is_obs_sd, + title = plot_title, has_distinct_situations = has_distinct_situations, + one_version = one_version, mixture = mixture + ) + ) } - general_plot + names(p) <- common_situations_models + + return(p) } @@ -869,17 +304,11 @@ plot_situations <- function( #' # R2 and nRMSE stats for two groups of simulations: #' summary(sim1 = sim, sim2 = sim, obs = obs, stats = c("R2", "nRMSE")) #' -plot.statistics <- function( - x, - xvar = c("group", "situation"), - type = c("bar", "radar"), - group_bar = c("rows", "stack", "dodge"), - crit_radar = NULL, - title = NULL, - force = FALSE, - verbose = TRUE, - ... -) { +plot.statistics <- function(x, xvar = c("group", "situation"), + type = c("bar", "radar"), + group_bar = c("rows", "stack", "dodge"), + crit_radar = NULL, + title = NULL, force = FALSE, verbose = TRUE, ...) { xvar <- match.arg(xvar, c("group", "situation")) type <- match.arg(type, c("bar", "radar")) group_bar <- match.arg(group_bar, c("rows", "stack", "dodge")) @@ -895,7 +324,8 @@ plot.statistics <- function( reshape2::melt( id.vars = c("group", "situation", "variable"), variable.name = "statistic" - ) + ) %>% + dplyr::rename(var = variable) if (type == "bar") { if (is.null(title)) { @@ -926,8 +356,7 @@ plot.statistics <- function( ggplot2::ggplot(ggplot2::aes(y = .data$value, x = !!xvariable)) + ggplot2::facet_grid( rows = ggplot2::vars(.data$statistic), - cols = ggplot2::vars(.data$variable), - scales = "free" + cols = ggplot2::vars(.data$var), scales = "free" ) + ggplot2::geom_col(ggplot2::aes(fill = !!filling), position = "dodge") + ggplot2::ggtitle(title) @@ -937,8 +366,7 @@ plot.statistics <- function( ggplot2::ggplot(ggplot2::aes(y = .data$value, x = !!xvariable)) + ggplot2::facet_grid( rows = ggplot2::vars(!!filling), - cols = ggplot2::vars(.data$variable), - scales = "free" + cols = ggplot2::vars(.data$var), scales = "free" ) + ggplot2::geom_col( ggplot2::aes(fill = .data$statistic), @@ -962,22 +390,16 @@ plot.statistics <- function( } # No need to label x-axis if only one value - if ( - (xvar == "situation" && is_all_situations) || - (xvar == "group" && is_one_group) - ) { - x <- x + - ggplot2::xlab("") + + if ((xvar == "situation" && is_all_situations) || + (xvar == "group" && is_one_group)) { + x <- x + ggplot2::xlab("") + ggplot2::theme(axis.text.x = ggplot2::element_blank()) + ggplot2::theme(axis.ticks.x = ggplot2::element_blank()) } # No need to label rows if only one - if ( - group_bar != "rows" && - ((xvar == "group" && is_all_situations) || - (xvar == "situation" && is_one_group)) - ) { + if (group_bar != "rows" && ((xvar == "group" && is_all_situations) || + (xvar == "situation" && is_one_group))) { x <- x + ggplot2::theme(strip.text.y = ggplot2::element_blank()) } } else { @@ -989,7 +411,8 @@ plot.statistics <- function( return(NULL) } else { stop( - "No statistical criteria to plot. Use `force = TRUE` to avoid this error." + "No statistical criteria to plot. + Use `force = TRUE` to avoid this error." ) } } @@ -1000,32 +423,25 @@ plot.statistics <- function( x <- x %>% ggplot2::ggplot(ggplot2::aes( - x = .data$variable, - y = .data$value, - group = .data$group, - colour = .data$group, + x = .data$var, y = .data$value, + group = .data$group, colour = .data$group, fill = .data$group )) + ggplot2::geom_point(size = 2) + ggplot2::geom_polygon(linewidth = 1, alpha = 0.2) + ggplot2::xlab("") + ggplot2::ylab(paste0(crit_radar)) + - ggplot2::ggtitle( - if (is.null(title)) { - paste0(crit_radar) - } else { - title - } - ) + + ggplot2::ggtitle(if (is.null(title)) { + paste0(crit_radar) + } else { + title + }) + ggplot2::scale_x_discrete() + ggplot2::ggproto( "CoordRadar", ggplot2::CoordPolar, - theta = "x", - r = "y", - start = -pi / 6, - direction = sign(1), - is_linear = function(coord) TRUE + theta = "x", r = "y", start = -pi / 6, + direction = sign(1), is_linear = function(coord) TRUE ) } diff --git a/R/generic_stats.R b/R/generic_stats.R index 8160b30e..a1154bff 100644 --- a/R/generic_stats.R +++ b/R/generic_stats.R @@ -16,10 +16,6 @@ #' @param all_plants Boolean (default = TRUE). If `TRUE`, computes statistics #' for all plants (when applicable). #' @param verbose Boolean. Print information during execution. -#' @param formater The function used to format the models outputs and -#' observations in a standard way. You can design your own function -#' that format one situation and provide it here (see [statistics()] and -#' [format_cropr()] for more information). #' #' @seealso All the functions used to compute the statistics: #' [predictor_assessment()]. @@ -34,8 +30,7 @@ statistics_situations <- function( stat = "all", all_situations = TRUE, all_plants = TRUE, - verbose = TRUE, - formater + verbose = TRUE ) { . <- NULL dot_args <- list(...) @@ -72,7 +67,6 @@ statistics_situations <- function( all_situations = all_situations, all_plants = all_plants, verbose = verbose, - formater = formater, stat = stat ) } @@ -97,7 +91,7 @@ statistics_situations <- function( #' Generic simulated/observed statistics for one situation #' #' @description Compute statistics for evaluation of any model outputs against -#' observations, providing a formater function (see [format_cropr()]). +#' observations. #' #' @param sim A simulation data.frame #' @param obs An observation data.frame (variable names must match) @@ -108,9 +102,6 @@ statistics_situations <- function( #' @param all_plants Boolean (default = TRUE). If `TRUE`, computes statistics #' for all plants (when applicable). #' @param verbose Boolean. Print informations during execution. -#' @param formater The function used to format the models outputs and -#' observations in a standard way. You can design your own function -#' that format one situation and provide it here. #' @param stat A character vector of required statistics, "all" for all, or any #' of [predictor_assessment()] (e.g. `"n"` or `"RMSE"`, or both `c("n", "RMSE")`). #' @@ -120,12 +111,13 @@ statistics_situations <- function( #' not the overall simulation mean. #' #' @return A data.frame with statistics for each variable and possibly each -#' grouping variable returned by the formater. +#' grouping variable. #' #' @importFrom reshape2 melt #' @importFrom parallel parLapply stopCluster #' @importFrom dplyr ungroup group_by summarise "%>%" filter #' @importFrom plyr join_all +#' @importFrom rlang ":=" #' @examples #' \dontrun{ #' workspace <- system.file(file.path("extdata", "stics_example_1"), @@ -140,7 +132,6 @@ statistics_situations <- function( #' statistics( #' sim = sim$`IC_Wheat_Pea_2005-2006_N0`, #' obs = obs$`IC_Wheat_Pea_2005-2006_N0`, -#' formater = format_cropr #' ) #' } #' @@ -152,7 +143,6 @@ statistics <- function( all_situations = FALSE, all_plants = TRUE, verbose = TRUE, - formater, stat = "all" ) { . <- NULL # To avoid CRAN check note @@ -167,7 +157,7 @@ statistics <- function( } # Testing if the obs and sim have the same plants names: - if (is_obs && !is.null(obs$Plant) && !is.null(sim$Plant)) { + if (is_obs && "Plant" %in% colnames(obs) && "Plant" %in% colnames(sim)) { common_crops <- unique(sim$Plant) %in% unique(obs$Plant) if (any(!common_crops)) { @@ -182,12 +172,7 @@ statistics <- function( } # Format the data: - formated_df <- formater( - sim, - obs, - type = "scatter", - all_situations = all_situations - ) + formated_df <- format_cropr(sim, obs, type = "scatter") # In case obs is given but no common variables between obs and sim: if (is.null(formated_df) || is.null(formated_df$Observed)) { @@ -284,7 +269,7 @@ statistics <- function( dplyr::summarise(!!cur_stat := do.call(cur_stat, !!arglist_quoted)) }) x <- plyr::join_all(x, by = "variable") - attr(x, "description") <- dplyr::select(all_stats, stat) + attr(x, "description") <- dplyr::select(all_stats, all_of(stat)) return(x) } @@ -325,99 +310,85 @@ statistics <- function( #' \item `Slope()`: Slope of regression line, computed using [stats::lm()] #' on sim~obs. #' \item `RMSE()`: Root Mean Squared Error, computed as -#' \deqn{RMSE = \sqrt{\frac{\sum_1^n(\hat{y_i}-y_i)^2}{n}}} -#' {RMSE = sqrt(mean((sim-obs)^2)} +#' \deqn{RMSE = \sqrt{\frac{\sum_1^n(\hat{y_i}-y_i)^2}{n}}}{RMSE = sqrt(mean((sim-obs)^2)} #' \item `RMSEs()`: Systematic Root Mean Squared Error, computed as -#' \deqn{RMSEs = \sqrt{\frac{\sum_1^n(\sim{y_i}-y_i)^2}{n}}} -#' {RMSEs = sqrt(mean((fitted.values(lm(formula=sim~obs))-obs)^2)} +#' \deqn{RMSEs = \sqrt{\frac{\sum_1^n(\sim{y_i}-y_i)^2}{n}}}{RMSEs = sqrt(mean((fitted.values(lm(formula=sim~obs))-obs)^2)} #' \item `RMSEu()`: Unsystematic Root Mean Squared Error, computed as -#' \deqn{RMSEu = \sqrt{\frac{\sum_1^n(\sim{y_i}-\hat{y_i})^2}{n}}} -#' {RMSEu = sqrt(mean((fitted.values(lm(formula=sim~obs))-sim)^2)} +#' \deqn{RMSEu = \sqrt{\frac{\sum_1^n(\sim{y_i}-\hat{y_i})^2}{n}}}{RMSEu = sqrt(mean((fitted.values(lm(formula=sim~obs))-sim)^2)} #' \item `NSE()`: Nash-Sutcliffe Efficiency, alias of EF, provided for user #' convenience. #' \item `nRMSE()`: Normalized Root Mean Squared Error, also denoted as #' CV(RMSE), and computed as: -#' \deqn{nRMSE = \frac{RMSE}{\bar{y}}\cdot100} -#' {nRMSE = (RMSE/mean(obs))*100} +#' \deqn{nRMSE = \frac{RMSE}{\bar{y}}\cdot100}{nRMSE = (RMSE/mean(obs))*100} #' \item `rRMSE()`: Relative Root Mean Squared Error, computed as: -#' \deqn{rRMSE = \frac{RMSE}{\bar{y}}}{rRMSE = (RMSE/mean(obs))} +#' \deqn{rRMSE = \frac{RMSE}{\bar{y}}}{rRMSE = (RMSE/mean(obs))} #' \item `rRMSEs()`: Relative Systematic Root Mean Squared Error, computed as -#' \deqn{rRMSEs = \frac{RMSEs}{\bar{y}}}{rRMSEs = (RMSEs/mean(obs))} +#' \deqn{rRMSEs = \frac{RMSEs}{\bar{y}}}{rRMSEs = (RMSEs/mean(obs))} #' \item `rRMSEu()`: Relative Unsystematic Root Mean Squared Error, -#' computed as -#' \deqn{rRMSEu = \frac{RMSEu}{\bar{y}}}{rRMSEu = (RMSEu/mean(obs))} +#' computed as: +#' \deqn{rRMSEu = \frac{RMSEu}{\bar{y}}}{rRMSEu = (RMSEu/mean(obs))} #' \item `pMSEs()`: Proportion of Systematic Mean Squared Error in Mean #' Square Error, computed as: -#' \deqn{pMSEs = \frac{MSEs}{MSE}}{pMSEs = MSEs/MSE} +#' \deqn{pMSEs = \frac{MSEs}{MSE}}{pMSEs = MSEs/MSE} #' \item `pMSEu()`: Proportion of Unsystematic Mean Squared Error in MEan #' Square Error, computed as: -#' \deqn{pMSEu = \frac{MSEu}{MSE}}{pMSEu = MSEu^2/MSE^2} +#' \deqn{pMSEu = \frac{MSEu}{MSE}}{pMSEu = MSEu^2/MSE^2} #' \item `Bias2()`: Bias squared (1st term of Kobayashi and Salam #' (2000) MSE decomposition): -#' \deqn{Bias2 = Bias^2} +#' \deqn{Bias2 = Bias^2} #' \item `SDSD()`: Difference between sd_obs and sd_sim squared #' (2nd term of Kobayashi and Salam (2000) MSE decomposition), computed as: -#' \deqn{SDSD = (sd\_obs-sd\_sim)^2}{SDSD = (sd\_obs-sd\_sim)^2} +#' \deqn{SDSD = (sd\_obs-sd\_sim)^2}{SDSD = (sd\_obs-sd\_sim)^2} #' \item `LCS()`: Correlation between observed and simulated values #' (3rd term of Kobayashi and Salam (2000) MSE decomposition), computed as: -#' \deqn{LCS = 2*sd\_obs*sd\_sim*(1-r)} +#' \deqn{LCS = 2*sd\_obs*sd\_sim*(1-r)} #' \item `rbias2()`: Relative bias squared, computed as: -#' \deqn{rbias2 = \frac{Bias^2}{\bar{y}^2}} -#' {rbias2 = Bias^2/mean(obs)^2} +#' \deqn{rbias2 = \frac{Bias^2}{\bar{y}^2}}{rbias2 = Bias^2/mean(obs)^2} #' \item `rSDSD()`: Relative difference between sd_obs and sd_sim squared, #' computed as: -#' \deqn{rSDSD = \frac{SDSD}{\bar{y}^2}}{rSDSD = (SDSD/mean(obs)^2)} +#' \deqn{rSDSD = \frac{SDSD}{\bar{y}^2}}{rSDSD = (SDSD/mean(obs)^2)} #' \item `rLCS()`: Relative correlation between observed and simulated values, #' computed as: -#' \deqn{rLCS = \frac{LCS}{\bar{y}^2}}{rLCS = (LCS/mean(obs)^2)} +#' \deqn{rLCS = \frac{LCS}{\bar{y}^2}}{rLCS = (LCS/mean(obs)^2)} #' \item `MAE()`: Mean Absolute Error, computed as: -#' \deqn{MAE = \frac{\sum_1^n(\left|\hat{y_i}-y_i\right|)}{n}} -#' {MAE = mean(abs(sim-obs))} +#' \deqn{MAE = \frac{\sum_1^n(\left|\hat{y_i}-y_i\right|)}{n}}{MAE = mean(abs(sim-obs))} #' \item `ABS()`: Mean Absolute Bias, which is an alias of `MAE()` #' \item `FVU()`: Fraction of variance unexplained, computed as: -#' \deqn{FVU = \frac{SS_{res}}{SS_{tot}}}{FVU = SS_res/SS_tot} +#' \deqn{FVU = \frac{SS_{res}}{SS_{tot}}}{FVU = SS_res/SS_tot} #' \item `MSE()`: Mean squared Error, computed as: -#' \deqn{MSE = \frac{1}{n}\sum_{i=1}^n(Y_i-\hat{Y_i})^2} -#' {MSE = mean((sim-obs)^2)} +#' \deqn{MSE = \frac{1}{n}\sum_{i=1}^n(Y_i-\hat{Y_i})^2}{MSE = mean((sim-obs)^2)} #' \item `EF()`: Model efficiency, also called Nash-Sutcliffe efficiency #' (NSE). This statistic is related to the FVU as #' \eqn{EF= 1-FVU}. It is also related to the \eqn{R^2}{R2} #' because they share the same equation, except SStot is applied #' relative to the identity function (*i.e.* 1:1 line) instead of the -#' regression line. It is computed -#' as: \deqn{EF = 1-\frac{SS_{res}}{SS_{tot}}}{EF = 1-SS_res/SS_tot} +#' regression line. It is computed as: +#' \deqn{EF = 1-\frac{SS_{res}}{SS_{tot}}}{EF = 1-SS_res/SS_tot} #' \item `Bias()`: Modelling bias, simply computed as: -#' \deqn{Bias = \frac{\sum_1^n(\hat{y_i}-y_i)}{n}} -#' {Bias = mean(sim-obs)} +#' \deqn{Bias = \frac{\sum_1^n(\hat{y_i}-y_i)}{n}}{Bias = mean(sim-obs)} #' \item `MAPE()`: Mean Absolute Percent Error, computed as: -#' \deqn{MAPE = \frac{\sum_1^n(\frac{\left|\hat{y_i}-y_i\right|} -#' {y_i})}{n}}{MAPE = mean(abs(obs-sim)/obs)} +#' \deqn{MAPE = \frac{\sum_1^n(\frac{\left|\hat{y_i}-y_i\right|}{y_i})}{n}}{MAPE = mean(abs(obs-sim)/obs)} #' \item `RME()`: Relative mean error, computed as: -#' \deqn{RME = \frac{\sum_1^n(\frac{\hat{y_i}-y_i}{y_i})}{n}} -#' {RME = mean((sim-obs)/obs)} +#' \deqn{RME = \frac{\sum_1^n(\frac{\hat{y_i}-y_i}{y_i})}{n}}{RME = mean((sim-obs)/obs)} #' \item `tSTUD()`: T student test of the mean difference, computed as: -#' \deqn{tSTUD = \frac{Bias}{\sqrt(\frac{var(M)}{n_obs})}} -#' {tSTUD = Bias/sqrt(var(M)/n_obs)} +#' \deqn{tSTUD = \frac{Bias}{\sqrt(\frac{var(M)}{n_obs})}}{tSTUD = Bias/sqrt(var(M)/n_obs)} #' \item `tLimit()`: T student threshold, computed using [qt()]: -#' \deqn{tLimit = qt(1-\frac{\alpha}{2},df=length(obs)-1)} -#' {tLimit = qt(1-risk/2,df =length(obs)-1)} +#' \deqn{tLimit = qt(1-\frac{\alpha}{2},df=length(obs)-1)}{tLimit = qt(1-risk/2,df =length(obs)-1)} #' \item `Decision()`: Decision of the t student test of the mean difference #' (can bias be considered statistically not different from 0 at alpha level #' 0.05, i.e. 5% probability of erroneously rejecting this hypothesis?), #' computed as: -#' \deqn{Decision = abs(tSTUD ) < tLimit} +#' \deqn{Decision = abs(tSTUD ) < tLimit} #' } #' #' @note \eqn{SS_{res}}{SS_res} is the residual sum of squares and -#' \eqn{SS_{tot}}{SS_tot} the total sum of squares. They are computed as: -#' \deqn{SS_{res} = \sum_{i=1}^n (y_i - \hat{y_i})^2} -#' {SS_res= sum((obs-sim)^2)} -#' \deqn{SS_{tot} = \sum_{i=1}^{n}\left(y_{i}-\bar{y}\right)^2} -#' {SS_tot= sum((obs-mean(obs))^2} -#' Also, it should be noted that \eqn{y_i} refers to the observed values -#' and \eqn{\hat{y_i}} to the predicted values, \eqn{\bar{y}} to the mean -#' value of observations and \eqn{\sim{y_i}} to -#' values predicted by linear regression. +#' \eqn{SS_{tot}}{SS_tot} the total sum of squares. They are computed as: +#' \deqn{SS_{res} = \sum_{i=1}^n (y_i - \hat{y_i})^2}{SS_res= sum((obs-sim)^2)} +#' \deqn{SS_{tot} = \sum_{i=1}^{n}\left(y_{i}-\bar{y}\right)^2}{SS_tot= sum((obs-mean(obs))^2} +#' Also, it should be noted that \eqn{y_i} refers to the observed values +#' and \eqn{\hat{y_i}} to the predicted values, \eqn{\bar{y}} to the mean +#' value of observations and \eqn{\sim{y_i}} to +#' values predicted by linear regression. #' #' @return A statistic depending on the function used. #' diff --git a/R/parse_plot_situations_arguments.R b/R/parse_plot_situations_arguments.R new file mode 100644 index 00000000..e3c66e5b --- /dev/null +++ b/R/parse_plot_situations_arguments.R @@ -0,0 +1,209 @@ +#' Parse plot situations arguments +#' +#' This function parses the arguments for `plot_situations`. +#' +#' @inheritParams plot_situations +#' +#' @return A list of parsed arguments, eventually corrected according to the +#' compatibility between options. +#' +#' @keywords internal +parse_plot_situations_args <- function( + dot_args, obs = NULL, obs_sd = NULL, + type = c("dynamic", "scatter"), + select_dyn = c("sim", "common", "obs", "all"), + select_scat = c("sim", "res"), var = NULL, + title = NULL, all_situations = TRUE, + overlap = NULL, successive = NULL, + shape_sit = c("none", "txt", "symbol", "group"), + situation_group = NULL, reference_var = NULL, + force = FALSE, verbose = TRUE +) { + type <- match.arg(type, c("dynamic", "scatter"), several.ok = FALSE) + select_dyn <- match.arg(select_dyn, c("sim", "common", "obs", "all"), + several.ok = FALSE + ) + + # Now that we have one data.frame only, we can test if we have + # observations / obs_sd: + is_obs <- !is.null(obs) && all(sapply(obs, function(x) nrow(x) > 0)) + is_obs_sd <- !is.null(obs_sd) && all(sapply(obs, function(x) nrow(x) > 0)) + + # Early error on observations (no observations given at all but we need them): + # NB: `generic_formatting` will check if there are common observations + # and simulations + if (!is_obs && (type == "scatter" || select_dyn %in% c("common", "obs"))) { + if (verbose) { + cli::cli_alert_warning( + c( + "Observations are required but not provided, ", + "did you provide `obs = ...`?" + ) + ) + } + if (force) { + return(NULL) + } else { + stop( + "Observations are required but not provided, ", + "did you provide `obs = ...`?" + ) + } + } + + select_scat <- match.arg(select_scat, c("sim", "res"), several.ok = FALSE) + shape_sit <- match.arg(shape_sit, c("none", "txt", "symbol", "group"), + several.ok = FALSE + ) + + if (select_scat == "res" || shape_sit != "none") { + type <- "scatter" + } + + # Disable all_situations when type=="dynamic" temporarily + if (type == "dynamic") { + all_situations <- FALSE + } + + # Enable successive and overlap only when type=="dynamic" + if (!is.null(successive) || !is.null(overlap)) { + type <- "dynamic" + } + + # Text on scatter plots only if all_situations + if (shape_sit != "none") { + all_situations <- TRUE + } + + # Enable reference variable edit only when plotting residual scatter plot + if (!is.null(reference_var)) { + type <- "scatter" + } + + if (!is.null(situation_group)) { + shape_sit <- "group" + } + + if (shape_sit == "group" && is.null(situation_group)) { + if (verbose) { + cli::cli_alert_warning("Argument `situation_group` must be defined + when `shape_sit` is 'group'") + } + if (force) { + return(NULL) + } else { + stop( + "Argument `situation_group` not defined.", + " Use `force = TRUE` to avoid this error." + ) + } + } + + # has_distinct_situations expresses whether, in the plot being built, + # situations are visually distinguished (e.g. by color/shape). + # It is independent from the input 'all_situations' (which controls whether + # we draw one plot per situation or merge in a single plot). + # Examples: + # - Multiple situations but all blended with the same aesthetics -> FALSE + # - Multiple situations with distinct aesthetics (symbol/group) -> TRUE + # - Only one situation -> FALSE + has_distinct_situations <- (all_situations || !is.null(successive)) && + shape_sit %in% c("symbol", "group") + + # Name the models: + v_names <- names(dot_args) + if (is.null(v_names) || length(v_names) < length(dot_args)) { + v_names <- paste0("Version_", seq_along(dot_args)) + names(dot_args) <- v_names + } + + # Don't show group in legend if only one: + if (length(v_names) == 1) { + one_version <- TRUE + } else { + one_version <- FALSE + } + + # If there are successive situations: + if (!is.null(successive)) { + # Cat situations that need to be represented as a + # contiguous sequence(dynamic) + list_rot <- cat_successive(dot_args, obs, successive) + dot_args <- list_rot[[1]] + obs <- list_rot[[2]] + } + + if (all_situations) { + common_situations_models <- "all_situations" + } else { + # Intersect situations between versions + common_situations_models <- names(dot_args[[1]]) + + if (length(dot_args) > 1) { + for (index in 2:length(dot_args)) { + common_situations_models <- intersect( + common_situations_models, + names(dot_args[[index]]) + ) + } + } + } + + if (length(title) == 1) { + if (!all_situations) { + title <- rep(title, length(common_situations_models)) + names(title) <- common_situations_models + } else { + title <- NULL + } + } + + if ( + !is.null(title) && + length(title) != length(common_situations_models) && + is.null(names(title)) + ) { + if (verbose) { + cli::cli_alert_danger("Situations number is different from model(s) + outputs, please name the {.code title} argument + with the situations names.") + } + # Situations number is different from models outputs, can't guess + # which title is for which situation. + stop("title argument is not a named list") + } + + if (!is.null(title) && is.null(names(title))) { + # title is provided by the user, is not named, but has same length than + # common_situations_models, so we guess it: + names(title) <- common_situations_models + } + + return( + list( + dot_args = dot_args, + obs = obs, + obs_sd = obs_sd, + type = type, + select_dyn = select_dyn, + select_scat = select_scat, + var = var, + title = title, + all_situations = all_situations, + overlap = overlap, + successive = successive, + shape_sit = shape_sit, + situation_group = situation_group, + reference_var = reference_var, + force = force, + verbose = verbose, + dot_args = dot_args, + v_names = v_names, + one_version = one_version, + has_distinct_situations = has_distinct_situations, + common_situations_models = common_situations_models, + is_obs = is_obs, + is_obs_sd = is_obs_sd + ) + ) +} diff --git a/R/save_plot_pdf.R b/R/save_plot_pdf.R index 612b562f..87d33bbb 100644 --- a/R/save_plot_pdf.R +++ b/R/save_plot_pdf.R @@ -86,13 +86,13 @@ save_plot_pdf <- function(plot, out_dir, file_name = "Graphs", title = "Plots", vars <- NULL for (d in plot) { - vars <- c(vars, as.character(d$data$variable)) + vars <- c(vars, as.character(d$data$var)) } vars <- unique(vars) if (file_per_var) { for (v in vars) { - if (v != "Sit_Name") { + if (v != "sit_name") { pdf(file.path(path, paste0(filename, "-", v, ".pdf")), paper = "a4", width = 7, @@ -113,7 +113,7 @@ save_plot_pdf <- function(plot, out_dir, file_name = "Graphs", title = "Plots", ind <- which(rmse == i) for (j in ind) { sit <- names(plot)[j] - if (v %in% unique(plot[[sit]]$data$variable)) { + if (v %in% unique(plot[[sit]]$data$var)) { gg <- ex[sit] gg[[1]]$labels$title <- paste0(sit, " | RMSE : ", round(i, 3)) plt <- c(plt, gg) @@ -154,10 +154,17 @@ save_plot_pdf <- function(plot, out_dir, file_name = "Graphs", title = "Plots", ) plt <- c() for (i in seq_along(plot)) { - for (va in vars) { - if (va %in% plot[[i]]$data$variable) { - plt <- c(plt, extract_plot(plot[i], var = va)) + out <- ggplot2::ggplot_build(plot[[i]]) + if (length(unique(out$data[[1]]$PANEL)) > 1) { + # only for facetted plots + # (plots with overlapped variables should not be extracted per variable ...) + for (va in vars) { + if (va %in% plot[[i]]$data$var) { + plt <- c(plt, extract_plot(plot[i], var = va)) + } } + } else { + plt <- c(plt, plot[i]) } } p <- 1 diff --git a/R/specific_plotting_dynamic.R b/R/specific_plotting_dynamic.R new file mode 100644 index 00000000..2e1413d9 --- /dev/null +++ b/R/specific_plotting_dynamic.R @@ -0,0 +1,322 @@ +#' Specific functions to generate dynamic plots +#' +#' @description Generate dynamic plots for the different +#' cases handled in CroPlotR +#' (plant mixture, plot several simulation results on same graph, ...) +#' as specified by the different arguments. +#' +#' @param df_data A named list of data frame including the data to plot (one df +#' per situation) +#' @param sit The name of the situation to plot +#' @param successive A list of lists containing the situations to be represented +#' as a contiguous sequence +#' @param title The plot title (optional, NULL by default) +#' +#' @importFrom rlang .data +#' @return A ggplot object +#' +#' @details List of the different specific functions: +#' \itemize{ +#' \item `plot_dynamic_mixture`: Generate a dynamic plot for the case of +#' mixture of crops, single simulation version and each variable +#' in different plot +#' \item `plot_dynamic_mixture_overlap`: Generate a dynamic plot for the +#' case of mixture of crops, single simulation version and several variables +#' in same plot (overlap) +#' \item `plot_dynamic_versions`: Generate a dynamic plot for the +#' case of sole crops, all simulation versions in same plot and each +#' variable in a plot +#' \item `plot_dynamic_overlap`: Generate a dynamic plot for the +#' case of sole crops, single simulation version and several variables +#' in same plot (overlap) +#' \item `plot_dynamic_mixture_versions_overlap`: not implemented (seems not +#' useful because too complex to analyze) +#' \item `plot_dynamic_versions_overlap`: Generate a dynamic plot for the +#' case of sole crops, all simulation versions and several variables +#' in same plot (overlap) +#' \item `plot_dynamic_mixture_versions`: Generate a dynamic plot for the +#' case of mixture of crops, all simulation versions in same plot and +#' each variable in a plot +#' } +#' +#' @return A list of ggplot objects +#' +#' @name specific_dynamic_plots +#' +NULL + + +#' @keywords internal +#' @rdname specific_dynamic_plots +plot_dynamic <- function(df_data, sit, successive, title = NULL) { + p <- ggplot2::ggplot( + df_data, + ggplot2::aes(x = .data$Date) + ) + + ggplot2::geom_line(ggplot2::aes(y = .data$Simulated)) + + ggplot2::facet_wrap(~ .data$var, scales = "free_y") + + if (!is.null(successive)) { + dates <- unique(df_data$succession_date) + dates_vlines <- as.POSIXct(dates, tz = "UTC") + + p <- p + ggplot2::geom_vline( + xintercept = dates_vlines[-length(dates_vlines)], + linetype = "dashed", + color = "black" + ) + } + + if ("Observed" %in% colnames(df_data)) { + p <- p + ggplot2::geom_point(ggplot2::aes(y = .data$Observed), na.rm = TRUE) + + if ("Obs_SD" %in% colnames(df_data)) { + p <- p + + ggplot2::geom_errorbar( + ggplot2::aes( + ymin = .data$Observed - 2 * .data$Obs_SD, + ymax = .data$Observed + 2 * .data$Obs_SD + ), + na.rm = TRUE + ) + } + } + p <- p + + ggplot2::ggtitle(title) + return(p) +} + +plot_dynamic_mixture <- function(df_data, sit, title = NULL) { + p <- ggplot2::ggplot( + df_data, + ggplot2::aes( + x = .data$Date, + colour = paste(.data$Dominance, ":", .data$Plant) + ) + ) + + ggplot2::geom_line(ggplot2::aes(y = .data$Simulated)) + + ggplot2::facet_wrap(~ .data$var, scales = "free_y") + + + if ("Observed" %in% colnames(df_data)) { + p <- p + ggplot2::geom_point(ggplot2::aes(y = .data$Observed), na.rm = TRUE) + + if ("Obs_SD" %in% colnames(df_data)) { + p <- p + + ggplot2::geom_errorbar( + ggplot2::aes( + ymin = .data$Observed - 2 * .data$Obs_SD, + ymax = .data$Observed + 2 * .data$Obs_SD + ), + na.rm = TRUE + ) + } + } + + p <- p + + ggplot2::ggtitle(title) + + ggplot2::labs(colour = "Plant") + return(p) +} + +plot_dynamic_mixture_overlap <- function(df_data, sit, title = NULL) { + p <- ggplot2::ggplot( + df_data, + ggplot2::aes( + x = .data$Date, + colour = .data$var, + linetype = paste(.data$Dominance, ": ", .data$Plant), + shape = paste(.data$Dominance, ": ", .data$Plant) + ) + ) + + ggplot2::geom_line(ggplot2::aes(y = .data$Simulated)) + + ggplot2::facet_wrap(~ .data$group_var, scales = "free") + + if ("Observed" %in% colnames(df_data)) { + p <- p + ggplot2::geom_point( + ggplot2::aes( + y = .data$Observed, + shape = paste( + .data$Dominance, + ": ", .data$Plant + ), + color = .data$var, + ), + na.rm = TRUE + ) + if ("Obs_SD" %in% colnames(df_data)) { + p <- p + + ggplot2::geom_errorbar( + ggplot2::aes( + ymin = .data$Observed - 2 * .data$Obs_SD, + ymax = .data$Observed + 2 * .data$Obs_SD + ), + na.rm = TRUE + ) + } + } + + p <- p + + ggplot2::ggtitle(title) + + ggplot2::guides( + colour = ggplot2::guide_legend(title = "Variable"), + # add override.aes = list(shape = NA) in prev guide_legend? + linetype = ggplot2::guide_legend(title = "Plant", order = 1), + shape = ggplot2::guide_legend(title = "Plant", order = 1) + ) + return(p) +} + +plot_dynamic_versions <- function(df_data, sit, title = NULL) { + df_data$Observed_Legend <- "Observed Value" + p <- ggplot2::ggplot( + df_data, + ggplot2::aes(x = .data$Date, colour = .data$version) + ) + + ggplot2::geom_line(ggplot2::aes(y = .data$Simulated)) + + ggplot2::facet_wrap(~ .data$var, scales = "free") + + if ("Observed" %in% colnames(df_data)) { + p <- p + ggplot2::geom_point( + ggplot2::aes(y = .data$Observed, shape = .data$Observed_Legend), + # NB: the shape is constant, but used to have a legend entry + color = "black", + na.rm = TRUE + ) + if ("Obs_SD" %in% colnames(df_data)) { + p <- p + + ggplot2::geom_errorbar( + ggplot2::aes( + ymin = .data$Observed - 2 * .data$Obs_SD, + ymax = .data$Observed + 2 * .data$Obs_SD, + shape = .data$version + ), + na.rm = TRUE + ) + } + } + + p <- p + + ggplot2::ggtitle(title) + + ggplot2::guides( + colour = ggplot2::guide_legend( + title = "Version", + override.aes = list(shape = NA) + ), + shape = ggplot2::guide_legend(title = "Observations") + ) + return(p) +} + +plot_dynamic_overlap <- function(df_data, sit, title = NULL) { + p <- ggplot2::ggplot( + df_data, + ggplot2::aes(x = .data$Date, colour = .data$var) + ) + + ggplot2::geom_line(ggplot2::aes(y = .data$Simulated)) + + ggplot2::facet_wrap(~ .data$group_var, scales = "free") + + ggplot2::labs(shape = "Variable", colour = "Variable") + + if ("Observed" %in% colnames(df_data)) { + p <- p + ggplot2::geom_point( + ggplot2::aes(y = .data$Observed, shape = .data$var), + na.rm = TRUE + ) + if ("Obs_SD" %in% colnames(df_data)) { + p <- p + + ggplot2::geom_errorbar( + ggplot2::aes( + ymin = .data$Observed - 2 * .data$Obs_SD, + ymax = .data$Observed + 2 * .data$Obs_SD, + shape = .data$version + ), + na.rm = TRUE + ) + } + } + p <- p + + ggplot2::ggtitle(title) + return(p) +} + +plot_dynamic_mixture_versions_overlap <- function(df_data, sit, title = NULL) { + stop( + "Too many cases to consider at a time: mixture + versions + overlap. ", + "Please use only a maximum of two combinations of: ", + "mixture, versions, overlap." + ) +} + + +plot_dynamic_versions_overlap <- function(df_data, sit, title = NULL) { + p <- ggplot2::ggplot( + df_data, + ggplot2::aes( + x = .data$Date, colour = .data$var, + linetype = .data$version + ) + ) + + ggplot2::geom_line(ggplot2::aes(y = .data$Simulated)) + + ggplot2::facet_wrap(~ .data$group_var, scales = "free") + + if ("Observed" %in% colnames(df_data)) { + p <- p + ggplot2::geom_point( + ggplot2::aes(y = .data$Observed, colour = .data$var), + na.rm = TRUE + ) + if ("Obs_SD" %in% colnames(df_data)) { + p <- p + + ggplot2::geom_errorbar( + ggplot2::aes( + ymin = .data$Observed - 2 * .data$Obs_SD, + ymax = .data$Observed + 2 * .data$Obs_SD, + colour = .data$var + ), + na.rm = TRUE + ) + } + } + + p <- p + + ggplot2::ggtitle(title) + + ggplot2::labs(colour = "Variable", linetype = "Version") + + return(p) +} + +plot_dynamic_mixture_versions <- function(df_data, sit, title = NULL) { + p <- ggplot2::ggplot( + df_data, + ggplot2::aes( + x = .data$Date, + colour = paste(.data$Dominance, ":", .data$Plant), + linetype = .data$version + ) + ) + + ggplot2::geom_line(ggplot2::aes(y = .data$Simulated)) + + ggplot2::facet_wrap(~ .data$var, scales = "free") + + if ("Observed" %in% colnames(df_data)) { + p <- p + ggplot2::geom_point( + ggplot2::aes(y = .data$Observed), + na.rm = TRUE + ) + if ("Obs_SD" %in% colnames(df_data)) { + p <- p + + ggplot2::geom_errorbar( + ggplot2::aes( + ymin = .data$Observed - 2 * .data$Obs_SD, + ymax = .data$Observed + 2 * .data$Obs_SD + ), + na.rm = TRUE + ) + } + } + p <- p + + ggplot2::ggtitle(title) + + ggplot2::labs( + colour = "Plant", + linetype = "Version" + ) + return(p) +} diff --git a/R/specific_plotting_scatter.R b/R/specific_plotting_scatter.R new file mode 100644 index 00000000..0bef8bd5 --- /dev/null +++ b/R/specific_plotting_scatter.R @@ -0,0 +1,671 @@ +#' Specific functions to generate scatter plots +#' +#' @description Generate scatter plots for the different cases handled in +#' CroPlotR (plant mixture, plot of residuals, plot several simulation results +#' on same graph, ...) as specified by the different arguments. +#' +#' @param df_data A named list of data frame including the data to plot (one df +#' per situation, or only one df if sit==all_situations) +#' @param sit The name of the situation to plot (or all_situations) +#' @param is_obs_sd TRUE if error standard deviation of observations is provided +#' @param mixture TRUE if the plot is for a mixture of crops +#' @param one_version TRUE if the plot is for one version +#' @param has_distinct_situations TRUE if the plot is for several situations +#' +#' @importFrom rlang .data +#' @return A ggplot object +#' +#' @details List of the different specific functions: +#' \itemize{ +#' \item `plot_scat_mixture_allsit`: Generate a scatter plot for the case of +#' mixture of crops, single simulation version and all_situations in same plot +#' \item `plot_scat_allsit`: Generate a scatter plot for the case of +#' sole crops, single simulation version and all_situations in same plot +#' } +#' +#' @return A list of ggplot objects +#' +#' @name specific_scatter_plots +#' +NULL + + +#' @keywords internal +#' @description Compute axis bounds (+/-0.05 added to the min/max of the data). +#' @rdname specific_scatter_plots +#' @param y_var_type type of variable to plot ("Simulated" or "Residuals") +#' @return List of x and y axis bounds (xaxis_min, xaxis_max, yaxis_min, +#' yaxis_max) +compute_axis_bounds <- function(df_data, reference_var, y_var_type, is_obs_sd) { + # Compute x and y axis min and max to set axis limits + df_min <- df_data %>% + group_by(.data$var) %>% + summarise(across(where(is.numeric), min)) + df_max <- df_data %>% + group_by(.data$var) %>% + summarise(across(where(is.numeric), max)) + xaxis_min <- df_min[[reference_var]] - 0.05 * df_min[[reference_var]] + xaxis_max <- df_max[[reference_var]] + 0.05 * df_max[[reference_var]] + yaxis_min <- df_min[[y_var_type]] - 0.05 * df_min[[y_var_type]] + yaxis_max <- df_max[[y_var_type]] + 0.05 * df_max[[y_var_type]] + + if (is_obs_sd && reference_var == "Observed") { + # Update xaxis min and max in case of addition of error bars + df_min <- df_data %>% + mutate(barmin = .data$Observed - 2 * .data$Obs_SD) %>% + group_by(.data$var) %>% + summarise(across(where(is.numeric), min)) + df_max <- df_data %>% + mutate(barmax = .data$Observed + 2 * .data$Obs_SD) %>% + group_by(.data$var) %>% + summarise(across(where(is.numeric), max)) + xaxis_min <- df_min[["barmin"]] - 0.05 * df_min[["barmin"]] + xaxis_max <- df_max[["barmax"]] + 0.05 * df_max[["barmax"]] + } + + return(list( + xaxis_min = xaxis_min, xaxis_max = xaxis_max, + yaxis_min = yaxis_min, yaxis_max = yaxis_max + )) +} + + +#' @keywords internal +#' @description Make axis square +#' @rdname specific_scatter_plots +#' @param p A ggplot to modify` +#' @param y_var_type type of variable to plot ("Simulated" or "Residuals") +#' @return The modified ggplot +make_axis_square <- function(df_data, reference_var, y_var_type, is_obs_sd, p) { + axis_bounds <- compute_axis_bounds(df_data, reference_var, y_var_type, is_obs_sd) + axis_min <- pmin(axis_bounds$xaxis_min, axis_bounds$yaxis_min) + axis_max <- pmax(axis_bounds$xaxis_max, axis_bounds$yaxis_max) + p <- p + + ggh4x::facetted_pos_scales( + x = lapply(1:length(axis_min), function(i) { + ggplot2::scale_x_continuous(limits = c(axis_min[i], axis_max[i])) + }), + y = lapply(1:length(axis_min), function(i) { + ggplot2::scale_y_continuous(limits = c(axis_min[i], axis_max[i])) + }) + ) + return(p) +} + +#' @keywords internal +#' @description Ensure that the Y axis includes zero when all values in a facet +#' are strictly positive or strictly negative. +#' @rdname specific_scatter_plots +#' @param p A ggplot to modify` +#' @param y_var_type type of variable to plot ("Simulated" or "Residuals") +#' @return The modified ggplot +force_y_axis <- function(df_data, reference_var, y_var_type, is_obs_sd, p) { + axis_bounds <- compute_axis_bounds( + df_data, + reference_var, + y_var_type, + is_obs_sd + ) + y_min <- axis_bounds$yaxis_min + y_max <- axis_bounds$yaxis_max + + expand_range <- function(min, max, mult = 0.05) { + delta <- max - min + if (delta == 0) delta <- abs(min) + 1e-9 + c(min - delta * mult, max + delta * mult) + } + + lims <- Map(function(lo, hi) { + base_min <- min(lo, 0) + base_max <- max(hi, 0) + + expand_range(base_min, base_max, 0.05) + }, y_min, y_max) + + p + + ggh4x::facetted_pos_scales( + y = lapply(lims, function(l) { + ggplot2::scale_y_continuous(limits = l) + }) + ) +} + +#' Get reference variable for plotting +#' +#' @description Return the reference variable and its display name for scatter +#' plots +#' +#' @param reference_var The reference variable name, if NULL "Observed" is used +#' +#' @keywords internal +#' +#' @return A list with two elements: +#' \itemize{ +#' \item reference_var: The reference variable name: "Observed" or "Reference" +#' \item reference_var_name: The display name for the reference variable +#' } +give_reference_var <- function(reference_var) { + if (is.null(reference_var)) { + reference_var <- "Observed" + reference_var_name <- "Observed" + } else { + reference_var_name <- reference_var + reference_var <- "Reference" + } + return( + list( + reference_var = reference_var, reference_var_name = reference_var_name + ) + ) +} + +#' Get y variable type for plotting +#' +#' @description Return the type of y variable for scatter plots based on +#' selection +#' +#' @param select_scat Selection type, either "sim" for Simulated or any other +#' value for Residuals +#' +#' @keywords internal +#' +#' @return A character string, either "Simulated" or "Residuals" +give_y_var_type <- function(select_scat) { + if (select_scat == "sim") { + y_var_type <- "Simulated" + } else { + y_var_type <- "Residuals" + } + return(y_var_type) +} + + +#' @keywords internal +#' @description Add error bars on observed values in given scatterplot +#' @rdname specific_scatter_plots +#' @param p A ggplot to modify` +#' @param colour_factor The factor to use for colouring the error bars +#' @return The modified ggplot +add_obs_error_bars <- function(p, colour_factor = NULL) { + p <- p + + ggplot2::geom_linerange( + ggplot2::aes( + xmin = .data$Observed - 2 * .data$Obs_SD, + xmax = .data$Observed + 2 * .data$Obs_SD, + colour = .data[[colour_factor]], + ), + na.rm = TRUE + ) + return(p) +} + +#' @keywords internal +#' @rdname specific_scatter_plots +plot_scat_mixture_allsit <- function(df_data, sit, select_scat, shape_sit, + reference_var, is_obs_sd, title = NULL) { + tmp <- give_reference_var(reference_var) + reference_var <- tmp$reference_var + reference_var_name <- tmp$reference_var_name + y_var_type <- give_y_var_type(select_scat) + + df_data <- + df_data %>% + dplyr::filter(!is.na(.data[[reference_var]]) & !is.na(.data[[y_var_type]])) + + p <- + ggplot2::ggplot( + df_data, + ggplot2::aes( + y = .data[[y_var_type]], x = .data[[reference_var]], + label = .data$sit_name + ) + ) + + if (shape_sit == "none" || shape_sit == "txt") { + p <- p + ggplot2::geom_point( + ggplot2::aes( + colour = as.factor(paste(.data$Dominance, ":", .data$Plant)) + ), + na.rm = TRUE + ) + } else if (shape_sit == "symbol" || shape_sit == "group") { + p <- p + ggplot2::geom_point( + ggplot2::aes( + colour = as.factor(paste(.data$Dominance, ":", .data$Plant)), + shape = as.factor(paste(.data$sit_name)) + ), + na.rm = TRUE + ) + + ggplot2::scale_shape_discrete(name = "Situation") + } + + p <- p + + ggplot2::geom_abline( + intercept = 0, slope = ifelse(select_scat == "sim", 1, 0), + color = "grey30", linetype = 2 + ) + + ggplot2::geom_smooth( + ggplot2::aes(y = .data[[y_var_type]], x = .data[[reference_var]]), + inherit.aes = FALSE, + method = lm, color = "blue", + se = FALSE, linewidth = 0.6, formula = y ~ x, + fullrange = TRUE, na.rm = TRUE + ) + + ggplot2::xlab(reference_var_name) + + ggplot2::facet_wrap(~ .data$var, scales = "free") + + p <- p + + ggplot2::ggtitle(title) + + if (is_obs_sd && reference_var == "Observed") { + p$data$colour_factor <- as.factor(paste(p$data$Dominance, ":", p$data$Plant)) + p <- add_obs_error_bars(p, colour_factor = "colour_factor") + } + + p <- p + ggplot2::theme(aspect.ratio = 1) + + if (shape_sit == "txt") { + p <- p + + ggrepel::geom_text_repel( + ggplot2::aes( + colour = as.factor(paste(.data$Dominance, ":", .data$Plant)) + ), + show.legend = FALSE, + max.overlaps = 100 + ) + } + + # Set same limits for x and y axis for sim VS obs scatter plots + if (select_scat == "sim" && reference_var == "Observed") { + p <- make_axis_square(df_data, reference_var, y_var_type, is_obs_sd, p) + } + if (select_scat == "res") { + p <- force_y_axis(df_data, reference_var, y_var_type, is_obs_sd, p) + } + + p <- p + ggplot2::scale_color_discrete(name = "Plant") + + return(p) +} + + +#' @keywords internal +#' @rdname specific_scatter_plots +plot_scat_mixture_versions <- function(df_data, sit, select_scat, shape_sit, + reference_var, is_obs_sd, title = NULL) { + tmp <- give_reference_var(reference_var) + reference_var <- tmp$reference_var + reference_var_name <- tmp$reference_var_name + y_var_type <- give_y_var_type(select_scat) + + df_data <- + df_data %>% + dplyr::filter(!is.na(.data[[reference_var]]) & !is.na(.data[[y_var_type]])) + + p <- + ggplot2::ggplot( + df_data, + ggplot2::aes( + y = .data[[y_var_type]], x = .data[[reference_var]], + label = .data$sit_name + ) + ) + + if (shape_sit == "none" || shape_sit == "txt") { + p <- p + ggplot2::geom_point( + ggplot2::aes( + shape = as.factor(paste(.data$Dominance, ":", .data$Plant)), + colour = as.factor(.data$version) + ), + na.rm = TRUE + ) + + ggplot2::labs(color = "Version", shape = "Plant") + } else if (shape_sit == "symbol" || shape_sit == "group") { + # ! In this case we loose the colour by species for mixtures, because + # there would be three aesthetics to handle (situation, version and + # species). We made this decision because the user explicitly asks + # for shape to be the situation name. If they want to color by species, + # they can put shape_sit = "none" or shape_sit = "txt" to have it all. + p <- p + ggplot2::geom_point( + ggplot2::aes( + colour = as.factor(.data$version), + shape = as.factor(.data$sit_name) + ), + na.rm = TRUE + ) + + ggplot2::labs(color = "Version", shape = "Situation") + } + + p <- p + + ggplot2::geom_abline( + intercept = 0, slope = ifelse(select_scat == "sim", 1, 0), + color = "grey30", linetype = 2 + ) + + ggplot2::geom_smooth( + ggplot2::aes( + y = .data[[y_var_type]], x = .data[[reference_var]], + colour = as.factor(.data$version) + ), + inherit.aes = FALSE, + method = lm, + se = FALSE, linewidth = 0.6, formula = y ~ x, + fullrange = TRUE, na.rm = TRUE + ) + + ggplot2::xlab(reference_var_name) + + ggplot2::facet_wrap(~ .data$var, scales = "free") + + p <- p + ggplot2::ggtitle(title) + + if (is_obs_sd && reference_var == "Observed") { + p <- p + + ggplot2::geom_linerange( + ggplot2::aes( + xmin = .data$Observed - 2 * .data$Obs_SD, + xmax = .data$Observed + 2 * .data$Obs_SD, + colour = as.factor(.data$version), + ), + na.rm = TRUE + ) + } + + p <- p + ggplot2::theme(aspect.ratio = 1) + + if (shape_sit == "txt") { + p <- p + + ggrepel::geom_text_repel( + ggplot2::aes( + colour = as.factor(.data$version) + ), + show.legend = FALSE, + max.overlaps = 100 + ) + } + + # Set same limits for x and y axis for sim VS obs scatter plots + if (select_scat == "sim" && reference_var == "Observed") { + p <- make_axis_square(df_data, reference_var, y_var_type, is_obs_sd, p) + } + if (select_scat == "res") { + p <- force_y_axis(df_data, reference_var, y_var_type, is_obs_sd, p) + } + + return(p) +} + + +#' @keywords internal +#' @rdname specific_scatter_plots +plot_scat_allsit <- function(df_data, sit, select_scat, shape_sit, + reference_var, is_obs_sd, title = NULL, + has_distinct_situations = FALSE, + one_version = FALSE, mixture = FALSE) { + tmp <- give_reference_var(reference_var) + reference_var <- tmp$reference_var + reference_var_name <- tmp$reference_var_name + y_var_type <- give_y_var_type(select_scat) + df_data <- + df_data %>% + dplyr::filter(!is.na(.data[[reference_var]]) & !is.na(.data[[y_var_type]])) + p <- + ggplot2::ggplot( + df_data, + ggplot2::aes( + y = .data[[y_var_type]], x = .data[[reference_var]], + label = .data$sit_name + ) + ) + if (shape_sit == "none" || shape_sit == "txt") { + p <- p + ggplot2::geom_point(na.rm = TRUE) + } else if (shape_sit == "symbol" || shape_sit == "group") { + p <- p + ggplot2::geom_point( + ggplot2::aes( + colour = as.factor(paste(.data$sit_name)) + ), + na.rm = TRUE + ) + + ggplot2::scale_color_discrete(name = "Situation") + } + + p <- p + + ggplot2::geom_abline( + intercept = 0, slope = ifelse(select_scat == "sim", 1, 0), + color = "grey30", linetype = 2 + ) + + ggplot2::geom_smooth( + ggplot2::aes(y = .data[[y_var_type]], x = .data[[reference_var]]), + inherit.aes = FALSE, + method = lm, color = "blue", + se = FALSE, linewidth = 0.6, formula = y ~ x, + fullrange = TRUE, na.rm = TRUE + ) + + ggplot2::xlab(reference_var_name) + + ggplot2::facet_wrap(~ .data$var, scales = "free") + + p <- p + + ggplot2::ggtitle(title) + + if (is_obs_sd && reference_var == "Observed") { + line_aes <- NULL + if (shape_sit == "symbol" || shape_sit == "group") { + line_aes <- ggplot2::aes( + xmin = .data$Observed - 2 * .data$Obs_SD, + xmax = .data$Observed + 2 * .data$Obs_SD, + colour = as.factor(paste(.data$sit_name)) + ) + } else { + line_aes <- ggplot2::aes( + xmin = .data$Observed - 2 * .data$Obs_SD, + xmax = .data$Observed + 2 * .data$Obs_SD + ) + } + p <- p + ggplot2::geom_linerange(line_aes, na.rm = TRUE) + } + + p <- p + ggplot2::theme(aspect.ratio = 1) + + if (shape_sit == "txt") { + p <- p + ggrepel::geom_text_repel(max.overlaps = 100) + } + + # Set same limits for x and y axis for sim VS obs scatter plots + if (select_scat == "sim" && reference_var == "Observed") { + p <- make_axis_square(df_data, reference_var, y_var_type, is_obs_sd, p) + } + if (select_scat == "res") { + p <- force_y_axis(df_data, reference_var, y_var_type, is_obs_sd, p) + } + if ( + has_distinct_situations == FALSE && + one_version == TRUE && + mixture == FALSE + ) { + p <- p + ggplot2::theme(legend.position = "none") + } + + return(p) +} + +#' @keywords internal +#' @rdname specific_scatter_plots +plot_scat_versions_per_sit <- function(df_data, + sit, select_scat, shape_sit, + reference_var, is_obs_sd, title = NULL) { + tmp <- give_reference_var(reference_var) + reference_var <- tmp$reference_var + reference_var_name <- tmp$reference_var_name + y_var_type <- give_y_var_type(select_scat) + + df_data <- + df_data %>% + dplyr::filter(!is.na(.data[[reference_var]]) & !is.na(.data[[y_var_type]])) + + p <- + ggplot2::ggplot( + df_data, + ggplot2::aes( + y = .data[[y_var_type]], x = .data[[reference_var]], + label = .data$sit_name, + ) + ) + + p <- p + ggplot2::geom_point( + ggplot2::aes(colour = as.factor(.data$version)), + na.rm = TRUE + ) + + ggplot2::labs(color = "Version") + p <- p + + ggplot2::geom_abline( + intercept = 0, slope = ifelse(select_scat == "sim", 1, 0), + color = "grey30", linetype = 2 + ) + + ggplot2::geom_smooth( + ggplot2::aes( + y = .data[[y_var_type]], x = .data[[reference_var]], + colour = as.factor(.data$version) + ), + method = lm, + inherit.aes = FALSE, + se = FALSE, linewidth = 0.6, formula = y ~ x, + fullrange = TRUE, na.rm = TRUE + ) + + ggplot2::xlab(reference_var_name) + + ggplot2::facet_wrap(~ .data$var, scales = "free") + + p <- p + ggplot2::ggtitle(title) + if (shape_sit == "txt") { + p <- p + + ggrepel::geom_text_repel( + ggplot2::aes( + colour = as.factor(.data$version) + ), + show.legend = FALSE, + max.overlaps = 100 + ) + } + + if (is_obs_sd && reference_var == "Observed") { + p <- p + + ggplot2::geom_linerange( + ggplot2::aes( + xmin = .data$Observed - 2 * .data$Obs_SD, + xmax = .data$Observed + 2 * .data$Obs_SD, + colour = as.factor(.data$version), + ), + na.rm = TRUE + ) + } + + p <- p + ggplot2::theme(aspect.ratio = 1) + + # Set same limits for x and y axis for sim VS obs scatter plots + if (select_scat == "sim" && reference_var == "Observed") { + p <- make_axis_square(df_data, reference_var, y_var_type, is_obs_sd, p) + } + if (select_scat == "res") { + p <- force_y_axis(df_data, reference_var, y_var_type, is_obs_sd, p) + } + + return(p) +} + + +#' @keywords internal +#' @rdname specific_scatter_plots +plot_scat_versions_allsit <- function(df_data, + sit, select_scat, shape_sit, + reference_var, is_obs_sd, title = NULL) { + tmp <- give_reference_var(reference_var) + reference_var <- tmp$reference_var + reference_var_name <- tmp$reference_var_name + y_var_type <- give_y_var_type(select_scat) + + df_data <- + df_data %>% + dplyr::filter(!is.na(.data[[reference_var]]) & !is.na(.data[[y_var_type]])) + + p <- + ggplot2::ggplot( + df_data, + ggplot2::aes( + y = .data[[y_var_type]], x = .data[[reference_var]], + label = .data$sit_name + ) + ) + + if (shape_sit == "none" || shape_sit == "txt") { + p <- p + ggplot2::geom_point( + ggplot2::aes( + colour = as.factor(.data$version) + ), + na.rm = TRUE + ) + + ggplot2::labs(color = "Version") + } else if (shape_sit == "symbol" || shape_sit == "group") { + # ! In this case we loose the colour by species for mixtures, because + # there would be three aesthetics to handle (situation, version and + # species). We made this decision because the user explicitly asks + # for shape to be the situation name. If they want to color by species, + # they can put shape_sit = "none" or shape_sit = "txt" to have it all. + p <- p + ggplot2::geom_point( + ggplot2::aes( + colour = as.factor(.data$version), + shape = as.factor(.data$sit_name) + ), + na.rm = TRUE + ) + + ggplot2::labs(color = "Version", shape = "Situation") + } + + p <- p + + ggplot2::geom_abline( + intercept = 0, slope = ifelse(select_scat == "sim", 1, 0), + color = "grey30", linetype = 2 + ) + + ggplot2::geom_smooth( + ggplot2::aes( + y = .data[[y_var_type]], x = .data[[reference_var]], + colour = as.factor(.data$version) + ), + inherit.aes = FALSE, + method = lm, + se = FALSE, linewidth = 0.6, formula = y ~ x, + fullrange = TRUE, na.rm = TRUE + ) + + ggplot2::xlab(reference_var_name) + + ggplot2::facet_wrap(~ .data$var, scales = "free") + + p <- p + ggplot2::ggtitle(title) + + if (is_obs_sd && reference_var == "Observed") { + p <- p + + ggplot2::geom_linerange( + ggplot2::aes( + xmin = .data$Observed - 2 * .data$Obs_SD, + xmax = .data$Observed + 2 * .data$Obs_SD, + colour = as.factor(.data$version), + ), + na.rm = TRUE + ) + } + + p <- p + ggplot2::theme(aspect.ratio = 1) + + if (shape_sit == "txt") { + p <- p + + ggrepel::geom_text_repel( + ggplot2::aes(colour = as.factor(.data$version)), + show.legend = FALSE, + max.overlaps = 100 + ) + } + + # Set same limits for x and y axis for sim VS obs scatter plots + if (select_scat == "sim" && reference_var == "Observed") { + p <- make_axis_square(df_data, reference_var, y_var_type, is_obs_sd, p) + } + if (select_scat == "res") { + p <- force_y_axis(df_data, reference_var, y_var_type, is_obs_sd, p) + } + + return(p) +} diff --git a/R/zzz.R b/R/zzz.R index 1d15c423..48fbdb2f 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -1,17 +1,4 @@ .onAttach <- function(libname, pkgname) { - required_max_version <- "4.0.0" - installed_version <- as.character(utils::packageVersion("ggplot2")) - - if (package_version(installed_version) >= package_version(required_max_version)) { - packageStartupMessage( - sprintf( - "/!\ CroPlotR scatter plots may not work properly with ggplot2 %s or higher.\nPlease use ggplot2 3.5.2 or earlier. This issue will be fixed in a future release.", - installed_version - ) - ) - packageStartupMessage("") - } - packageStartupMessage( "Learn CroPlotR at: https://SticsRPacks.github.io/CroPlotR" ) diff --git a/README.Rmd b/README.Rmd index 2b50d6b8..748b70b4 100644 --- a/README.Rmd +++ b/README.Rmd @@ -21,105 +21,108 @@ knitr::opts_chunk$set( -[![Project Status: WIP – Initial development is in progress, but there -has not yet been a stable, usable release suitable for the -public.](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip) [![Codecov test -coverage](https://codecov.io/gh/SticsRPacks/CroPlotR/branch/master/graph/badge.svg)](https://app.codecov.io/gh/SticsRPacks/CroPlotR?branch=master) -[![R-CMD-check](https://github.com/SticsRPacks/CroPlotR/actions/workflows/check-standard.yaml/badge.svg?branch=main)](https://github.com/SticsRPacks/CroPlotR/actions/workflows/check-standard.yaml) +coverage](https://codecov.io/gh/SticsRPacks/CroPlotR/branch/main/graph/badge.svg)](https://app.codecov.io/gh/SticsRPacks/CroPlotR?branch=main) [![DOI](https://zenodo.org/badge/263962392.svg)](https://zenodo.org/badge/latestdoi/263962392) -`CroPlotR` aims at the standardization of the process of analyzing the -outputs from crop models such as -[STICS](https://www6.paca.inrae.fr/stics_eng/), -[APSIM](https://www.apsim.info/) or really any model. +`CroPlotR` standardizes the analysis and visualization of crop model outputs, including models such as +[STICS](https://www6.paca.inrae.fr/stics_eng/), [APSIM](https://www.apsim.info/), and others. -Its use does not need any particular adaptation if your model has been -wrapped with the [CroptimizR](https://github.com/SticsRPacks/CroptimizR) -package. +The package works seamlessly with models wrapped using the [CroptimizR](https://github.com/SticsRPacks/CroptimizR) +package through the `cropr_simulation` data format (see [section Data structure](#13-data-structure)). -If you want to be notified when a new release of this package is made, -you can tick the Releases box in the "Watch / Unwatch =\> Custom" menu -at the top right of [this -page](https://github.com/SticsRPacks/CroPlotR). +**Stay updated:** To receive notifications about new releases, click "Watch" → "Custom" → "Releases" at the top +of [this repository](https://github.com/SticsRPacks/CroPlotR). ## Table of Contents -- [1. Installation](#1-installation) -- [2. Examples](#2-examples) - - [2.1 Plotting](#21-plotting) - - [2.1.1 Dynamic plots](#211-dynamic-plots) - - [2.1.2 Scatter plots](#212-scatter-plots) - - [2.1.3 Group comparison](#213-group-comparison) - - [2.1.4 Plot saving](#214-plot-saving) - - [2.1.5 Plot extracting](#215-plot-extracting) - - [2.2 Statistics](#22-statistics) - - [2.2.1 Dynamic plots](#221-simple-case) - - [2.2.2 Several groups](#222-several-groups) - - [2.2.3 Statistics plot](#223-statistics-plot) - - [2.3 Data manipulation](#23-data-manipulation) -- [3. Tools](#3-tools) - - [3.1 ggplotly](#31-ggplotly) - - [3.2 patchwork](#32-patchwork) -- [4. Help](#4-help) -- [5. Citation](#5-Citation) + +- [CroPlotR](#croplotr) + - [Table of Contents](#table-of-contents) + - [1. Installation](#1-installation) + - [2. Introduction](#2-introduction) + - [3. Dynamic plots](#3-dynamic-plots) + - [3.1. Simple dynamic plot](#31-simple-dynamic-plot) + - [3.2. Adding Observations](#32-adding-observations) + - [3.3. Filtering variables](#33-filtering-variables) + - [3.4. Successive situations](#34-successive-situations) + - [3.5. Overlaying variables](#35-overlaying-variables) + - [4. Scatter plots](#4-scatter-plots) + - [4.1. Simple scatter plot](#41-simple-scatter-plot) + - [4.2. Plotting residuals](#42-plotting-residuals) + - [4.3. Grouping situations](#43-grouping-situations) + - [4.4. Reference variable on the x-axis](#44-reference-variable-on-the-x-axis) + - [4.5. Distinguishing Situations with Shapes](#45-distinguishing-situations-with-shapes) + - [5. Comparing model versions](#5-comparing-model-versions) + - [6. Error bars](#6-error-bars) + - [7. Intercrops](#7-intercrops) + - [8. Saving Plots](#8-saving-plots) + - [9. Extracting Individual Plots](#9-extracting-individual-plots) + - [10. Statistics](#10-statistics) + - [10.1. Basic Usage](#101-basic-usage) + - [10.2. Comparing Multiple Groups](#102-comparing-multiple-groups) + - [10.3. Visualizing Statistics](#103-visualizing-statistics) + - [11. Data manipulation](#11-data-manipulation) + - [12. Integration with Other Packages](#12-integration-with-other-packages) + - [12.1. Interactive Plots with plotly](#121-interactive-plots-with-plotly) + - [12.2. Combining plots with patchwork](#122-combining-plots-with-patchwork) + - [13. Data structure](#13-data-structure) + - [14. Getting help](#14-getting-help) + - [15. Citation](#15-citation) ## 1. Installation -You can install the released version of CroPlotR from -[Github](https://github.com/SticsRPacks/CroPlotR) either using -`devtools` or the lightweight `remotes` package: +Install the latest release from [GitHub](https://github.com/SticsRPacks/CroPlotR) using either `devtools` or `remotes`: -- With `devtools` +**Using `remotes` (recommended):** ```{r eval=FALSE} -devtools::install_github("SticsRPacks/CroPlotR@*release") +# install.packages("remotes") +remotes::install_github("SticsRPacks/CroPlotR@*release") ``` -- With `remotes` +**Using `devtools`:** ```{r eval=FALSE} -# install.packages("remotes") -remotes::install_github("SticsRPacks/CroPlotR@*release") +devtools::install_github("SticsRPacks/CroPlotR@*release") ``` -Normally, all the package dependencies will be installed for CRAN -packages. +## 2. Introduction -## 2. Examples +### Core Functions -At the moment, only one function is exported for plots -[`plot()`](https://sticsrpacks.github.io/CroPlotR/reference/plot.cropr_simulation.html) -(and its alias `autoplot()`), and one for the statistics -[`summary()`](https://sticsrpacks.github.io/CroPlotR/reference/summary.cropr_simulation.html). -These functions should be the only one you need for all your plots and -summary statistics. Additional ones are provided to simplify the -manipulation of simulated data (see [2.3 Data -manipulation](#23-data-manipulation)). +CroPlotR provides two main functions: -In the following, an example using the STICS crop model is presented. If -you want to use another model for which a wrapper has been designed for -the [CroptimizR](https://github.com/SticsRPacks/CroptimizR) package, -just consider defining the `sim` variable used in the examples below as -`sim <- result$sim_list`, where `result` is the list returned by your -model wrapper. Examples of use of CroPlotR with Stics and APSIM model -wrappers can be found in [CroptimizR's -website](https://sticsrpacks.github.io/CroptimizR/) (see Articles tab). +- **[`plot()`](https://sticsrpacks.github.io/CroPlotR/reference/plot.cropr_simulation.html)** (alias: `autoplot()`) for creating visualizations +- **[`summary()`](https://sticsrpacks.github.io/CroPlotR/reference/summary.cropr_simulation.html)** for computing statistical metrics -In the following example a simulation of three situations (called USM in -STICS) with their observations is used: +These functions cover most visualization and analysis needs. Additional helper functions are available for data manipulation +(see [section Data manipulation](#11-data-manipulation)). -- an intercrop of Wheat and pea -- a Pea in sole crop -- a Wheat in sole crop +### Using CroPlotR with Model Wrappers -Let's import the simulation and observation data: +If you're using a model wrapper from the [CroptimizR](https://github.com/SticsRPacks/CroptimizR) package, +you can simply extract the simulations with: `sim <- result$sim_list`, where `result` is the object returned by the model wrapper. For detailed examples with STICS and APSIM, +visit [CroptimizR's documentation](https://sticsrpacks.github.io/CroptimizR/) (Articles tab). -```{r} -library(CroPlotR) +### Example Data + +The following examples use simulation and observation data from the STICS crop model: + +**Sole crops** (objects `sim` and `obs`): +- Pea in sole crop (situation: `SC_Pea_2005-2006_N0`) +- Wheat in sole crop (situation: `SC_Wheat_2005-2006_N0`) + +**Intercrop** (`sim_intercrop` and `obs_intercrop`): + +- Wheat and Pea intercrop (situation: `IC_Wheat_Pea_2005-2006_N0`) + +
Click to view code for loading example data + +```{r, include = FALSE} # Importing an example with three situations with observation: workspace <- system.file( file.path("extdata", "stics_example_1"), @@ -130,83 +133,121 @@ situations <- SticsRFiles::get_usms_list( file = file.path(workspace, "usms.xml") ) +usms_sole_crop <- c("SC_Pea_2005-2006_N0", "SC_Wheat_2005-2006_N0") +usms_intercrop <- c("IC_Wheat_Pea_2005-2006_N0") + sim <- SticsRFiles::get_sim( workspace = workspace, - usms_file = file.path(workspace, "usms.xml") + usms_file = file.path(workspace, "usms.xml"), + usm = usms_sole_crop +) + +sim_intercrop <- SticsRFiles::get_sim( + workspace = workspace, + usms_file = file.path(workspace, "usms.xml"), + usm = usms_intercrop ) obs <- SticsRFiles::get_obs( workspace = workspace, - usm = situations, + usm = usms_sole_crop, usms_file = file.path(workspace, "usms.xml") ) -``` -### 2.1 Plotting +obs_intercrop <- SticsRFiles::get_obs( + workspace = workspace, + usm = usms_intercrop, + usms_file = file.path(workspace, "usms.xml") +) -#### 2.1.1 Dynamic plots +workspace_2 <- system.file( + file.path("extdata", "stics_example_successive"), + package = "CroPlotR" +) -Here is an application of dynamic plots for the 3 situations: +situations <- SticsRFiles::get_usms_list( + file = file.path(workspace_2, "usms.xml") +) + +sim_rot <- SticsRFiles::get_sim( + workspace = workspace_2, + usm = situations, + usms_file = file.path(workspace_2, "usms.xml") +) + +# Generate synthetic data mimicking the output of a simulation from a newer model version (for illustration purposes) +sim2 <- sim +for (sit in names(sim2)) { + sim2[[sit]]$lai_n <- sim[[sit]]$lai_n * 1.1 + sim2[[sit]]$masec_n <- sim[[sit]]$masec_n * 1.1 + sim2[[sit]]$mafruit <- sim[[sit]]$mafruit * 1.1 +} + +# Generate synthetic data mimicking standard deviation of observations (for illustration purposes) +vars <- c("lai_n", "masec_n", "mafruit") +p <- 0.20 +obs_sd <- lapply(obs, function(df) { + df_sd <- df + common_vars <- intersect(vars, names(df_sd)) + df_sd[common_vars] <- lapply(df_sd[common_vars], function(x) p * x) + df_sd +}) +# Write a .RData file for reproducibility for the users +save( + sim, sim2, sim_intercrop, obs, obs_intercrop, sim_rot, + obs_sd, + file = "inst/extdata/readme_sim_obs_example.RData" +) +``` ```{r} -p <- plot(sim, obs = obs) +library(CroPlotR) +rdata_path <- system.file(file.path("extdata", "readme_sim_obs_example.RData"), package = "CroPlotR") +load(rdata_path) ``` -Note that the `obs` argument is explicitly named. This is because the -first argument of the function is `...` (we'll see why in a minute). +
-The plot function returns a named list of ggplot objects. +## 3. Dynamic Plots -To plot all of them, just do +Dynamic plots show variable values over time, making them ideal for visualizing temporal patterns in crop model outputs. -```{r} -p -``` +### 3.1. Simple Dynamic Plot -or simply +Create basic time-series plots for all variables and situations simulated (in this example, three variables, `lai_n`, `masec_n` and `mafruit`, and two situations, `SC_Pea_2005-2006_N0` and `SC_Wheat_2005-2006_N0`): -```{r, eval=FALSE} -plot(sim, obs = obs) +```{r} +plot(sim) ``` -In this case, the elements of the list take the name of the situations. -```{r} -names(p) -``` +### 3.2. Adding Observations -To plot only one of the graph, access it using its name: +Overlay observed data on simulated outputs using the `obs` argument: ```{r} -p$`IC_Wheat_Pea_2005-2006_N0` +plots <- plot(sim, obs = obs) +# Only displaying the first situation for this one: +plots[[1]] ``` -or index: +> **Note:** The `obs` argument must be explicitly named. -```{r, eval=FALSE} -p[[1]] -``` +### 3.3. Filtering Variables -It is possible to aggregate plots of multiple situations on the same -graph when situations follow one another over time. This can be done -using the `successive` parameter. +By default, all variables are plotted. Use `var` to select specific variables: ```{r} -workspace <- system.file( - file.path("extdata", "stics_example_successive"), - package = "CroPlotR" -) +plots <- plot(sim, obs = obs, var = c("lai_n")) +# Only displaying the first situation for this one: +plots[[1]] +``` -situations <- SticsRFiles::get_usms_list( - file = file.path(workspace, "usms.xml") -) +### 3.4. Successive Situations -sim_rot <- SticsRFiles::get_sim( - workspace = workspace, - usm = situations, - usms_file = file.path(workspace, "usms.xml") -) +Combine multiple sequential situations (e.g., crop rotations) into a single continuous timeline using the `successive` parameter: +```{r} plot( sim_rot, var = c("resmes", "masec_n"), @@ -214,35 +255,39 @@ plot( ) ``` -We can also overlay variables thanks to the "overlap" parameter with -dynamic plots. +### 3.5. Overlaying Variables + +Plot multiple variables on the same graph using the `overlap` parameter: ```{r} -plot(sim, obs = obs, overlap = list(list("lai_n", "masec_n"))) +plots <- plot(sim, obs = obs, overlap = list(list("lai_n", "masec_n"))) +# Only displaying the first situation for this one: +plots[[1]] ``` -> Note that it is not possible to scale the variables right now from the -> plot function (see -> [issue](https://github.com/SticsRPacks/CroPlotR/issues/2)). If you -> want to do so, you are encouraged to scale before the plotting -> function, and to add a second axis using -> [sec_axis](https://ggplot2.tidyverse.org/reference/sec_axis.html) on -> the resulting plot. +> **Note:** Automatic variable scaling is not yet available ([see issue](https://github.com/SticsRPacks/CroPlotR/issues/2)). +> To scale variables, transform your data before plotting and add a secondary axis using +> [`sec_axis()`](https://ggplot2.tidyverse.org/reference/sec_axis.html). + +## 4. Scatter Plots -#### 2.1.2 Scatter plots +Scatter plots compare simulated versus observed values, providing visual assessment of model performance. -Here are the same plots, but presented as scatter plots: +### 4.1. Simple Scatter Plot + +Create observed vs. simulated scatter plots by setting `type = "scatter"`: ```{r} -# Only plotting the first situation for this one: plots <- plot(sim, obs = obs, type = "scatter", all_situations = FALSE) -plots$`IC_Wheat_Pea_2005-2006_N0` +# Only displaying the first situation for this one: +plots[[1]] ``` -Residues can also be represented against observations: +### 4.2. Plotting Residuals + +Visualize model residuals (observed - simulated values) using `select_scat = "res"`: ```{r} -# Only plotting the first situation again: plots <- plot( sim, obs = obs, @@ -250,22 +295,22 @@ plots <- plot( select_scat = "res", all_situations = FALSE ) - -plots[[1]] +# Only displaying the first situation again, but this time using its name: +plots$`SC_Pea_2005-2006_N0` ``` -All these data can also be represented with a single graph for all -situations: +### 4.3. Grouping Situations + +Combine data from all situations in a single plot using `all_situations = TRUE`: ```{r} plot(sim, obs = obs, type = "scatter", all_situations = TRUE) ``` -When plotting residual scatter plots, `reference_var` allows to choose -the reference variable on the x-axis. Thus, the observations or -simulations of this reference variable (to be chosen by suffixing the -variable name by "\_obs" or "\_sim") will be compared to the residuals -of each of the variables. +### 4.4. Reference Variable on the X-axis + +Use `reference_var` to specify which variable appears on the x-axis. +Suffix the variable name with `_obs`, `_sim` or `_res` to choose observed, simulated or residual values: ```{r} plot( @@ -278,23 +323,23 @@ plot( ) ``` -The points on the graphs can be shown in different shapes to -differentiate between situations when `all_situations = TRUE`. If -desired, the names of the situations can be displayed. +### 4.5. Distinguishing Situations with Shapes + +When plotting multiple situations together (`all_situations = TRUE`), differentiate them using the `shape_sit` parameter. + +**Display situation names as text labels:** ```{r} plot( sim, - obs = obs[c(2, 3)], + obs = obs, type = "scatter", all_situations = TRUE, shape_sit = "txt" ) ``` -As you can see, this can quickly become unreadable depending on the -number of points and length of situation names; That is why you can -simply assign a different symbol to each situation. +Text labels can become cluttered with many data points. Use distinct symbols instead: ```{r} plot( @@ -306,8 +351,7 @@ plot( ) ``` -It is also possible to represent a group of situations with the same -symbol when, for example, clusters are identified. +**Group multiple situations under a single symbol** (e.g., for identified clusters): ```{r} plot( @@ -320,8 +364,7 @@ plot( ) ``` -You can also name your `situation_group` list and thus customize (e.g -shorten) the plot legend. +**Customize legend labels** by naming your `situation_group` list: ```{r} plot( @@ -336,72 +379,79 @@ plot( ) ``` -By default, all variables are returned by `plot()`, but you can filter -them using the `var` argument: +## 5. Comparing Model Versions -```{r} -plot(sim, obs = obs, type = "scatter", all_situations = TRUE, var = c("lai_n")) -``` +Compare different model versions or parameter sets by passing multiple simulation objects to `plot()`. +This is why the `obs` argument must be explicitly named. -Error bars related to observations can also be added to the graph using -the `obs_sd` parameter which must be of the same shape as `obs`. In our -example, we will create a false data frame with the only purpose of -having a preview of the result. To have 95% confidence, the error bar is -equal to two standard deviations on each side of the point. +### Dynamic Plot Comparison ```{r} -obs_sd <- obs -names_obs <- names(obs_sd$`SC_Pea_2005-2006_N0`) -obs_sd$`SC_Pea_2005-2006_N0`[, !(names_obs %in% c("Date", "Plant"))] <- - 0.05 * obs_sd$`SC_Pea_2005-2006_N0`[, !(names_obs %in% c("Date", "Plant"))] -obs_sd$`SC_Wheat_2005-2006_N0`[, !(names_obs %in% c("Date", "Plant"))] <- - 0.2 * obs_sd$`SC_Wheat_2005-2006_N0`[, !(names_obs %in% c("Date", "Plant"))] - -plot(sim, obs = obs, obs_sd = obs_sd, type = "scatter", all_situations = TRUE) +plots <- plot(sim, sim2, obs = obs, all_situations = FALSE) +# Only displaying the first situation for this one: +plots[[1]] ``` -#### 2.1.3 Group comparison +### Naming Model Versions -We can compare groups of simulations alongside by simply adding the -simulations objects one after the other (that is why the first argument -of the function is `...`). Group simulations can be the results of -simulations from different model versions, or simulations with different -parameter values. +Provide descriptive names for each simulation group: ```{r} -workspace2 <- system.file( - file.path("extdata", "stics_example_2"), - package = "CroPlotR" -) - -sim2 <- SticsRFiles::get_sim( - workspace = workspace2, - usms_file = file.path(workspace2, "usms.xml") +plots <- plot( + original = sim, + "New version" = sim2, + obs = obs ) - -plot(sim, sim2, obs = obs, all_situations = FALSE) +# Only displaying the first situation for this one: +plots[[1]] ``` -Here only one plot is outputted because `workspace2` only contains the -intercrop situation. +### Scatter Plot Comparison -We can also name the corresponding group in the plot by naming them -while passing to the `plot()` function: +Model versions can also be compared using scatter plots: ```{r} -plot( - "New version" = sim, - original = sim2, +plots <- plot( + original = sim, + "New version" = sim2, obs = obs, type = "scatter", all_situations = FALSE ) +# Only displaying the first situation for this one: +plots[[1]] +``` + +## 6. Error Bars + +Add uncertainty estimates to observations using the `obs_sd` parameter, which must have the same structure as `obs`. +Error bars are then displayed as ±2 standard deviations, corresponding to an approximate 95% confidence interval under the assumption of Gaussian observation errors. + +```{r} +plot(sim, obs = obs, obs_sd = obs_sd, type = "scatter", all_situations = TRUE) +``` + +## 7. Intercrops + +CroPlotR automatically handles simulations of intercrop situations where multiple plant species are grown together. + +### Dynamic Plots for Intercrops + +```{r} +plot(sim_intercrop, obs = obs_intercrop) +``` + +### Scatter Plots for Intercrops + +```{r} +plot(sim_intercrop, obs = obs_intercrop, type = "scatter", all_situations = TRUE) ``` -#### 2.1.4 Plot saving +## 8. Saving Plots -The plots can be saved to disk using the `save_plot_png()` function as -follows: +### Save as PNG + +Export individual plots as PNG files using `save_plot_png()`: ```{r eval=FALSE} plots <- plot("New version" = sim, original = sim2, obs = obs, type = "scatter") @@ -418,10 +468,9 @@ plots <- plot( save_plot_png(., out_dir = "path/to/directory", suffix = "_scatter") ``` -They can also be saved using the `save_plot_pdf()` function that which, -from a list of ggplots, generates a pdf file. If the `file_per_var` -parameter is TRUE, in this case the function generates one pdf file per -variable. +### Save as PDF + +Export plots to PDF using `save_plot_pdf()`. Set `file_per_var = TRUE` to create separate PDFs for each variable: ```{r eval=FALSE} plots <- plot(sim, obs = obs) @@ -429,29 +478,55 @@ plots <- plot(sim, obs = obs) save_plot_pdf(plot = plots, out_dir = "path/to/directory", file_per_var = FALSE) ``` -#### 2.1.5 Plot extracting +## 9. Extracting Individual Plots -When we have plots with several variables and several situations, the -`extract_plot` function allows to keep the situations and variables that -we need. +The `plot()` function returns a named list of ggplot objects, where names correspond to situations: -In the following example, we want to extract the intercrop situation and -the "masec_n" variable. +```{r} +p <- plot(sim) + +names(p) +``` + +### Access by Name + +Access individual plots using their situation name (use backticks if the name contains special characters): + +```{r} +p$`SC_Wheat_2005-2006_N0` +``` + +### Access by Index + +Alternatively, use numeric indexing: + +```{r, eval=FALSE} +p[[1]] +``` + +### Filtering Plots + +Use `extract_plot()` to filter plots by situation and/or variable. This is useful when working with many +situations and variables. + +Example: Extract only the wheat situation and the `masec_n` variable: ```{r} plots <- plot(sim, obs = obs, type = "scatter", all_situations = FALSE) extract_plot( plots, - situation = c("IC_Wheat_Pea_2005-2006_N0"), var = c("masec_n") + situation = c("SC_Wheat_2005-2006_N0"), var = c("masec_n") ) ``` -### 2.2 Statistics +## 10. Statistics + +Compute performance metrics to quantitatively compare simulated and observed values. -#### 2.2.1 Simple case +### 10.1. Basic Usage -Here is an application of summary statistics for the 3 situations: +Calculate statistics for each situation individually: ```{r eval=FALSE} summary(sim, obs = obs, all_situations = FALSE) @@ -462,16 +537,11 @@ s <- summary(sim, obs = obs, all_situations = FALSE) knitr::kable(s) ``` -Note that as for the `plot()` function the `obs` argument is explicitly -named. This is because the first argument of the function is `...` to be -able to compare groups (i.e. model versions or simulation with different -parameter values). In this example, a message warns the user because -some observed values have a zero value which causes a division by zero -in the calculation of certain statistical criteria, these values are -therefore filtered for the calculation of these criteria. +> **Note:** The `obs` argument must be explicitly named (same reason as for `plot()`). -And as for the `plot()` function again, it is possible to compute the -statistical criteria for all situations at once. +### Aggregated Statistics + +Compute statistics across all situations simultaneously: ```{r eval=FALSE} summary(sim, obs = obs, all_situations = TRUE) @@ -482,10 +552,9 @@ s <- summary(sim, obs = obs, all_situations = TRUE) knitr::kable(s) ``` -#### 2.2.2 Several groups +### 10.2. Comparing Multiple Groups -We can get statistics for each group of simulations by simply adding the -simulations objects one after the other (as for the `plot()` function). +Compute statistics for multiple simulation groups (e.g., different model versions or parameter sets): ```{r eval=FALSE} summary(sim, sim2, obs = obs) @@ -496,8 +565,7 @@ s <- summary(sim, sim2, obs = obs) knitr::kable(s) ``` -We can also name the corresponding group in the plot by naming them -while passing to the `summary()` function: +Provide descriptive names for clarity: ```{r eval=FALSE} summary("New version" = sim, original = sim2, obs = obs) @@ -508,8 +576,9 @@ s <- summary("New version" = sim, original = sim2, obs = obs) knitr::kable(s) ``` -By default, all statistics are returned by `summary`, but you can filter -them using the `stat` argument: +### Selecting Specific Statistics + +By default, all available statistics are computed. Use the `stats` argument to select specific metrics: ```{r eval=FALSE} summary( @@ -529,18 +598,13 @@ s <- summary( knitr::kable(s) ``` -Please read the help from -[`summary.cropr_simulation()`](https://sticsrpacks.github.io/CroPlotR/reference/summary.cropr_simulation.html) -and -[`predictor_assessment()`](https://sticsrpacks.github.io/CroPlotR/reference/predictor_assessment.html). +For more details about the list of available statistical criterion and their definition, please read the help from [`predictor_assessment()`](https://sticsrpacks.github.io/CroPlotR/reference/predictor_assessment.html). -#### 2.2.3 Statistics plot +### 10.3. Visualizing Statistics -It is also possible to plot the statistics: +Plot statistical metrics for visual comparison using `plot()` on the summary output. -In a rather obvious way, the resulting graph will take into account all -the situations simultaneously or not according to the parameter given to -`summary`. Here is an example with `all_situations = FALSE`. +**Separate plots per situation** (`all_situations = FALSE`): ```{r} stats <- summary( @@ -553,7 +617,7 @@ stats <- summary( plot(stats) ``` -And here is an example with `all_situations = TRUE`. +**Combined plot for all situations** (`all_situations = TRUE`): ```{r} stats <- summary( @@ -567,8 +631,10 @@ stats <- summary( plot(stats) ``` -We can choose to plot either the group or the situation in x (and the -other is used for grouping and colouring): +### Customizing Plot Layout + +Control which variable appears on the x-axis using the `xvar` parameter. The other variable is used for +grouping and color coding: ```{r} stats <- summary( @@ -582,8 +648,9 @@ stats <- summary( plot(stats, xvar = "situation", title = "Situation in X") ``` -In the previous examples, each line corresponds to a statistical -criterion. These can also be stacked. +### Bar Chart Layouts + +**Stacked bars** (`group_bar = "stack"`): ```{r} stats <- summary( @@ -597,7 +664,7 @@ stats <- summary( plot(stats, xvar = "situation", title = "Stacked columns", group_bar = "stack") ``` -Or put side by side. +**Side-by-side bars** (`group_bar = "dodge"`): ```{r} stats <- summary( @@ -616,28 +683,16 @@ plot( ) ``` -To compare different versions on a single criterion, the function -produces a radar graph like the following one. +### Radar Charts -```{r} -sim$`SC_Pea_2005-2006_N0`$mafruit <- - (15 / 10) * sim$`SC_Pea_2005-2006_N0`$masec_n -sim$`SC_Wheat_2005-2006_N0`$mafruit <- - (15 / 20) * sim$`SC_Wheat_2005-2006_N0`$masec_n -sim2$`IC_Wheat_Pea_2005-2006_N0`$mafruit <- - sim2$`IC_Wheat_Pea_2005-2006_N0`$masec_n -obs$`IC_Wheat_Pea_2005-2006_N0`$mafruit <- - (12 / 10) * obs$`IC_Wheat_Pea_2005-2006_N0`$masec_n -obs$`SC_Pea_2005-2006_N0`$mafruit <- - (18 / 10) * obs$`SC_Pea_2005-2006_N0`$masec_n -obs$`SC_Wheat_2005-2006_N0`$mafruit <- - (15 / 12) * obs$`SC_Wheat_2005-2006_N0`$masec_n +Compare model versions across multiple variables using a radar chart (`type = "radar"`) for a single metric: +```{r} stats <- summary( "New version" = sim, original = sim2, obs = obs, - stats = c("R2", "nRMSE"), + stats = c("nRMSE"), all_situations = TRUE ) @@ -649,45 +704,44 @@ plot( ) ``` -### 2.3 Data manipulation +## 11. Data Manipulation + +### Working with Standard R Packages + +Observation data can be easily manipulated using packages like [dplyr](https://CRAN.R-project.org/package=dplyr), +[tidyr](https://CRAN.R-project.org/package=tidyr), or [tibble](https://CRAN.R-project.org/package=tibble). + +However, the `cropr_simulation` attribute on simulated data can interfere with some operations. CroPlotR provides +two helper functions to facilitate data manipulation: -Observation lists can easily be handled using e.g. -[dplyr](https://CRAN.R-project.org/package=dplyr), -[tidyr](https://CRAN.R-project.org/package=tidyr) or -[tibble](https://CRAN.R-project.org/package=tibble) packages. +### Converting to Data Frame -The use of these packages on simulated data as returned by CroptimizR -model wrappers is sometimes prevented by their attribute -`cropr_simulation`. To easily manipulate simulated data we thus provide -two functions for (i) binding rows of data simulated on different -situations in a single data.frame or tibble and (ii) go back to the -original (cropr) format by splitting this single data.frame or tibble. +Use `bind_rows()` to combine all situations into a single data frame: ```{r} df <- bind_rows(sim) head(df) ``` -The resulting data.frame/tibble can then easily be manipulated using -standard R packages. The column `situation` contains the name of the -corresponding situation (as given in the named list `sim`). +The `situation` column identifies the source situation for each row. This format is compatible with standard +data manipulation packages. -To go back to the original format of simulated data handled by CroPlotR, -use the `split_df2sim` function: +### Converting Back to CroPlotR Format + +After manipulation, use `split_df2sim()` to restore the original `cropr_simulation` structure: ```{r} sim_new <- split_df2sim(df) lapply(sim_new, head) ``` -## 3. Tools +## 12. Integration with Other Packages + +CroPlotR works seamlessly with popular R visualization packages to enhance your plots. -### 3.1 ggplotly +### 12.1. Interactive Plots with plotly -The ggplotly function in plotly library makes it very easy to create -interactive graphics from a ggplot. Do not hesitate to call it with your -plot and move your mouse over the graph to discover the features of this -function. +Convert any ggplot to an interactive visualization using `plotly::ggplotly()`: ```{r, eval = FALSE} library(plotly) @@ -695,10 +749,9 @@ library(plotly) ggplotly(plot(sim, obs = obs, type = "dynamic")[[1]]) ``` -### 3.2 patchwork +### 12.2. Combining Plots with patchwork -There is also the patchwork library that allows you to easily combine -several ggplot into one. +Create complex multi-panel layouts using the [patchwork](https://CRAN.R-project.org/package=patchwork) package: ```{r} library(patchwork) @@ -711,12 +764,59 @@ plot4 <- plot(sim, obs = obs, var = "masec_n")[[1]] plot1 + plot2 + plot3 + plot4 + plot_layout(ncol = 2) ``` -## 4. Help +## 13. Data Structure + +### Understanding the `cropr_simulation` Format -You can find help for the functions directly using the name of the -function followed by the class of the object you need the method for: +Both `sim` and `obs` objects are named lists of data frames: -- plot: +- **List names**: Correspond to situation identifiers (e.g., crop-year-management combinations) +- **Data frames**: Store variable values for each situation, with one row per time step and one column per simulated or observed variable. They include a `Date` column as a time reference (at Date or POSIXct format), and may optionally contain `Plant` and `Dominance` columns to indicate crop names and their status (ā€œPrincipalā€ or ā€œAssociatedā€) in intercrop datasets. + +### Simulation Data Structure + +```{r} +lapply(sim, head) +``` + +### Observation Data Structure + +Observations follow the same structure: + +```{r} +lapply(obs, head) +``` + +### Creating Custom `cropr_simulation` Objects + +You can create compatible simulation objects from your own data by adding the `cropr_simulation` class attribute +to a named list of data frames: + +```{r} +sim_test <- list( + situation_1 = data.frame( + Date = as.Date("2000-01-01") + 0:9, + var1 = rnorm(10), + var2 = rnorm(10) + ), + situation_2 = data.frame( + Date = as.Date("2001-01-01") + 0:9, + var1 = rnorm(10), + var2 = rnorm(10) + ) +) + +class(sim_test) <- append(class(sim_test), "cropr_simulation") +head(sim_test) +``` + +## 14. Getting Help + +### Documentation + +Access help for specific functions by specifying the class: + +**For plotting functions:** ```{r eval=FALSE} ?plot.cropr_simulation @@ -724,18 +824,17 @@ function followed by the class of the object you need the method for: ?plot.statistics ``` -- statistics: +**For statistical functions:** ```{r eval=FALSE} ?summary.cropr_simulation ``` -If you have any problem, please [fill an -issue](https://github.com/SticsRPacks/CroPlotR/issues) on Github. +### Reporting Issues + +If you encounter problems or have suggestions, please [open an issue](https://github.com/SticsRPacks/CroPlotR/issues) +on GitHub. -## 5. Citation +## 15. Citation -If you have used this package for a study that led to a publication or -report, please cite us. You can either use the citation tool from Github -if you used the last version, or use `citation("CroPlotR")` from R -otherwise. +If CroPlotR contributed to a publication or report, please cite it using the reference corresponding to the version you used. To obtain the correct citation, run citation("CroPlotR") in R. diff --git a/README.md b/README.md index 97bd4268..27ef66ed 100644 --- a/README.md +++ b/README.md @@ -5,217 +5,205 @@ -[![Project Status: WIP – Initial development is in progress, but there -has not yet been a stable, usable release suitable for the -public.](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip) [![Codecov test -coverage](https://codecov.io/gh/SticsRPacks/CroPlotR/branch/master/graph/badge.svg)](https://app.codecov.io/gh/SticsRPacks/CroPlotR?branch=master) -[![R-CMD-check](https://github.com/SticsRPacks/CroPlotR/actions/workflows/check-standard.yaml/badge.svg?branch=main)](https://github.com/SticsRPacks/CroPlotR/actions/workflows/check-standard.yaml) +coverage](https://codecov.io/gh/SticsRPacks/CroPlotR/branch/main/graph/badge.svg)](https://app.codecov.io/gh/SticsRPacks/CroPlotR?branch=main) [![DOI](https://zenodo.org/badge/263962392.svg)](https://zenodo.org/badge/latestdoi/263962392) -`CroPlotR` aims at the standardization of the process of analyzing the -outputs from crop models such as +`CroPlotR` standardizes the analysis and visualization of crop model +outputs, including models such as [STICS](https://www6.paca.inrae.fr/stics_eng/), -[APSIM](https://www.apsim.info/) or really any model. +[APSIM](https://www.apsim.info/), and others. -Its use does not need any particular adaptation if your model has been -wrapped with the [CroptimizR](https://github.com/SticsRPacks/CroptimizR) -package. +The package works seamlessly with models wrapped using the +[CroptimizR](https://github.com/SticsRPacks/CroptimizR) package through +the `cropr_simulation` data format (see [section Data +structure](#13-data-structure)). -If you want to be notified when a new release of this package is made, -you can tick the Releases box in the ā€œWatch / Unwatch =\> Customā€ menu -at the top right of [this -page](https://github.com/SticsRPacks/CroPlotR). +**Stay updated:** To receive notifications about new releases, click +ā€œWatchā€ → ā€œCustomā€ → ā€œReleasesā€ at the top of [this +repository](https://github.com/SticsRPacks/CroPlotR). ## Table of Contents -- [1. Installation](#1-installation) -- [2. Examples](#2-examples) - - [2.1 Plotting](#21-plotting) - - [2.1.1 Dynamic plots](#211-dynamic-plots) - - [2.1.2 Scatter plots](#212-scatter-plots) - - [2.1.3 Group comparison](#213-group-comparison) - - [2.1.4 Plot saving](#214-plot-saving) - - [2.1.5 Plot extracting](#215-plot-extracting) - - [2.2 Statistics](#22-statistics) - - [2.2.1 Dynamic plots](#221-simple-case) - - [2.2.2 Several groups](#222-several-groups) - - [2.2.3 Statistics plot](#223-statistics-plot) - - [2.3 Data manipulation](#23-data-manipulation) -- [3. Tools](#3-tools) - - [3.1 ggplotly](#31-ggplotly) - - [3.2 patchwork](#32-patchwork) -- [4. Help](#4-help) -- [5. Citation](#5-Citation) +- [CroPlotR](#croplotr) + - [Table of Contents](#table-of-contents) + - [1. Installation](#1-installation) + - [2. Introduction](#2-introduction) + - [3. Dynamic plots](#3-dynamic-plots) + - [3.1. Simple dynamic plot](#31-simple-dynamic-plot) + - [3.2. Adding Observations](#32-adding-observations) + - [3.3. Filtering variables](#33-filtering-variables) + - [3.4. Successive situations](#34-successive-situations) + - [3.5. Overlaying variables](#35-overlaying-variables) + - [4. Scatter plots](#4-scatter-plots) + - [4.1. Simple scatter plot](#41-simple-scatter-plot) + - [4.2. Plotting residuals](#42-plotting-residuals) + - [4.3. Grouping situations](#43-grouping-situations) + - [4.4. Reference variable on the + x-axis](#44-reference-variable-on-the-x-axis) + - [4.5. Distinguishing Situations with + Shapes](#45-distinguishing-situations-with-shapes) + - [5. Comparing model versions](#5-comparing-model-versions) + - [6. Error bars](#6-error-bars) + - [7. Intercrops](#7-intercrops) + - [8. Saving Plots](#8-saving-plots) + - [9. Extracting Individual Plots](#9-extracting-individual-plots) + - [10. Statistics](#10-statistics) + - [10.1. Basic Usage](#101-basic-usage) + - [10.2. Comparing Multiple Groups](#102-comparing-multiple-groups) + - [10.3. Visualizing Statistics](#103-visualizing-statistics) + - [11. Data manipulation](#11-data-manipulation) + - [12. Integration with Other + Packages](#12-integration-with-other-packages) + - [12.1. Interactive Plots with + plotly](#121-interactive-plots-with-plotly) + - [12.2. Combining plots with + patchwork](#122-combining-plots-with-patchwork) + - [13. Data structure](#13-data-structure) + - [14. Getting help](#14-getting-help) + - [15. Citation](#15-citation) ## 1. Installation -You can install the released version of CroPlotR from -[Github](https://github.com/SticsRPacks/CroPlotR) either using -`devtools` or the lightweight `remotes` package: +Install the latest release from +[GitHub](https://github.com/SticsRPacks/CroPlotR) using either +`devtools` or `remotes`: -- With `devtools` +**Using `remotes` (recommended):** ``` r -devtools::install_github("SticsRPacks/CroPlotR@*release") +# install.packages("remotes") +remotes::install_github("SticsRPacks/CroPlotR@*release") ``` -- With `remotes` +**Using `devtools`:** ``` r -# install.packages("remotes") -remotes::install_github("SticsRPacks/CroPlotR@*release") +devtools::install_github("SticsRPacks/CroPlotR@*release") ``` -Normally, all the package dependencies will be installed for CRAN -packages. +## 2. Introduction -## 2. Examples +### Core Functions -At the moment, only one function is exported for plots -[`plot()`](https://sticsrpacks.github.io/CroPlotR/reference/plot.cropr_simulation.html) -(and its alias `autoplot()`), and one for the statistics -[`summary()`](https://sticsrpacks.github.io/CroPlotR/reference/summary.cropr_simulation.html). -These functions should be the only one you need for all your plots and -summary statistics. Additional ones are provided to simplify the -manipulation of simulated data (see [2.3 Data -manipulation](#23-data-manipulation)). +CroPlotR provides two main functions: -In the following, an example using the STICS crop model is presented. If -you want to use another model for which a wrapper has been designed for -the [CroptimizR](https://github.com/SticsRPacks/CroptimizR) package, -just consider defining the `sim` variable used in the examples below as -`sim <- result$sim_list`, where `result` is the list returned by your -model wrapper. Examples of use of CroPlotR with Stics and APSIM model -wrappers can be found in [CroptimizR’s -website](https://sticsrpacks.github.io/CroptimizR/) (see Articles tab). +- **[`plot()`](https://sticsrpacks.github.io/CroPlotR/reference/plot.cropr_simulation.html)** + (alias: `autoplot()`) for creating visualizations +- **[`summary()`](https://sticsrpacks.github.io/CroPlotR/reference/summary.cropr_simulation.html)** + for computing statistical metrics -In the following example a simulation of three situations (called USM in -STICS) with their observations is used: +These functions cover most visualization and analysis needs. Additional +helper functions are available for data manipulation (see [section Data +manipulation](#11-data-manipulation)). -- an intercrop of Wheat and pea -- a Pea in sole crop -- a Wheat in sole crop +### Using CroPlotR with Model Wrappers -Let’s import the simulation and observation data: +If you’re using a model wrapper from the +[CroptimizR](https://github.com/SticsRPacks/CroptimizR) package, you can +simply extract the simulations with: `sim <- result$sim_list`, where +`result` is the object returned by the model wrapper. For detailed +examples with STICS and APSIM, visit [CroptimizR’s +documentation](https://sticsrpacks.github.io/CroptimizR/) (Articles +tab). -``` r -library(CroPlotR) +### Example Data -# Importing an example with three situations with observation: -workspace <- system.file( - file.path("extdata", "stics_example_1"), - package = "CroPlotR" -) +The following examples use simulation and observation data from the +STICS crop model: -situations <- SticsRFiles::get_usms_list( - file = file.path(workspace, "usms.xml") -) +**Sole crops** (objects `sim` and `obs`): -sim <- SticsRFiles::get_sim( - workspace = workspace, - usms_file = file.path(workspace, "usms.xml") -) -#> mod_spIC_Wheat_Pea_2005-2006_N0.stimod_saIC_Wheat_Pea_2005-2006_N0.sti -#> mod_sSC_Pea_2005-2006_N0.sti -#> mod_sSC_Wheat_2005-2006_N0.sti - -obs <- SticsRFiles::get_obs( - workspace = workspace, - usm = situations, - usms_file = file.path(workspace, "usms.xml") -) -#> IC_Wheat_Pea_2005-2006_N0p.obsIC_Wheat_Pea_2005-2006_N0a.obs -#> SC_Pea_2005-2006_N0.obs -#> SC_Wheat_2005-2006_N0.obs -``` +- Pea in sole crop (situation: `SC_Pea_2005-2006_N0`) +- Wheat in sole crop (situation: `SC_Wheat_2005-2006_N0`) -### 2.1 Plotting +**Intercrop** (`sim_intercrop` and `obs_intercrop`): -#### 2.1.1 Dynamic plots +- Wheat and Pea intercrop (situation: `IC_Wheat_Pea_2005-2006_N0`) -Here is an application of dynamic plots for the 3 situations: +
+ +Click to view code for loading example data + ``` r -p <- plot(sim, obs = obs) +library(CroPlotR) +#> Registered S3 method overwritten by 'CroPlotR': +#> method from +#> [.cropr_simulation SticsRFiles +#> Learn CroPlotR at: https://SticsRPacks.github.io/CroPlotR +#> +#> Please cite CroPlotR in your work: +#> Vezy R, Buis S, Midingoyi C, Lecharpentier P, Giner M (2025). +#> CroPlotR: A Package to Analyze Crop Model Simulations Outputs with +#> Plots and Statistics. R package version 0.11.0, +#> https://doi.org/10.5281/zenodo.4442330, +#> . +rdata_path <- system.file(file.path("extdata", "readme_sim_obs_example.RData"), package = "CroPlotR") +load(rdata_path) ``` -Note that the `obs` argument is explicitly named. This is because the -first argument of the function is `...` (we’ll see why in a minute). +
-The plot function returns a named list of ggplot objects. +## 3. Dynamic Plots -To plot all of them, just do +Dynamic plots show variable values over time, making them ideal for +visualizing temporal patterns in crop model outputs. -``` r -p -#> $`IC_Wheat_Pea_2005-2006_N0` -``` +### 3.1. Simple Dynamic Plot - +Create basic time-series plots for all variables and situations +simulated (in this example, three variables, `lai_n`, `masec_n` and +`mafruit`, and two situations, `SC_Pea_2005-2006_N0` and +`SC_Wheat_2005-2006_N0`): - #> - #> $`SC_Pea_2005-2006_N0` +``` r +plot(sim) +#> $`SC_Pea_2005-2006_N0` +``` - + #> #> $`SC_Wheat_2005-2006_N0` - + -or simply +### 3.2. Adding Observations -``` r -plot(sim, obs = obs) -``` - -In this case, the elements of the list take the name of the situations. +Overlay observed data on simulated outputs using the `obs` argument: ``` r -names(p) -#> [1] "IC_Wheat_Pea_2005-2006_N0" "SC_Pea_2005-2006_N0" "SC_Wheat_2005-2006_N0" +plots <- plot(sim, obs = obs) +# Only displaying the first situation for this one: +plots[[1]] ``` -To plot only one of the graph, access it using its name: + -``` r -p$`IC_Wheat_Pea_2005-2006_N0` -``` +> **Note:** The `obs` argument must be explicitly named. - +### 3.3. Filtering Variables -or index: +By default, all variables are plotted. Use `var` to select specific +variables: ``` r -p[[1]] +plots <- plot(sim, obs = obs, var = c("lai_n")) +# Only displaying the first situation for this one: +plots[[1]] ``` -It is possible to aggregate plots of multiple situations on the same -graph when situations follow one another over time. This can be done -using the `successive` parameter. + -``` r -workspace <- system.file( - file.path("extdata", "stics_example_successive"), - package = "CroPlotR" -) - -situations <- SticsRFiles::get_usms_list( - file = file.path(workspace, "usms.xml") -) +### 3.4. Successive Situations -sim_rot <- SticsRFiles::get_sim( - workspace = workspace, - usm = situations, - usms_file = file.path(workspace, "usms.xml") -) -#> mod_sdemo_Wheat1.sti -#> mod_sdemo_BareSoil2.sti -#> mod_sdemo_maize3.sti +Combine multiple sequential situations (e.g., crop rotations) into a +single continuous timeline using the `successive` parameter: +``` r plot( sim_rot, var = c("resmes", "masec_n"), @@ -224,52 +212,50 @@ plot( #> $`demo_Wheat1 | demo_BareSoil2 | demo_maize3 | ` ``` - + + +### 3.5. Overlaying Variables -We can also overlay variables thanks to the ā€œoverlapā€ parameter with -dynamic plots. +Plot multiple variables on the same graph using the `overlap` parameter: ``` r -plot(sim, obs = obs, overlap = list(list("lai_n", "masec_n"))) -#> $`IC_Wheat_Pea_2005-2006_N0` +plots <- plot(sim, obs = obs, overlap = list(list("lai_n", "masec_n"))) +# Only displaying the first situation for this one: +plots[[1]] ``` - + - #> - #> $`SC_Pea_2005-2006_N0` - - - - #> - #> $`SC_Wheat_2005-2006_N0` +> **Note:** Automatic variable scaling is not yet available ([see +> issue](https://github.com/SticsRPacks/CroPlotR/issues/2)). To scale +> variables, transform your data before plotting and add a secondary +> axis using +> [`sec_axis()`](https://ggplot2.tidyverse.org/reference/sec_axis.html). - +## 4. Scatter Plots -> Note that it is not possible to scale the variables right now from the -> plot function (see -> [issue](https://github.com/SticsRPacks/CroPlotR/issues/2)). If you -> want to do so, you are encouraged to scale before the plotting -> function, and to add a second axis using -> [sec_axis](https://ggplot2.tidyverse.org/reference/sec_axis.html) on -> the resulting plot. +Scatter plots compare simulated versus observed values, providing visual +assessment of model performance. -#### 2.1.2 Scatter plots +### 4.1. Simple Scatter Plot -Here are the same plots, but presented as scatter plots: +Create observed vs.Ā simulated scatter plots by setting +`type = "scatter"`: ``` r -# Only plotting the first situation for this one: plots <- plot(sim, obs = obs, type = "scatter", all_situations = FALSE) -plots$`IC_Wheat_Pea_2005-2006_N0` +# Only displaying the first situation for this one: +plots[[1]] ``` - + + +### 4.2. Plotting Residuals -Residues can also be represented against observations: +Visualize model residuals (observed - simulated values) using +`select_scat = "res"`: ``` r -# Only plotting the first situation again: plots <- plot( sim, obs = obs, @@ -277,27 +263,29 @@ plots <- plot( select_scat = "res", all_situations = FALSE ) - -plots[[1]] +# Only displaying the first situation again, but this time using its name: +plots$`SC_Pea_2005-2006_N0` ``` - + + +### 4.3. Grouping Situations -All these data can also be represented with a single graph for all -situations: +Combine data from all situations in a single plot using +`all_situations = TRUE`: ``` r plot(sim, obs = obs, type = "scatter", all_situations = TRUE) #> $all_situations ``` - + -When plotting residual scatter plots, `reference_var` allows to choose -the reference variable on the x-axis. Thus, the observations or -simulations of this reference variable (to be chosen by suffixing the -variable name by ā€œ\_obsā€ or ā€œ\_simā€) will be compared to the residuals -of each of the variables. +### 4.4. Reference Variable on the X-axis + +Use `reference_var` to specify which variable appears on the x-axis. +Suffix the variable name with `_obs`, `_sim` or `_res` to choose +observed, simulated or residual values: ``` r plot( @@ -311,16 +299,19 @@ plot( #> $all_situations ``` - + + +### 4.5. Distinguishing Situations with Shapes + +When plotting multiple situations together (`all_situations = TRUE`), +differentiate them using the `shape_sit` parameter. -The points on the graphs can be shown in different shapes to -differentiate between situations when `all_situations = TRUE`. If -desired, the names of the situations can be displayed. +**Display situation names as text labels:** ``` r plot( sim, - obs = obs[c(2, 3)], + obs = obs, type = "scatter", all_situations = TRUE, shape_sit = "txt" @@ -328,11 +319,10 @@ plot( #> $all_situations ``` - + -As you can see, this can quickly become unreadable depending on the -number of points and length of situation names; That is why you can -simply assign a different symbol to each situation. +Text labels can become cluttered with many data points. Use distinct +symbols instead: ``` r plot( @@ -345,10 +335,10 @@ plot( #> $all_situations ``` - + -It is also possible to represent a group of situations with the same -symbol when, for example, clusters are identified. +**Group multiple situations under a single symbol** (e.g., for +identified clusters): ``` r plot( @@ -362,10 +352,9 @@ plot( #> $all_situations ``` - + -You can also name your `situation_group` list and thus customize (e.g -shorten) the plot legend. +**Customize legend labels** by naming your `situation_group` list: ``` r plot( @@ -381,87 +370,100 @@ plot( #> $all_situations ``` - + + +## 5. Comparing Model Versions -By default, all variables are returned by `plot()`, but you can filter -them using the `var` argument: +Compare different model versions or parameter sets by passing multiple +simulation objects to `plot()`. This is why the `obs` argument must be +explicitly named. + +### Dynamic Plot Comparison ``` r -plot(sim, obs = obs, type = "scatter", all_situations = TRUE, var = c("lai_n")) -#> $all_situations +plots <- plot(sim, sim2, obs = obs, all_situations = FALSE) +# Only displaying the first situation for this one: +plots[[1]] ``` - + -Error bars related to observations can also be added to the graph using -the `obs_sd` parameter which must be of the same shape as `obs`. In our -example, we will create a false data frame with the only purpose of -having a preview of the result. To have 95% confidence, the error bar is -equal to two standard deviations on each side of the point. +### Naming Model Versions -``` r -obs_sd <- obs -names_obs <- names(obs_sd$`SC_Pea_2005-2006_N0`) -obs_sd$`SC_Pea_2005-2006_N0`[, !(names_obs %in% c("Date", "Plant"))] <- - 0.05 * obs_sd$`SC_Pea_2005-2006_N0`[, !(names_obs %in% c("Date", "Plant"))] -obs_sd$`SC_Wheat_2005-2006_N0`[, !(names_obs %in% c("Date", "Plant"))] <- - 0.2 * obs_sd$`SC_Wheat_2005-2006_N0`[, !(names_obs %in% c("Date", "Plant"))] +Provide descriptive names for each simulation group: -plot(sim, obs = obs, obs_sd = obs_sd, type = "scatter", all_situations = TRUE) -#> $all_situations +``` r +plots <- plot( + original = sim, + "New version" = sim2, + obs = obs +) +# Only displaying the first situation for this one: +plots[[1]] ``` - + -#### 2.1.3 Group comparison +### Scatter Plot Comparison -We can compare groups of simulations alongside by simply adding the -simulations objects one after the other (that is why the first argument -of the function is `...`). Group simulations can be the results of -simulations from different model versions, or simulations with different -parameter values. +Model versions can also be compared using scatter plots: ``` r -workspace2 <- system.file( - file.path("extdata", "stics_example_2"), - package = "CroPlotR" +plots <- plot( + original = sim, + "New version" = sim2, + obs = obs, + type = "scatter", + all_situations = FALSE ) +# Only displaying the first situation for this one: +plots[[1]] +``` -sim2 <- SticsRFiles::get_sim( - workspace = workspace2, - usms_file = file.path(workspace2, "usms.xml") -) -#> mod_spIC_Wheat_Pea_2005-2006_N0.stimod_saIC_Wheat_Pea_2005-2006_N0.sti + -plot(sim, sim2, obs = obs, all_situations = FALSE) -#> $`IC_Wheat_Pea_2005-2006_N0` +## 6. Error Bars + +Add uncertainty estimates to observations using the `obs_sd` parameter, +which must have the same structure as `obs`. Error bars are then +displayed as ±2 standard deviations, corresponding to an approximate 95% +confidence interval under the assumption of Gaussian observation errors. + +``` r +plot(sim, obs = obs, obs_sd = obs_sd, type = "scatter", all_situations = TRUE) +#> $all_situations ``` - + -Here only one plot is outputted because `workspace2` only contains the -intercrop situation. +## 7. Intercrops -We can also name the corresponding group in the plot by naming them -while passing to the `plot()` function: +CroPlotR automatically handles simulations of intercrop situations where +multiple plant species are grown together. + +### Dynamic Plots for Intercrops ``` r -plot( - "New version" = sim, - original = sim2, - obs = obs, - type = "scatter", - all_situations = FALSE -) +plot(sim_intercrop, obs = obs_intercrop) #> $`IC_Wheat_Pea_2005-2006_N0` ``` - + + +### Scatter Plots for Intercrops + +``` r +plot(sim_intercrop, obs = obs_intercrop, type = "scatter", all_situations = TRUE) +#> $all_situations +``` + + + +## 8. Saving Plots -#### 2.1.4 Plot saving +### Save as PNG -The plots can be saved to disk using the `save_plot_png()` function as -follows: +Export individual plots as PNG files using `save_plot_png()`: ``` r plots <- plot("New version" = sim, original = sim2, obs = obs, type = "scatter") @@ -478,10 +480,10 @@ plots <- plot( save_plot_png(., out_dir = "path/to/directory", suffix = "_scatter") ``` -They can also be saved using the `save_plot_pdf()` function that which, -from a list of ggplots, generates a pdf file. If the `file_per_var` -parameter is TRUE, in this case the function generates one pdf file per -variable. +### Save as PDF + +Export plots to PDF using `save_plot_pdf()`. Set `file_per_var = TRUE` +to create separate PDFs for each variable: ``` r plots <- plot(sim, obs = obs) @@ -489,114 +491,132 @@ plots <- plot(sim, obs = obs) save_plot_pdf(plot = plots, out_dir = "path/to/directory", file_per_var = FALSE) ``` -#### 2.1.5 Plot extracting +## 9. Extracting Individual Plots + +The `plot()` function returns a named list of ggplot objects, where +names correspond to situations: + +``` r +p <- plot(sim) + +names(p) +#> [1] "SC_Pea_2005-2006_N0" "SC_Wheat_2005-2006_N0" +``` + +### Access by Name + +Access individual plots using their situation name (use backticks if the +name contains special characters): + +``` r +p$`SC_Wheat_2005-2006_N0` +``` + + + +### Access by Index + +Alternatively, use numeric indexing: + +``` r +p[[1]] +``` + +### Filtering Plots -When we have plots with several variables and several situations, the -`extract_plot` function allows to keep the situations and variables that -we need. +Use `extract_plot()` to filter plots by situation and/or variable. This +is useful when working with many situations and variables. -In the following example, we want to extract the intercrop situation and -the ā€œmasec_nā€ variable. +Example: Extract only the wheat situation and the `masec_n` variable: ``` r plots <- plot(sim, obs = obs, type = "scatter", all_situations = FALSE) extract_plot( plots, - situation = c("IC_Wheat_Pea_2005-2006_N0"), var = c("masec_n") + situation = c("SC_Wheat_2005-2006_N0"), var = c("masec_n") ) -#> $`IC_Wheat_Pea_2005-2006_N0` +#> $`SC_Wheat_2005-2006_N0` ``` - + -### 2.2 Statistics +## 10. Statistics -#### 2.2.1 Simple case +Compute performance metrics to quantitatively compare simulated and +observed values. -Here is an application of summary statistics for the 3 situations: +### 10.1. Basic Usage + +Calculate statistics for each situation individually: ``` r summary(sim, obs = obs, all_situations = FALSE) ``` - #> Attention: some observed values are zero. They are filtered for the computation of MAPE - #> Attention: some observed values are zero. They are filtered for the computation of RME - | group | situation | variable | n_obs | mean_obs | mean_sim | r_means | sd_obs | sd_sim | CV_obs | CV_sim | R2 | SS_res | Inter | Slope | RMSE | RMSEs | RMSEu | nRMSE | rRMSE | rRMSEs | rRMSEu | pMSEs | pMSEu | Bias2 | SDSD | LCS | rbias2 | rSDSD | rLCS | MAE | FVU | MSE | EF | Bias | ABS | MAPE | RME | tSTUD | tLimit | Decision | |:---|:---|:---|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|:---| -| Version_1 | IC_Wheat_Pea_2005-2006_N0 | lai_n | 8 | 0.762500 | 0.6135987 | 80.47197 | 0.6326306 | 0.5508654 | 82.96794 | 89.77616 | 0.8082574 | 0.7167893 | 0.0166871 | 0.7828349 | 0.2993304 | 0.1966900 | 0.2256362 | 39.25644 | 0.3925644 | 0.2579541 | 0.2959163 | 0.4317805 | 0.5682195 | 0.0221716 | 0.0066855 | 0.0703740 | 0.0381344 | 0.0114989 | 0.1210410 | 0.2323863 | 0.1925422 | 0.0895987 | 0.7441455 | -0.1489013 | 0.2323863 | 0.3156233 | -0.2466048 | -1.5171559 | 2.364624 | OK | -| Version_1 | IC_Wheat_Pea_2005-2006_N0 | masec_n | 10 | 3.450000 | 3.2975700 | 95.58174 | 1.9615810 | 2.1296432 | 56.85742 | 64.58220 | 0.9631080 | 1.8866224 | -0.3782750 | 1.0654623 | 0.4343527 | 0.1951283 | 0.3880557 | 12.58993 | 0.1258993 | 0.0565589 | 0.1124799 | 0.2018159 | 0.7981841 | 0.0232349 | 0.0282449 | 0.1555633 | 0.0019521 | 0.0023730 | 0.0130698 | 0.3477720 | 0.0477697 | 0.1886622 | 0.9455209 | -0.1524300 | 0.3477720 | 0.1927375 | -0.1469491 | -1.1243151 | 2.262157 | OK | -| Version_1 | SC_Pea_2005-2006_N0 | lai_n | 3 | 2.622222 | 1.7386367 | 66.30394 | 1.5135732 | 1.3463799 | 57.72101 | 77.43883 | 0.6945994 | 3.7558828 | -0.2053841 | 0.7413638 | 1.1189106 | 0.9396204 | 0.6075149 | 42.67032 | 0.4267032 | 0.3583298 | 0.2316794 | 0.7052029 | 0.2947971 | 0.7807234 | 0.0279536 | 0.6789027 | 0.1135424 | 0.0040654 | 0.0987344 | 0.8835856 | 0.3085491 | 1.2519609 | 0.1802618 | -0.8835856 | 0.8835856 | 0.3901011 | -0.3901011 | -1.8203030 | 4.302653 | OK | -| Version_1 | SC_Pea_2005-2006_N0 | masec_n | 4 | 5.451667 | 4.3825425 | 80.38904 | 3.7848396 | 3.7494028 | 69.42537 | 85.55314 | 0.8907017 | 9.3636018 | -0.7144037 | 0.9349336 | 1.5300001 | 1.0901888 | 1.0734937 | 28.06481 | 0.2806481 | 0.1999735 | 0.1969111 | 0.5077156 | 0.4922844 | 1.1430265 | 0.0012558 | 1.5959095 | 0.0384590 | 0.0000423 | 0.0536970 | 1.1660625 | 0.1114949 | 2.3409005 | 0.7821153 | -1.0691242 | 1.1660625 | 0.3308096 | -0.3198354 | -1.6919332 | 3.182446 | OK | -| Version_1 | SC_Wheat_2005-2006_N0 | lai_n | 3 | 1.273333 | 1.4022867 | 110.12723 | 0.4396684 | 0.6236645 | 34.52893 | 44.47482 | 0.0098002 | 1.1058377 | 1.2234797 | 0.1404243 | 0.6071347 | 0.3344381 | 0.5067186 | 47.68074 | 0.4768074 | 0.2626477 | 0.3979465 | 0.3034319 | 0.6965681 | 0.0166290 | 0.0338546 | 0.4941208 | 0.0102561 | 0.0208801 | 0.3047537 | 0.5115933 | 2.7312604 | 0.3686126 | -1.8602948 | 0.1289533 | 0.5115933 | 0.4881989 | 0.1825306 | 0.3073876 | 4.302653 | OK | -| Version_1 | SC_Wheat_2005-2006_N0 | masec_n | 4 | 5.393750 | 6.0159025 | 111.53469 | 3.1594630 | 3.9552603 | 58.57637 | 65.74675 | 0.9637756 | 4.8187352 | -0.6129841 | 1.2289940 | 1.0975809 | 0.8829841 | 0.6519378 | 20.34912 | 0.2034912 | 0.1637050 | 0.1208691 | 0.6471914 | 0.3528086 | 0.3870737 | 0.6332935 | 0.4568533 | 0.0133049 | 0.0217682 | 0.0157035 | 0.6221525 | 0.1092090 | 1.2046838 | 0.8390892 | 0.6221525 | 0.6221525 | 0.0866369 | 0.0866369 | 1.1917478 | 3.182446 | OK | +| Version_1 | SC_Pea_2005-2006_N0 | lai_n | 3 | 2.622222 | 1.738637 | 66.30394 | 1.5135732 | 1.3463799 | 57.72101 | 77.43883 | 0.6945994 | 3.7558828 | -0.2053841 | 0.7413638 | 1.1189106 | 0.9396204 | 0.6075149 | 42.670319 | 0.4267032 | 0.3583298 | 0.2316794 | 0.7052029 | 0.2947971 | 0.7807234 | 0.0279536 | 0.6789027 | 0.1135424 | 0.0040654 | 0.0987344 | 0.8835856 | 0.3085491 | 1.2519609 | 0.1802618 | -0.8835856 | 0.8835856 | 0.3901011 | -0.3901011 | -1.8203030 | 4.302653 | OK | +| Version_1 | SC_Pea_2005-2006_N0 | mafruit | 1 | 4.355000 | 4.742713 | 108.90270 | NA | NA | NA | NA | 0.0000000 | 0.1503211 | 4.7427127 | NA | 0.3877127 | 0.3877127 | 0.0000000 | 8.902703 | 0.0890270 | 0.0890270 | 0.0000000 | 1.0000000 | 0.0000000 | 0.1503211 | NA | NA | 0.0079258 | NA | NA | 0.3877127 | NA | 0.1503211 | -Inf | 0.3877127 | 0.3877127 | 0.0890270 | 0.0890270 | NA | NaN | Insufficient size | +| Version_1 | SC_Pea_2005-2006_N0 | masec_n | 4 | 5.451667 | 4.382542 | 80.38904 | 3.7848396 | 3.7494028 | 69.42537 | 85.55314 | 0.8907017 | 9.3636018 | -0.7144037 | 0.9349336 | 1.5300001 | 1.0901888 | 1.0734937 | 28.064815 | 0.2806481 | 0.1999735 | 0.1969111 | 0.5077156 | 0.4922844 | 1.1430265 | 0.0012558 | 1.5959095 | 0.0384590 | 0.0000423 | 0.0536970 | 1.1660625 | 0.1114949 | 2.3409005 | 0.7821153 | -1.0691242 | 1.1660625 | 0.3308096 | -0.3198354 | -1.6919332 | 3.182446 | OK | +| Version_1 | SC_Wheat_2005-2006_N0 | lai_n | 3 | 1.273333 | 1.402287 | 110.12723 | 0.4396684 | 0.6236645 | 34.52893 | 44.47482 | 0.0098002 | 1.1058377 | 1.2234797 | 0.1404243 | 0.6071347 | 0.3344381 | 0.5067186 | 47.680736 | 0.4768074 | 0.2626477 | 0.3979465 | 0.3034319 | 0.6965681 | 0.0166290 | 0.0338546 | 0.4941208 | 0.0102561 | 0.0208801 | 0.3047537 | 0.5115933 | 2.7312604 | 0.3686126 | -1.8602948 | 0.1289533 | 0.5115933 | 0.4881989 | 0.1825306 | 0.3073876 | 4.302653 | OK | +| Version_1 | SC_Wheat_2005-2006_N0 | mafruit | 1 | 3.825000 | 5.675395 | 148.37634 | NA | NA | NA | NA | 0.0000000 | 3.4239617 | 5.6753950 | NA | 1.8503950 | 1.8503950 | 0.0000000 | 48.376340 | 0.4837634 | 0.4837634 | 0.0000000 | 1.0000000 | 0.0000000 | 3.4239617 | NA | NA | 0.2340270 | NA | NA | 1.8503950 | NA | 3.4239617 | -Inf | 1.8503950 | 1.8503950 | 0.4837634 | 0.4837634 | NA | NaN | Insufficient size | +| Version_1 | SC_Wheat_2005-2006_N0 | masec_n | 4 | 5.393750 | 6.015903 | 111.53469 | 3.1594630 | 3.9552603 | 58.57637 | 65.74675 | 0.9637756 | 4.8187352 | -0.6129841 | 1.2289940 | 1.0975809 | 0.8829841 | 0.6519378 | 20.349124 | 0.2034912 | 0.1637050 | 0.1208691 | 0.6471914 | 0.3528086 | 0.3870737 | 0.6332935 | 0.4568533 | 0.0133049 | 0.0217682 | 0.0157035 | 0.6221525 | 0.1092090 | 1.2046838 | 0.8390892 | 0.6221525 | 0.6221525 | 0.0866369 | 0.0866369 | 1.1917478 | 3.182446 | OK | + +> **Note:** The `obs` argument must be explicitly named (same reason as +> for `plot()`). -Note that as for the `plot()` function the `obs` argument is explicitly -named. This is because the first argument of the function is `...` to be -able to compare groups (i.e.Ā model versions or simulation with different -parameter values). In this example, a message warns the user because -some observed values have a zero value which causes a division by zero -in the calculation of certain statistical criteria, these values are -therefore filtered for the calculation of these criteria. +### Aggregated Statistics -And as for the `plot()` function again, it is possible to compute the -statistical criteria for all situations at once. +Compute statistics across all situations simultaneously: ``` r summary(sim, obs = obs, all_situations = TRUE) ``` - #> Attention: some observed values are zero. They are filtered for the computation of MAPE - #> Attention: some observed values are zero. They are filtered for the computation of RME - | group | situation | variable | n_obs | mean_obs | mean_sim | r_means | sd_obs | sd_sim | CV_obs | CV_sim | R2 | SS_res | Inter | Slope | RMSE | RMSEs | RMSEu | nRMSE | rRMSE | rRMSEs | rRMSEu | pMSEs | pMSEu | Bias2 | SDSD | LCS | rbias2 | rSDSD | rLCS | MAE | FVU | MSE | EF | Bias | ABS | MAPE | RME | tSTUD | tLimit | Decision | |:---|:---|:---|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|:---| -| Version_1 | all_situations | lai_n | 14 | 1.270476 | 1.023683 | 80.57474 | 1.085427 | 0.8698547 | 85.43465 | 84.97306 | 0.6923882 | 5.57851 | 0.1764799 | 0.6668389 | 0.6312408 | 0.4270089 | 0.4648960 | 49.68537 | 0.4968537 | 0.3361015 | 0.3659227 | 0.4575977 | 0.5424023 | 0.0609069 | 0.0464714 | 0.3170527 | 0.0377341 | 0.0287907 | 0.1964257 | 0.4317590 | 0.3085546 | 0.398465 | 0.6357717 | -0.2467933 | 0.4317590 | 0.3773867 | -0.1751950 | -1.5315489 | 2.160369 | OK | -| Version_1 | all_situations | masec_n | 18 | 4.326759 | 4.142749 | 95.74715 | 2.710052 | 2.9836105 | 62.63468 | 72.02007 | 0.8994510 | 16.06896 | -0.3749370 | 1.0441269 | 0.9448386 | 0.2176378 | 0.9194312 | 21.83710 | 0.2183710 | 0.0503004 | 0.2124988 | 0.0530583 | 0.9469417 | 0.0338598 | 0.0748344 | 0.8345469 | 0.0018087 | 0.0039974 | 0.0445785 | 0.5905878 | 0.1238200 | 0.892720 | 0.8712985 | -0.1840104 | 0.5905878 | 0.1998423 | -0.1334603 | -0.8186637 | 2.109816 | OK | +| Version_1 | all_situations | lai_n | 6 | 1.947778 | 1.570462 | 80.62838 | 1.2407801 | 0.9563566 | 63.702343 | 60.89653 | 0.4849226 | 4.861720 | 0.5250179 | 0.5367367 | 0.9001593 | 0.6463004 | 0.6265641 | 46.21468 | 0.4621468 | 0.3318142 | 0.3216815 | 0.5155017 | 0.4844983 | 0.1423674 | 0.0808967 | 0.7206064 | 0.0375260 | 0.0213232 | 0.1899413 | 0.6975894 | 0.5206137 | 0.8102867 | 0.3684171 | -0.3773161 | 0.6975894 | 0.4391500 | -0.1037853 | -1.0323533 | 2.570582 | OK | +| Version_1 | all_situations | mafruit | 2 | 4.090000 | 5.209054 | 127.36073 | 0.3747666 | 0.6595060 | 9.162997 | 12.66076 | 1.0000000 | 3.574283 | 12.4065456 | -1.7597779 | 1.3368401 | 1.3368401 | 0.0000000 | 32.68558 | 0.3268558 | 0.3268558 | 0.0000000 | 1.0000000 | 0.0000000 | 1.2522815 | 0.0810765 | 0.9886432 | 0.0748610 | 0.0048467 | 0.0591007 | 1.1190538 | 7.6163742 | 1.7871414 | -24.4487917 | 1.1190538 | 1.1190538 | 0.2863952 | 0.2863952 | 1.5301393 | 12.706205 | OK | +| Version_1 | all_situations | masec_n | 8 | 5.422708 | 5.199223 | 95.87870 | 3.2277449 | 3.6731078 | 59.522746 | 70.64725 | 0.8562305 | 14.182337 | -0.5109084 | 1.0530035 | 1.3314624 | 0.2748750 | 1.3027800 | 24.55346 | 0.2455346 | 0.0506896 | 0.2402453 | 0.0426199 | 0.9573801 | 0.0499459 | 0.1983481 | 1.7706190 | 0.0016985 | 0.0067452 | 0.0602133 | 0.8941075 | 0.1889905 | 1.7727921 | 0.8055306 | -0.2234858 | 0.8941075 | 0.2087232 | -0.1165992 | -0.4504803 | 2.364624 | OK | -#### 2.2.2 Several groups +### 10.2. Comparing Multiple Groups -We can get statistics for each group of simulations by simply adding the -simulations objects one after the other (as for the `plot()` function). +Compute statistics for multiple simulation groups (e.g., different model +versions or parameter sets): ``` r summary(sim, sim2, obs = obs) ``` - #> Attention: some observed values are zero. They are filtered for the computation of MAPE - #> Attention: some observed values are zero. They are filtered for the computation of RME - #> Attention: some observed values are zero. They are filtered for the computation of MAPE - #> Attention: some observed values are zero. They are filtered for the computation of RME - | group | situation | variable | n_obs | mean_obs | mean_sim | r_means | sd_obs | sd_sim | CV_obs | CV_sim | R2 | SS_res | Inter | Slope | RMSE | RMSEs | RMSEu | nRMSE | rRMSE | rRMSEs | rRMSEu | pMSEs | pMSEu | Bias2 | SDSD | LCS | rbias2 | rSDSD | rLCS | MAE | FVU | MSE | EF | Bias | ABS | MAPE | RME | tSTUD | tLimit | Decision | |:---|:---|:---|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|:---| -| Version_1 | all_situations | lai_n | 14 | 1.270476 | 1.0236829 | 80.57474 | 1.0854269 | 0.8698547 | 85.43465 | 84.97306 | 0.6923882 | 5.578510 | 0.1764799 | 0.6668389 | 0.6312408 | 0.4270089 | 0.4648960 | 49.68537 | 0.4968537 | 0.3361015 | 0.3659227 | 0.4575977 | 0.5424023 | 0.0609069 | 0.0464714 | 0.3170527 | 0.0377341 | 0.0287907 | 0.1964257 | 0.4317590 | 0.3085546 | 0.3984650 | 0.6357717 | -0.2467933 | 0.4317590 | 0.3773867 | -0.1751950 | -1.5315489 | 2.160369 | OK | -| Version_1 | all_situations | masec_n | 18 | 4.326759 | 4.1427489 | 95.74715 | 2.7100517 | 2.9836105 | 62.63468 | 72.02007 | 0.8994510 | 16.068959 | -0.3749370 | 1.0441269 | 0.9448386 | 0.2176378 | 0.9194312 | 21.83710 | 0.2183710 | 0.0503004 | 0.2124988 | 0.0530583 | 0.9469417 | 0.0338598 | 0.0748344 | 0.8345469 | 0.0018087 | 0.0039974 | 0.0445785 | 0.5905878 | 0.1238200 | 0.8927200 | 0.8712985 | -0.1840104 | 0.5905878 | 0.1998423 | -0.1334603 | -0.8186637 | 2.109816 | OK | -| Version_2 | all_situations | lai_n | 8 | 0.762500 | 0.5993112 | 78.59820 | 0.6326306 | 0.4383225 | 82.96794 | 73.13770 | 0.1192180 | 3.019054 | 0.4168988 | 0.2392294 | 0.6143141 | 0.4788662 | 0.3847972 | 80.56578 | 0.8056578 | 0.6280213 | 0.5046521 | 0.6076416 | 0.3923584 | 0.0266306 | 0.0377556 | 0.3631029 | 0.0458037 | 0.0649385 | 0.6245253 | 0.5046413 | 1.0015919 | 0.3773818 | -0.0776372 | -0.1631888 | 0.5046413 | 0.5726006 | -0.2460595 | -0.7290203 | 2.364624 | OK | -| Version_2 | all_situations | masec_n | 10 | 3.450000 | 3.3168750 | 96.14130 | 1.9615810 | 3.2725657 | 56.85742 | 98.66412 | 0.6237332 | 39.937521 | -1.2288238 | 1.3175938 | 1.9984374 | 0.6058240 | 1.9043974 | 57.92572 | 0.5792572 | 0.1756012 | 0.5519992 | 0.0918992 | 0.9081008 | 0.0177223 | 1.7186808 | 2.6991301 | 0.0014890 | 0.1443966 | 0.2267700 | 1.7338590 | 1.1481394 | 3.9937521 | -0.1532570 | -0.1331250 | 1.7338590 | 0.5148451 | -0.1538282 | -0.2002885 | 2.262157 | OK | +| Version_1 | all_situations | lai_n | 6 | 1.947778 | 1.570462 | 80.62838 | 1.2407801 | 0.9563566 | 63.702343 | 60.89653 | 0.4849226 | 4.861720 | 0.5250179 | 0.5367367 | 0.9001593 | 0.6463004 | 0.6265641 | 46.21468 | 0.4621468 | 0.3318142 | 0.3216815 | 0.5155017 | 0.4844983 | 0.1423674 | 0.0808967 | 0.7206064 | 0.0375260 | 0.0213232 | 0.1899413 | 0.6975894 | 0.5206137 | 0.8102867 | 0.3684171 | -0.3773161 | 0.6975894 | 0.4391500 | -0.1037853 | -1.0323533 | 2.570582 | OK | +| Version_1 | all_situations | mafruit | 2 | 4.090000 | 5.209054 | 127.36073 | 0.3747666 | 0.6595060 | 9.162997 | 12.66076 | 1.0000000 | 3.574283 | 12.4065456 | -1.7597779 | 1.3368401 | 1.3368401 | 0.0000000 | 32.68558 | 0.3268558 | 0.3268558 | 0.0000000 | 1.0000000 | 0.0000000 | 1.2522815 | 0.0810765 | 0.9886432 | 0.0748610 | 0.0048467 | 0.0591007 | 1.1190538 | 7.6163742 | 1.7871414 | -24.4487917 | 1.1190538 | 1.1190538 | 0.2863952 | 0.2863952 | 1.5301393 | 12.706205 | OK | +| Version_1 | all_situations | masec_n | 8 | 5.422708 | 5.199223 | 95.87870 | 3.2277449 | 3.6731078 | 59.522746 | 70.64725 | 0.8562305 | 14.182337 | -0.5109084 | 1.0530035 | 1.3314624 | 0.2748750 | 1.3027800 | 24.55346 | 0.2455346 | 0.0506896 | 0.2402453 | 0.0426199 | 0.9573801 | 0.0499459 | 0.1983481 | 1.7706190 | 0.0016985 | 0.0067452 | 0.0602133 | 0.8941075 | 0.1889905 | 1.7727921 | 0.8055306 | -0.2234858 | 0.8941075 | 0.2087232 | -0.1165992 | -0.4504803 | 2.364624 | OK | +| Version_2 | all_situations | lai_n | 6 | 1.947778 | 1.727508 | 88.69122 | 1.2407801 | 1.0519922 | 63.702343 | 60.89653 | 0.4849226 | 4.432653 | 0.5775197 | 0.5904103 | 0.8595205 | 0.5135666 | 0.6892205 | 44.12826 | 0.4412826 | 0.2636679 | 0.3538496 | 0.3570105 | 0.6429895 | 0.0485188 | 0.0356408 | 0.7926671 | 0.0127889 | 0.0093944 | 0.2089354 | 0.6060845 | 0.5380247 | 0.7387754 | 0.4241570 | -0.2202699 | 0.6060845 | 0.4168965 | -0.0141638 | -0.5928365 | 2.570582 | OK | +| Version_2 | all_situations | mafruit | 2 | 4.090000 | 5.729959 | 140.09680 | 0.3747666 | 0.7254566 | 9.162997 | 12.66076 | 1.0000000 | 6.589424 | 13.6472001 | -1.9357557 | 1.8151341 | 1.8151341 | 0.0000000 | 44.37981 | 0.4437981 | 0.4437981 | 0.0000000 | 1.0000000 | 0.0000000 | 2.6894663 | 0.1229835 | 1.0875076 | 0.1607754 | 0.0073519 | 0.0650108 | 1.6399592 | 8.6186616 | 3.2947118 | -45.9165084 | 1.6399592 | 1.6399592 | 0.4150347 | 0.4150347 | 2.1079838 | 12.706205 | OK | +| Version_2 | all_situations | masec_n | 8 | 5.422708 | 5.719145 | 105.46658 | 3.2277449 | 4.0404186 | 59.522746 | 70.64725 | 0.8562305 | 18.959832 | -0.5619992 | 1.1583039 | 1.5394736 | 0.5624266 | 1.4330581 | 28.38939 | 0.2838939 | 0.1037169 | 0.2642698 | 0.1334711 | 0.8665289 | 0.0878745 | 0.6604385 | 1.9476809 | 0.0029883 | 0.0224595 | 0.0662347 | 1.2014558 | 0.2503393 | 2.3699790 | 0.7400211 | 0.2964364 | 1.2014558 | 0.2545956 | -0.0282592 | 0.5191739 | 2.364624 | OK | -We can also name the corresponding group in the plot by naming them -while passing to the `summary()` function: +Provide descriptive names for clarity: ``` r summary("New version" = sim, original = sim2, obs = obs) ``` - #> Attention: some observed values are zero. They are filtered for the computation of MAPE - #> Attention: some observed values are zero. They are filtered for the computation of RME - #> Attention: some observed values are zero. They are filtered for the computation of MAPE - #> Attention: some observed values are zero. They are filtered for the computation of RME - | group | situation | variable | n_obs | mean_obs | mean_sim | r_means | sd_obs | sd_sim | CV_obs | CV_sim | R2 | SS_res | Inter | Slope | RMSE | RMSEs | RMSEu | nRMSE | rRMSE | rRMSEs | rRMSEu | pMSEs | pMSEu | Bias2 | SDSD | LCS | rbias2 | rSDSD | rLCS | MAE | FVU | MSE | EF | Bias | ABS | MAPE | RME | tSTUD | tLimit | Decision | |:---|:---|:---|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|:---| -| New version | all_situations | lai_n | 14 | 1.270476 | 1.0236829 | 80.57474 | 1.0854269 | 0.8698547 | 85.43465 | 84.97306 | 0.6923882 | 5.578510 | 0.1764799 | 0.6668389 | 0.6312408 | 0.4270089 | 0.4648960 | 49.68537 | 0.4968537 | 0.3361015 | 0.3659227 | 0.4575977 | 0.5424023 | 0.0609069 | 0.0464714 | 0.3170527 | 0.0377341 | 0.0287907 | 0.1964257 | 0.4317590 | 0.3085546 | 0.3984650 | 0.6357717 | -0.2467933 | 0.4317590 | 0.3773867 | -0.1751950 | -1.5315489 | 2.160369 | OK | -| New version | all_situations | masec_n | 18 | 4.326759 | 4.1427489 | 95.74715 | 2.7100517 | 2.9836105 | 62.63468 | 72.02007 | 0.8994510 | 16.068959 | -0.3749370 | 1.0441269 | 0.9448386 | 0.2176378 | 0.9194312 | 21.83710 | 0.2183710 | 0.0503004 | 0.2124988 | 0.0530583 | 0.9469417 | 0.0338598 | 0.0748344 | 0.8345469 | 0.0018087 | 0.0039974 | 0.0445785 | 0.5905878 | 0.1238200 | 0.8927200 | 0.8712985 | -0.1840104 | 0.5905878 | 0.1998423 | -0.1334603 | -0.8186637 | 2.109816 | OK | -| original | all_situations | lai_n | 8 | 0.762500 | 0.5993112 | 78.59820 | 0.6326306 | 0.4383225 | 82.96794 | 73.13770 | 0.1192180 | 3.019054 | 0.4168988 | 0.2392294 | 0.6143141 | 0.4788662 | 0.3847972 | 80.56578 | 0.8056578 | 0.6280213 | 0.5046521 | 0.6076416 | 0.3923584 | 0.0266306 | 0.0377556 | 0.3631029 | 0.0458037 | 0.0649385 | 0.6245253 | 0.5046413 | 1.0015919 | 0.3773818 | -0.0776372 | -0.1631888 | 0.5046413 | 0.5726006 | -0.2460595 | -0.7290203 | 2.364624 | OK | -| original | all_situations | masec_n | 10 | 3.450000 | 3.3168750 | 96.14130 | 1.9615810 | 3.2725657 | 56.85742 | 98.66412 | 0.6237332 | 39.937521 | -1.2288238 | 1.3175938 | 1.9984374 | 0.6058240 | 1.9043974 | 57.92572 | 0.5792572 | 0.1756012 | 0.5519992 | 0.0918992 | 0.9081008 | 0.0177223 | 1.7186808 | 2.6991301 | 0.0014890 | 0.1443966 | 0.2267700 | 1.7338590 | 1.1481394 | 3.9937521 | -0.1532570 | -0.1331250 | 1.7338590 | 0.5148451 | -0.1538282 | -0.2002885 | 2.262157 | OK | +| New version | all_situations | lai_n | 6 | 1.947778 | 1.570462 | 80.62838 | 1.2407801 | 0.9563566 | 63.702343 | 60.89653 | 0.4849226 | 4.861720 | 0.5250179 | 0.5367367 | 0.9001593 | 0.6463004 | 0.6265641 | 46.21468 | 0.4621468 | 0.3318142 | 0.3216815 | 0.5155017 | 0.4844983 | 0.1423674 | 0.0808967 | 0.7206064 | 0.0375260 | 0.0213232 | 0.1899413 | 0.6975894 | 0.5206137 | 0.8102867 | 0.3684171 | -0.3773161 | 0.6975894 | 0.4391500 | -0.1037853 | -1.0323533 | 2.570582 | OK | +| New version | all_situations | mafruit | 2 | 4.090000 | 5.209054 | 127.36073 | 0.3747666 | 0.6595060 | 9.162997 | 12.66076 | 1.0000000 | 3.574283 | 12.4065456 | -1.7597779 | 1.3368401 | 1.3368401 | 0.0000000 | 32.68558 | 0.3268558 | 0.3268558 | 0.0000000 | 1.0000000 | 0.0000000 | 1.2522815 | 0.0810765 | 0.9886432 | 0.0748610 | 0.0048467 | 0.0591007 | 1.1190538 | 7.6163742 | 1.7871414 | -24.4487917 | 1.1190538 | 1.1190538 | 0.2863952 | 0.2863952 | 1.5301393 | 12.706205 | OK | +| New version | all_situations | masec_n | 8 | 5.422708 | 5.199223 | 95.87870 | 3.2277449 | 3.6731078 | 59.522746 | 70.64725 | 0.8562305 | 14.182337 | -0.5109084 | 1.0530035 | 1.3314624 | 0.2748750 | 1.3027800 | 24.55346 | 0.2455346 | 0.0506896 | 0.2402453 | 0.0426199 | 0.9573801 | 0.0499459 | 0.1983481 | 1.7706190 | 0.0016985 | 0.0067452 | 0.0602133 | 0.8941075 | 0.1889905 | 1.7727921 | 0.8055306 | -0.2234858 | 0.8941075 | 0.2087232 | -0.1165992 | -0.4504803 | 2.364624 | OK | +| original | all_situations | lai_n | 6 | 1.947778 | 1.727508 | 88.69122 | 1.2407801 | 1.0519922 | 63.702343 | 60.89653 | 0.4849226 | 4.432653 | 0.5775197 | 0.5904103 | 0.8595205 | 0.5135666 | 0.6892205 | 44.12826 | 0.4412826 | 0.2636679 | 0.3538496 | 0.3570105 | 0.6429895 | 0.0485188 | 0.0356408 | 0.7926671 | 0.0127889 | 0.0093944 | 0.2089354 | 0.6060845 | 0.5380247 | 0.7387754 | 0.4241570 | -0.2202699 | 0.6060845 | 0.4168965 | -0.0141638 | -0.5928365 | 2.570582 | OK | +| original | all_situations | mafruit | 2 | 4.090000 | 5.729959 | 140.09680 | 0.3747666 | 0.7254566 | 9.162997 | 12.66076 | 1.0000000 | 6.589424 | 13.6472001 | -1.9357557 | 1.8151341 | 1.8151341 | 0.0000000 | 44.37981 | 0.4437981 | 0.4437981 | 0.0000000 | 1.0000000 | 0.0000000 | 2.6894663 | 0.1229835 | 1.0875076 | 0.1607754 | 0.0073519 | 0.0650108 | 1.6399592 | 8.6186616 | 3.2947118 | -45.9165084 | 1.6399592 | 1.6399592 | 0.4150347 | 0.4150347 | 2.1079838 | 12.706205 | OK | +| original | all_situations | masec_n | 8 | 5.422708 | 5.719145 | 105.46658 | 3.2277449 | 4.0404186 | 59.522746 | 70.64725 | 0.8562305 | 18.959832 | -0.5619992 | 1.1583039 | 1.5394736 | 0.5624266 | 1.4330581 | 28.38939 | 0.2838939 | 0.1037169 | 0.2642698 | 0.1334711 | 0.8665289 | 0.0878745 | 0.6604385 | 1.9476809 | 0.0029883 | 0.0224595 | 0.0662347 | 1.2014558 | 0.2503393 | 2.3699790 | 0.7400211 | 0.2964364 | 1.2014558 | 0.2545956 | -0.0282592 | 0.5191739 | 2.364624 | OK | + +### Selecting Specific Statistics -By default, all statistics are returned by `summary`, but you can filter -them using the `stat` argument: +By default, all available statistics are computed. Use the `stats` +argument to select specific metrics: ``` r summary( @@ -607,23 +627,23 @@ summary( | group | situation | variable | R2 | nRMSE | |:------------|:---------------|:---------|----------:|---------:| -| New version | all_situations | lai_n | 0.6923882 | 49.68537 | -| New version | all_situations | masec_n | 0.8994510 | 21.83710 | -| original | all_situations | lai_n | 0.1192180 | 80.56578 | -| original | all_situations | masec_n | 0.6237332 | 57.92572 | - -Please read the help from -[`summary.cropr_simulation()`](https://sticsrpacks.github.io/CroPlotR/reference/summary.cropr_simulation.html) -and +| New version | all_situations | lai_n | 0.4849226 | 46.21468 | +| New version | all_situations | mafruit | 1.0000000 | 32.68558 | +| New version | all_situations | masec_n | 0.8562305 | 24.55346 | +| original | all_situations | lai_n | 0.4849226 | 44.12826 | +| original | all_situations | mafruit | 1.0000000 | 44.37981 | +| original | all_situations | masec_n | 0.8562305 | 28.38939 | + +For more details about the list of available statistical criterion and +their definition, please read the help from [`predictor_assessment()`](https://sticsrpacks.github.io/CroPlotR/reference/predictor_assessment.html). -#### 2.2.3 Statistics plot +### 10.3. Visualizing Statistics -It is also possible to plot the statistics: +Plot statistical metrics for visual comparison using `plot()` on the +summary output. -In a rather obvious way, the resulting graph will take into account all -the situations simultaneously or not according to the parameter given to -`summary`. Here is an example with `all_situations = FALSE`. +**Separate plots per situation** (`all_situations = FALSE`): ``` r stats <- summary( @@ -636,9 +656,9 @@ stats <- summary( plot(stats) ``` - + -And here is an example with `all_situations = TRUE`. +**Combined plot for all situations** (`all_situations = TRUE`): ``` r stats <- summary( @@ -652,10 +672,12 @@ stats <- summary( plot(stats) ``` - + + +### Customizing Plot Layout -We can choose to plot either the group or the situation in x (and the -other is used for grouping and colouring): +Control which variable appears on the x-axis using the `xvar` parameter. +The other variable is used for grouping and color coding: ``` r stats <- summary( @@ -669,10 +691,11 @@ stats <- summary( plot(stats, xvar = "situation", title = "Situation in X") ``` - + -In the previous examples, each line corresponds to a statistical -criterion. These can also be stacked. +### Bar Chart Layouts + +**Stacked bars** (`group_bar = "stack"`): ``` r stats <- summary( @@ -686,9 +709,9 @@ stats <- summary( plot(stats, xvar = "situation", title = "Stacked columns", group_bar = "stack") ``` - + -Or put side by side. +**Side-by-side bars** (`group_bar = "dodge"`): ``` r stats <- summary( @@ -707,30 +730,19 @@ plot( ) ``` - + -To compare different versions on a single criterion, the function -produces a radar graph like the following one. +### Radar Charts -``` r -sim$`SC_Pea_2005-2006_N0`$mafruit <- - (15 / 10) * sim$`SC_Pea_2005-2006_N0`$masec_n -sim$`SC_Wheat_2005-2006_N0`$mafruit <- - (15 / 20) * sim$`SC_Wheat_2005-2006_N0`$masec_n -sim2$`IC_Wheat_Pea_2005-2006_N0`$mafruit <- - sim2$`IC_Wheat_Pea_2005-2006_N0`$masec_n -obs$`IC_Wheat_Pea_2005-2006_N0`$mafruit <- - (12 / 10) * obs$`IC_Wheat_Pea_2005-2006_N0`$masec_n -obs$`SC_Pea_2005-2006_N0`$mafruit <- - (18 / 10) * obs$`SC_Pea_2005-2006_N0`$masec_n -obs$`SC_Wheat_2005-2006_N0`$mafruit <- - (15 / 12) * obs$`SC_Wheat_2005-2006_N0`$masec_n +Compare model versions across multiple variables using a radar chart +(`type = "radar"`) for a single metric: +``` r stats <- summary( "New version" = sim, original = sim2, obs = obs, - stats = c("R2", "nRMSE"), + stats = c("nRMSE"), all_situations = TRUE ) @@ -742,80 +754,76 @@ plot( ) ``` - + + +## 11. Data Manipulation -### 2.3 Data manipulation +### Working with Standard R Packages -Observation lists can easily be handled using e.g. +Observation data can be easily manipulated using packages like [dplyr](https://CRAN.R-project.org/package=dplyr), -[tidyr](https://CRAN.R-project.org/package=tidyr) or -[tibble](https://CRAN.R-project.org/package=tibble) packages. +[tidyr](https://CRAN.R-project.org/package=tidyr), or +[tibble](https://CRAN.R-project.org/package=tibble). + +However, the `cropr_simulation` attribute on simulated data can +interfere with some operations. CroPlotR provides two helper functions +to facilitate data manipulation: + +### Converting to Data Frame -The use of these packages on simulated data as returned by CroptimizR -model wrappers is sometimes prevented by their attribute -`cropr_simulation`. To easily manipulate simulated data we thus provide -two functions for (i) binding rows of data simulated on different -situations in a single data.frame or tibble and (ii) go back to the -original (cropr) format by splitting this single data.frame or tibble. +Use `bind_rows()` to combine all situations into a single data frame: ``` r df <- bind_rows(sim) head(df) -#> situation Date lai_n masec_n Plant Dominance mafruit -#> 1 IC_Wheat_Pea_2005-2006_N0 2005-09-26 0 0 ble Principal NA -#> 2 IC_Wheat_Pea_2005-2006_N0 2005-09-27 0 0 ble Principal NA -#> 3 IC_Wheat_Pea_2005-2006_N0 2005-09-28 0 0 ble Principal NA -#> 4 IC_Wheat_Pea_2005-2006_N0 2005-09-29 0 0 ble Principal NA -#> 5 IC_Wheat_Pea_2005-2006_N0 2005-09-30 0 0 ble Principal NA -#> 6 IC_Wheat_Pea_2005-2006_N0 2005-10-01 0 0 ble Principal NA +#> situation Date lai_n masec_n mafruit Plant +#> 1 SC_Pea_2005-2006_N0 2005-09-26 0 0 0 poi +#> 2 SC_Pea_2005-2006_N0 2005-09-27 0 0 0 poi +#> 3 SC_Pea_2005-2006_N0 2005-09-28 0 0 0 poi +#> 4 SC_Pea_2005-2006_N0 2005-09-29 0 0 0 poi +#> 5 SC_Pea_2005-2006_N0 2005-09-30 0 0 0 poi +#> 6 SC_Pea_2005-2006_N0 2005-10-01 0 0 0 poi ``` -The resulting data.frame/tibble can then easily be manipulated using -standard R packages. The column `situation` contains the name of the -corresponding situation (as given in the named list `sim`). +The `situation` column identifies the source situation for each row. +This format is compatible with standard data manipulation packages. -To go back to the original format of simulated data handled by CroPlotR, -use the `split_df2sim` function: +### Converting Back to CroPlotR Format + +After manipulation, use `split_df2sim()` to restore the original +`cropr_simulation` structure: ``` r sim_new <- split_df2sim(df) lapply(sim_new, head) -#> $`IC_Wheat_Pea_2005-2006_N0` -#> Date lai_n masec_n Plant Dominance -#> 1 2005-09-26 0 0 ble Principal -#> 2 2005-09-27 0 0 ble Principal -#> 3 2005-09-28 0 0 ble Principal -#> 4 2005-09-29 0 0 ble Principal -#> 5 2005-09-30 0 0 ble Principal -#> 6 2005-10-01 0 0 ble Principal -#> #> $`SC_Pea_2005-2006_N0` -#> Date lai_n masec_n Plant mafruit -#> 1 2005-09-26 0 0 poi 0 -#> 2 2005-09-27 0 0 poi 0 -#> 3 2005-09-28 0 0 poi 0 -#> 4 2005-09-29 0 0 poi 0 -#> 5 2005-09-30 0 0 poi 0 -#> 6 2005-10-01 0 0 poi 0 +#> Date lai_n masec_n mafruit Plant +#> 1 2005-09-26 0 0 0 poi +#> 2 2005-09-27 0 0 0 poi +#> 3 2005-09-28 0 0 0 poi +#> 4 2005-09-29 0 0 0 poi +#> 5 2005-09-30 0 0 0 poi +#> 6 2005-10-01 0 0 0 poi #> #> $`SC_Wheat_2005-2006_N0` -#> Date lai_n masec_n Plant mafruit -#> 1 2005-09-26 0 0 ble 0 -#> 2 2005-09-27 0 0 ble 0 -#> 3 2005-09-28 0 0 ble 0 -#> 4 2005-09-29 0 0 ble 0 -#> 5 2005-09-30 0 0 ble 0 -#> 6 2005-10-01 0 0 ble 0 +#> Date lai_n masec_n mafruit Plant +#> 1 2005-09-26 0 0 0 ble +#> 2 2005-09-27 0 0 0 ble +#> 3 2005-09-28 0 0 0 ble +#> 4 2005-09-29 0 0 0 ble +#> 5 2005-09-30 0 0 0 ble +#> 6 2005-10-01 0 0 0 ble ``` -## 3. Tools +## 12. Integration with Other Packages -### 3.1 ggplotly +CroPlotR works seamlessly with popular R visualization packages to +enhance your plots. -The ggplotly function in plotly library makes it very easy to create -interactive graphics from a ggplot. Do not hesitate to call it with your -plot and move your mouse over the graph to discover the features of this -function. +### 12.1. Interactive Plots with plotly + +Convert any ggplot to an interactive visualization using +`plotly::ggplotly()`: ``` r library(plotly) @@ -823,13 +831,14 @@ library(plotly) ggplotly(plot(sim, obs = obs, type = "dynamic")[[1]]) ``` -### 3.2 patchwork +### 12.2. Combining Plots with patchwork -There is also the patchwork library that allows you to easily combine -several ggplot into one. +Create complex multi-panel layouts using the +[patchwork](https://CRAN.R-project.org/package=patchwork) package: ``` r library(patchwork) +#> Warning: le package 'patchwork' a Ć©tĆ© compilĆ© avec la version R 4.4.3 plot1 <- plot(sim, obs = obs, type = "scatter", var = "lai_n")[[1]] plot2 <- plot(sim, obs = obs, var = "lai_n")[[1]] @@ -839,14 +848,128 @@ plot4 <- plot(sim, obs = obs, var = "masec_n")[[1]] plot1 + plot2 + plot3 + plot4 + plot_layout(ncol = 2) ``` - + + +## 13. Data Structure + +### Understanding the `cropr_simulation` Format + +Both `sim` and `obs` objects are named lists of data frames: + +- **List names**: Correspond to situation identifiers (e.g., + crop-year-management combinations) +- **Data frames**: Store variable values for each situation, with one + row per time step and one column per simulated or observed variable. + They include a `Date` column as a time reference (at Date or POSIXct + format), and may optionally contain `Plant` and `Dominance` columns to + indicate crop names and their status (ā€œPrincipalā€ or ā€œAssociatedā€) in + intercrop datasets. + +### Simulation Data Structure + +``` r +lapply(sim, head) +#> $`SC_Pea_2005-2006_N0` +#> Date lai_n masec_n mafruit Plant +#> 1 2005-09-26 0 0 0 poi +#> 2 2005-09-27 0 0 0 poi +#> 3 2005-09-28 0 0 0 poi +#> 4 2005-09-29 0 0 0 poi +#> 5 2005-09-30 0 0 0 poi +#> 6 2005-10-01 0 0 0 poi +#> +#> $`SC_Wheat_2005-2006_N0` +#> Date lai_n masec_n mafruit Plant +#> 1 2005-09-26 0 0 0 ble +#> 2 2005-09-27 0 0 0 ble +#> 3 2005-09-28 0 0 0 ble +#> 4 2005-09-29 0 0 0 ble +#> 5 2005-09-30 0 0 0 ble +#> 6 2005-10-01 0 0 0 ble +``` + +### Observation Data Structure + +Observations follow the same structure: + +``` r +lapply(obs, head) +#> $`SC_Pea_2005-2006_N0` +#> Date mafruit masec_n lai_n Plant +#> 1 2006-03-29 NA 0.7833333 0.880000 poi +#> 2 2006-04-26 NA 3.9833333 3.613333 poi +#> 3 2006-05-15 NA 8.2066667 3.373333 poi +#> 4 2006-06-13 4.355 NA NA poi +#> 5 2006-06-14 NA 8.8333333 NA poi +#> +#> $`SC_Wheat_2005-2006_N0` +#> Date mafruit masec_n lai_n Plant +#> 1 2006-03-29 NA 1.430 1.090 ble +#> 2 2006-04-26 NA 4.405 1.775 ble +#> 3 2006-05-15 NA 7.165 0.955 ble +#> 4 2006-06-14 NA 8.575 NA ble +#> 5 2006-07-04 3.825 NA NA ble +``` + +### Creating Custom `cropr_simulation` Objects + +You can create compatible simulation objects from your own data by +adding the `cropr_simulation` class attribute to a named list of data +frames: + +``` r +sim_test <- list( + situation_1 = data.frame( + Date = as.Date("2000-01-01") + 0:9, + var1 = rnorm(10), + var2 = rnorm(10) + ), + situation_2 = data.frame( + Date = as.Date("2001-01-01") + 0:9, + var1 = rnorm(10), + var2 = rnorm(10) + ) +) + +class(sim_test) <- append(class(sim_test), "cropr_simulation") +head(sim_test) +#> $situation_1 +#> Date var1 var2 +#> 1 2000-01-01 0.17851245 0.99830079 +#> 2 2000-01-02 -0.18501293 -1.40498186 +#> 3 2000-01-03 0.99458587 -2.51209777 +#> 4 2000-01-04 1.42358872 1.49718481 +#> 5 2000-01-05 0.99588785 -1.15765880 +#> 6 2000-01-06 1.80768707 -0.38440228 +#> 7 2000-01-07 -1.57172087 -0.06107318 +#> 8 2000-01-08 1.03827066 -1.73751647 +#> 9 2000-01-09 -0.02226482 -0.31848179 +#> 10 2000-01-10 1.44859084 0.63979278 +#> +#> $situation_2 +#> Date var1 var2 +#> 1 2001-01-01 0.7242881 -2.32230396 +#> 2 2001-01-02 -1.7797979 0.57906373 +#> 3 2001-01-03 -1.1308429 0.84785651 +#> 4 2001-01-04 0.5645866 -0.33415060 +#> 5 2001-01-05 0.5719987 1.00692496 +#> 6 2001-01-06 2.0015839 -0.08801978 +#> 7 2001-01-07 -1.1901460 -0.17226188 +#> 8 2001-01-08 -1.5696923 0.26070868 +#> 9 2001-01-09 -0.2458506 0.25828618 +#> 10 2001-01-10 1.5008699 -0.14129121 +#> +#> attr(,"class") +#> [1] "list" "cropr_simulation" +``` + +## 14. Getting Help -## 4. Help +### Documentation -You can find help for the functions directly using the name of the -function followed by the class of the object you need the method for: +Access help for specific functions by specifying the class: -- plot: +**For plotting functions:** ``` r ?plot.cropr_simulation @@ -854,18 +977,19 @@ function followed by the class of the object you need the method for: ?plot.statistics ``` -- statistics: +**For statistical functions:** ``` r ?summary.cropr_simulation ``` -If you have any problem, please [fill an -issue](https://github.com/SticsRPacks/CroPlotR/issues) on Github. +### Reporting Issues + +If you encounter problems or have suggestions, please [open an +issue](https://github.com/SticsRPacks/CroPlotR/issues) on GitHub. -## 5. Citation +## 15. Citation -If you have used this package for a study that led to a publication or -report, please cite us. You can either use the citation tool from Github -if you used the last version, or use `citation("CroPlotR")` from R -otherwise. +If CroPlotR contributed to a publication or report, please cite it using +the reference corresponding to the version you used. To obtain the +correct citation, run citation(ā€œCroPlotRā€) in R. diff --git a/inst/WORDLIST b/inst/WORDLIST index fe2fae16..4006425c 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -1,8 +1,7 @@ APSIM -Analyse -Apsim CeCILL Codecov +Combi CropR CroplotR Cropr @@ -29,35 +28,38 @@ STICS Salam Stics SticsRFiles +SticsRPacks Sutcliffe USM Unwatch WIP +aes +args binded bmp bservations +btw +cff colouring -cran cropr df dplyr eps -formater +faaaast ggplot ggplotly ggplots +github heigth -https intercrop intercropping jpeg lai -lm +linetype mafruit masec nRMSE nd -outputed pMSEs pMSEu pictex @@ -76,9 +78,12 @@ sd svg tLimit tSTUD +testthat tex tibble tibbles tidyr usms wmf +xaxis +yaxis diff --git a/inst/extdata/readme_sim_obs_example.RData b/inst/extdata/readme_sim_obs_example.RData new file mode 100644 index 00000000..a14f08fe Binary files /dev/null and b/inst/extdata/readme_sim_obs_example.RData differ diff --git a/inst/extdata/stics_example_1/IC_Wheat_Pea_2005-2006_N0a.obs b/inst/extdata/stics_example_1/IC_Wheat_Pea_2005-2006_N0a.obs index 5954ca67..8cf36f65 100644 --- a/inst/extdata/stics_example_1/IC_Wheat_Pea_2005-2006_N0a.obs +++ b/inst/extdata/stics_example_1/IC_Wheat_Pea_2005-2006_N0a.obs @@ -1,26 +1,6 @@ -ian;mo;jo;jul;masec(n);lai(n);hauteur;HR(1);HR(2);AZnit(1);AZnit(2);QNplante;hauteur_sd;lai(n)_sd;masec(n)_sd;fapar;fapar_sd;tauxcouv(n);tauxcouv(n)_sd -2006;2;23;54;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.164;0.036 -2006;2;24;55;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.07;0.028;-999.99;-999.99 -2006;2;28;59;-999.99;-999.99;0.05;-999.99;-999.99;-999.99;-999.99;-999.99;0;-999.99;-999.99;0.13;0.014;0.204;0.054 -2006;3;6;65;-999.99;-999.99;0.05;-999.99;-999.99;-999.99;-999.99;-999.99;0;-999.99;-999.99;-999.99;-999.99;0.262;0.07 -2006;3;13;72;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.225;0.007;-999.99;-999.99 -2006;3;14;73;-999.99;-999.99;0.05;-999.99;-999.99;-999.99;-999.99;-999.99;0;-999.99;-999.99;-999.99;-999.99;0.328;0.062 -2006;3;20;79;-999.99;-999.99;0.05;-999.99;-999.99;-999.99;-999.99;-999.99;0;-999.99;-999.99;-999.99;-999.99;0.422;0.059 -2006;3;21;80;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.425;0.021;-999.99;-999.99 -2006;3;29;88;0.36;0.39;0.1;19.42;15.63;5.55;6.24;14.29;0;-999.99;-999.99;0.485;0.021;0.516;0.078 -2006;4;4;94;-999.99;-999.99;0.15;-999.99;-999.99;-999.99;-999.99;-999.99;0.035;-999.99;-999.99;0.66;0.071;0.686;0.09 -2006;4;12;102;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.764;0.053 -2006;4;18;108;-999.99;-999.99;0.4;-999.99;-999.99;-999.99;-999.99;-999.99;0;-999.99;-999.99;-999.99;-999.99;0.852;0.069 -2006;4;19;109;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.825;0.021;-999.99;-999.99 -2006;4;25;115;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;4;26;116;1.93;1.46;-999.99;11.62;12.52;8.22;9.77;60.14;-999.99;-999.99;-999.99;-999.99;-999.99;0.928;0.019 -2006;4;27;117;-999.99;-999.99;0.55;-999.99;-999.99;-999.99;-999.99;-999.99;0.047;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;5;3;123;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.96;0 -2006;5;4;124;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.865;0.007;-999.99;-999.99 -2006;5;12;132;-999.99;-999.99;0.6;-999.99;-999.99;-999.99;-999.99;-999.99;0;-999.99;-999.99;-999.99;-999.99;0.93;0.028 -2006;5;15;135;3.9;1.59;-999.99;-999.99;-999.99;-999.99;-999.99;73.13;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;5;17;137;-999.99;-999.99;-999.99;10.71;9.91;7.42;6.43;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;6;14;165;4.38;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;7;7;188;4.34;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;81.11;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;7;8;189;-999.99;-999.99;-999.99;7.09;8.51;16.81;7.85;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;11;29;333;-999.99;-999.99;-999.99;15.19;14.68;56.26;43.35;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +ian;mo;jo;jul;masec(n);lai(n);mafruit +2006;3;29;88;0.36;0.39;-999 +2006;4;26;116;1.93;1.46;-999 +2006;5;15;135;3.9;1.59;-999 +2006;6;14;165;4.38;0;-999 +2006;7;7;188;4.34;-999.99;2.6 diff --git a/inst/extdata/stics_example_1/IC_Wheat_Pea_2005-2006_N0a.sd b/inst/extdata/stics_example_1/IC_Wheat_Pea_2005-2006_N0a.sd new file mode 100644 index 00000000..5954ca67 --- /dev/null +++ b/inst/extdata/stics_example_1/IC_Wheat_Pea_2005-2006_N0a.sd @@ -0,0 +1,26 @@ +ian;mo;jo;jul;masec(n);lai(n);hauteur;HR(1);HR(2);AZnit(1);AZnit(2);QNplante;hauteur_sd;lai(n)_sd;masec(n)_sd;fapar;fapar_sd;tauxcouv(n);tauxcouv(n)_sd +2006;2;23;54;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.164;0.036 +2006;2;24;55;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.07;0.028;-999.99;-999.99 +2006;2;28;59;-999.99;-999.99;0.05;-999.99;-999.99;-999.99;-999.99;-999.99;0;-999.99;-999.99;0.13;0.014;0.204;0.054 +2006;3;6;65;-999.99;-999.99;0.05;-999.99;-999.99;-999.99;-999.99;-999.99;0;-999.99;-999.99;-999.99;-999.99;0.262;0.07 +2006;3;13;72;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.225;0.007;-999.99;-999.99 +2006;3;14;73;-999.99;-999.99;0.05;-999.99;-999.99;-999.99;-999.99;-999.99;0;-999.99;-999.99;-999.99;-999.99;0.328;0.062 +2006;3;20;79;-999.99;-999.99;0.05;-999.99;-999.99;-999.99;-999.99;-999.99;0;-999.99;-999.99;-999.99;-999.99;0.422;0.059 +2006;3;21;80;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.425;0.021;-999.99;-999.99 +2006;3;29;88;0.36;0.39;0.1;19.42;15.63;5.55;6.24;14.29;0;-999.99;-999.99;0.485;0.021;0.516;0.078 +2006;4;4;94;-999.99;-999.99;0.15;-999.99;-999.99;-999.99;-999.99;-999.99;0.035;-999.99;-999.99;0.66;0.071;0.686;0.09 +2006;4;12;102;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.764;0.053 +2006;4;18;108;-999.99;-999.99;0.4;-999.99;-999.99;-999.99;-999.99;-999.99;0;-999.99;-999.99;-999.99;-999.99;0.852;0.069 +2006;4;19;109;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.825;0.021;-999.99;-999.99 +2006;4;25;115;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;4;26;116;1.93;1.46;-999.99;11.62;12.52;8.22;9.77;60.14;-999.99;-999.99;-999.99;-999.99;-999.99;0.928;0.019 +2006;4;27;117;-999.99;-999.99;0.55;-999.99;-999.99;-999.99;-999.99;-999.99;0.047;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;5;3;123;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.96;0 +2006;5;4;124;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.865;0.007;-999.99;-999.99 +2006;5;12;132;-999.99;-999.99;0.6;-999.99;-999.99;-999.99;-999.99;-999.99;0;-999.99;-999.99;-999.99;-999.99;0.93;0.028 +2006;5;15;135;3.9;1.59;-999.99;-999.99;-999.99;-999.99;-999.99;73.13;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;5;17;137;-999.99;-999.99;-999.99;10.71;9.91;7.42;6.43;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;6;14;165;4.38;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;7;7;188;4.34;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;81.11;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;7;8;189;-999.99;-999.99;-999.99;7.09;8.51;16.81;7.85;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;11;29;333;-999.99;-999.99;-999.99;15.19;14.68;56.26;43.35;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 diff --git a/inst/extdata/stics_example_1/IC_Wheat_Pea_2005-2006_N0p.obs b/inst/extdata/stics_example_1/IC_Wheat_Pea_2005-2006_N0p.obs index 2b1c043e..929cfb03 100644 --- a/inst/extdata/stics_example_1/IC_Wheat_Pea_2005-2006_N0p.obs +++ b/inst/extdata/stics_example_1/IC_Wheat_Pea_2005-2006_N0p.obs @@ -1,26 +1,6 @@ -ian;mo;jo;jul;masec(n);lai(n);hauteur;HR(1);HR(2);AZnit(1);AZnit(2);QNplante;hauteur_sd;lai(n)_sd;masec(n)_sd;fapar;fapar_sd;tauxcouv(n);tauxcouv(n)_sd -2006;2;23;54;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.164;0.036 -2006;2;24;55;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.07;0.028;-999.99;-999.99 -2006;2;28;59;-999.99;-999.99;0.1;-999.99;-999.99;-999.99;-999.99;-999.99;0;-999.99;-999.99;0.13;0.014;0.204;0.054 -2006;3;6;65;-999.99;-999.99;0.13;-999.99;-999.99;-999.99;-999.99;-999.99;0.027;-999.99;-999.99;-999.99;-999.99;0.262;0.07 -2006;3;13;72;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.225;0.007;-999.99;-999.99 -2006;3;14;73;-999.99;-999.99;0.15;-999.99;-999.99;-999.99;-999.99;-999.99;0;-999.99;-999.99;-999.99;-999.99;0.328;0.062 -2006;3;20;79;-999.99;-999.99;0.19;-999.99;-999.99;-999.99;-999.99;-999.99;0.022;-999.99;-999.99;-999.99;-999.99;0.422;0.059 -2006;3;21;80;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.425;0.021;-999.99;-999.99 -2006;3;29;88;0.86;0.65;0.26;19.42;15.63;5.55;6.24;21.07;0.022;-999.99;0.191;0.485;0.021;0.516;0.078 -2006;4;4;94;-999.99;-999.99;0.32;-999.99;-999.99;-999.99;-999.99;-999.99;0.027;-999.99;-999.99;0.66;0.071;0.686;0.09 -2006;4;12;102;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.764;0.053 -2006;4;18;108;-999.99;-999.99;0.4;-999.99;-999.99;-999.99;-999.99;-999.99;0;-999.99;-999.99;-999.99;-999.99;0.852;0.069 -2006;4;19;109;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.825;0.021;-999.99;-999.99 -2006;4;25;115;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;4;26;116;2.73;1.32;-999.99;11.62;12.52;8.22;9.77;36.19;-999.99;-999.99;-999.99;-999.99;-999.99;0.928;0.019 -2006;4;27;117;-999.99;-999.99;0.55;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;5;3;123;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.96;0 -2006;5;4;124;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.865;0.007;-999.99;-999.99 -2006;5;12;132;-999.99;-999.99;0.7;-999.99;-999.99;-999.99;-999.99;-999.99;0;-999.99;-999.99;-999.99;-999.99;0.93;0.028 -2006;5;15;135;3.91;0.69;-999.99;-999.99;-999.99;-999.99;-999.99;37.33;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;5;17;137;-999.99;-999.99;-999.99;10.71;9.91;7.42;6.43;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;6;14;165;5.99;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;7;7;188;6.1;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;66.52;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;7;8;189;-999.99;-999.99;-999.99;7.09;8.51;16.81;7.85;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;11;29;333;-999.99;-999.99;-999.99;15.19;14.68;56.26;43.35;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +ian;mo;jo;jul;masec(n);lai(n);mafruit +2006;3;29;88;0.86;0.65;-999 +2006;4;26;116;2.73;1.32;-999 +2006;5;15;135;3.91;0.69;-999 +2006;6;14;165;5.99;0;-999 +2006;7;7;188;6.1;-999.99;3.1 diff --git a/inst/extdata/stics_example_1/IC_Wheat_Pea_2005-2006_N0p.sd b/inst/extdata/stics_example_1/IC_Wheat_Pea_2005-2006_N0p.sd new file mode 100644 index 00000000..2b1c043e --- /dev/null +++ b/inst/extdata/stics_example_1/IC_Wheat_Pea_2005-2006_N0p.sd @@ -0,0 +1,26 @@ +ian;mo;jo;jul;masec(n);lai(n);hauteur;HR(1);HR(2);AZnit(1);AZnit(2);QNplante;hauteur_sd;lai(n)_sd;masec(n)_sd;fapar;fapar_sd;tauxcouv(n);tauxcouv(n)_sd +2006;2;23;54;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.164;0.036 +2006;2;24;55;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.07;0.028;-999.99;-999.99 +2006;2;28;59;-999.99;-999.99;0.1;-999.99;-999.99;-999.99;-999.99;-999.99;0;-999.99;-999.99;0.13;0.014;0.204;0.054 +2006;3;6;65;-999.99;-999.99;0.13;-999.99;-999.99;-999.99;-999.99;-999.99;0.027;-999.99;-999.99;-999.99;-999.99;0.262;0.07 +2006;3;13;72;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.225;0.007;-999.99;-999.99 +2006;3;14;73;-999.99;-999.99;0.15;-999.99;-999.99;-999.99;-999.99;-999.99;0;-999.99;-999.99;-999.99;-999.99;0.328;0.062 +2006;3;20;79;-999.99;-999.99;0.19;-999.99;-999.99;-999.99;-999.99;-999.99;0.022;-999.99;-999.99;-999.99;-999.99;0.422;0.059 +2006;3;21;80;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.425;0.021;-999.99;-999.99 +2006;3;29;88;0.86;0.65;0.26;19.42;15.63;5.55;6.24;21.07;0.022;-999.99;0.191;0.485;0.021;0.516;0.078 +2006;4;4;94;-999.99;-999.99;0.32;-999.99;-999.99;-999.99;-999.99;-999.99;0.027;-999.99;-999.99;0.66;0.071;0.686;0.09 +2006;4;12;102;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.764;0.053 +2006;4;18;108;-999.99;-999.99;0.4;-999.99;-999.99;-999.99;-999.99;-999.99;0;-999.99;-999.99;-999.99;-999.99;0.852;0.069 +2006;4;19;109;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.825;0.021;-999.99;-999.99 +2006;4;25;115;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;4;26;116;2.73;1.32;-999.99;11.62;12.52;8.22;9.77;36.19;-999.99;-999.99;-999.99;-999.99;-999.99;0.928;0.019 +2006;4;27;117;-999.99;-999.99;0.55;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;5;3;123;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.96;0 +2006;5;4;124;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.865;0.007;-999.99;-999.99 +2006;5;12;132;-999.99;-999.99;0.7;-999.99;-999.99;-999.99;-999.99;-999.99;0;-999.99;-999.99;-999.99;-999.99;0.93;0.028 +2006;5;15;135;3.91;0.69;-999.99;-999.99;-999.99;-999.99;-999.99;37.33;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;5;17;137;-999.99;-999.99;-999.99;10.71;9.91;7.42;6.43;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;6;14;165;5.99;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;7;7;188;6.1;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;66.52;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;7;8;189;-999.99;-999.99;-999.99;7.09;8.51;16.81;7.85;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;11;29;333;-999.99;-999.99;-999.99;15.19;14.68;56.26;43.35;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 diff --git a/inst/extdata/stics_example_1/SC_Pea_2005-2006_N0.obs b/inst/extdata/stics_example_1/SC_Pea_2005-2006_N0.obs index ee6ba643..b0b8ef6a 100644 --- a/inst/extdata/stics_example_1/SC_Pea_2005-2006_N0.obs +++ b/inst/extdata/stics_example_1/SC_Pea_2005-2006_N0.obs @@ -1,28 +1,6 @@ -ian;mo;jo;jul;nshootconc(n);nshootconc(n)_sd;tauxcouv(n);tauxcouv(n)_sd;CNgrain;CNgrain_sd;mafruit;mafruit_sd;nfruitnou;nfruitnou_sd;QNplante;QNplante_sd;Qfix;Qfix_sd;masec(n);masec(n)_sd;fapar;fapar_sd;lai(n);lai(n)_sd;hauteur;hauteur_sd;iflos;iflos_sd;imats;imats_sd;ilaxs;ilaxs_sd;iamfs;iamfs_sd;ilevs;ilevs_sd;Nfruitnou;Nfruitnou_sd -2006;2;23;54;-999.99;-999.99;0.075;0.014;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;2;24;55;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.0233333333333333;0.006;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;2;28;59;-999.99;-999.99;0.0916666666666667;0.004;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.04;0;-999.99;-999.99;0.05;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;3;6;65;-999.99;-999.99;0.113333333333333;0.01;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.05;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;3;13;72;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.0966666666666667;0.006;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;3;14;73;-999.99;-999.99;0.18;0.013;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.05;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;3;20;79;-999.99;-999.99;0.301666666666667;0.028;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.05;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;3;21;80;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.156666666666667;0.023;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;3;29;88;36.53;1.909;0.481666666666667;0.04;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.783333333333333;0.05;0.306666666666667;0.012;0.88;0.096;0.1;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;453;0;-999.99;-999.99;-999.99;-999.99 -2006;4;4;94;-999.99;-999.99;0.748333333333333;0.056;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.543333333333333;0.025;-999.99;-999.99;0.15;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;4;12;102;-999.99;-999.99;0.896666666666667;0.074;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;4;18;108;-999.99;-999.99;0.976666666666667;0.015;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.366666666666667;0.029;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;4;19;109;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.85;0.017;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;4;25;115;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;4;26;116;35.8333333333333;1.296;0.988333333333333;0.004;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;3.98333333333333;0.475;-999.99;-999.99;3.61333333333333;0.34;-999.99;-999.99;481;0;-999.99;-999.99;481;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;4;27;117;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.561666666666667;0.038;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;5;3;123;-999.99;-999.99;0.966666666666667;0.006;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;5;4;124;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.903333333333333;0.012;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;5;12;132;-999.99;-999.99;0.98;0.01;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.633333333333333;0.026;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;5;15;135;21.9733333333333;0.23;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;8.20666666666667;0.155;-999.99;-999.99;3.37333333333333;0.093;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;5;17;137;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;6;13;164;-999.99;-999.99;-999.99;-999.99;2.95183333333333;0.051;4.355;0.79;-999.99;-999.99;176.995;30.456;116.916666666667;29.838;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;529;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;6;14;165;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;8.83333333333333;1.649;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;7;4;185;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;7;7;188;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;7;8;189;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;11;29;333;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +ian;mo;jo;jul;mafruit;masec(n);lai(n) +2006;3;29;88;-999.99;0.783333333;0.88 +2006;4;26;116;-999.99;3.983333333;3.613333333 +2006;5;15;135;-999.99;8.206666667;3.373333333 +2006;6;13;164;4.355;-999.99;-999.99 +2006;6;14;165;-999.99;8.833333333;-999.99 \ No newline at end of file diff --git a/inst/extdata/stics_example_1/SC_Pea_2005-2006_N0.sd b/inst/extdata/stics_example_1/SC_Pea_2005-2006_N0.sd new file mode 100644 index 00000000..ee6ba643 --- /dev/null +++ b/inst/extdata/stics_example_1/SC_Pea_2005-2006_N0.sd @@ -0,0 +1,28 @@ +ian;mo;jo;jul;nshootconc(n);nshootconc(n)_sd;tauxcouv(n);tauxcouv(n)_sd;CNgrain;CNgrain_sd;mafruit;mafruit_sd;nfruitnou;nfruitnou_sd;QNplante;QNplante_sd;Qfix;Qfix_sd;masec(n);masec(n)_sd;fapar;fapar_sd;lai(n);lai(n)_sd;hauteur;hauteur_sd;iflos;iflos_sd;imats;imats_sd;ilaxs;ilaxs_sd;iamfs;iamfs_sd;ilevs;ilevs_sd;Nfruitnou;Nfruitnou_sd +2006;2;23;54;-999.99;-999.99;0.075;0.014;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;2;24;55;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.0233333333333333;0.006;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;2;28;59;-999.99;-999.99;0.0916666666666667;0.004;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.04;0;-999.99;-999.99;0.05;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;3;6;65;-999.99;-999.99;0.113333333333333;0.01;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.05;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;3;13;72;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.0966666666666667;0.006;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;3;14;73;-999.99;-999.99;0.18;0.013;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.05;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;3;20;79;-999.99;-999.99;0.301666666666667;0.028;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.05;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;3;21;80;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.156666666666667;0.023;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;3;29;88;36.53;1.909;0.481666666666667;0.04;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.783333333333333;0.05;0.306666666666667;0.012;0.88;0.096;0.1;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;453;0;-999.99;-999.99;-999.99;-999.99 +2006;4;4;94;-999.99;-999.99;0.748333333333333;0.056;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.543333333333333;0.025;-999.99;-999.99;0.15;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;4;12;102;-999.99;-999.99;0.896666666666667;0.074;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;4;18;108;-999.99;-999.99;0.976666666666667;0.015;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.366666666666667;0.029;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;4;19;109;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.85;0.017;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;4;25;115;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;4;26;116;35.8333333333333;1.296;0.988333333333333;0.004;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;3.98333333333333;0.475;-999.99;-999.99;3.61333333333333;0.34;-999.99;-999.99;481;0;-999.99;-999.99;481;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;4;27;117;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.561666666666667;0.038;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;5;3;123;-999.99;-999.99;0.966666666666667;0.006;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;5;4;124;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.903333333333333;0.012;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;5;12;132;-999.99;-999.99;0.98;0.01;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.633333333333333;0.026;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;5;15;135;21.9733333333333;0.23;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;8.20666666666667;0.155;-999.99;-999.99;3.37333333333333;0.093;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;5;17;137;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;6;13;164;-999.99;-999.99;-999.99;-999.99;2.95183333333333;0.051;4.355;0.79;-999.99;-999.99;176.995;30.456;116.916666666667;29.838;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;529;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;6;14;165;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;8.83333333333333;1.649;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;7;4;185;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;7;7;188;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;7;8;189;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;11;29;333;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 diff --git a/inst/extdata/stics_example_1/SC_Wheat_2005-2006_N0.obs b/inst/extdata/stics_example_1/SC_Wheat_2005-2006_N0.obs index 6b730dce..74c8d565 100644 --- a/inst/extdata/stics_example_1/SC_Wheat_2005-2006_N0.obs +++ b/inst/extdata/stics_example_1/SC_Wheat_2005-2006_N0.obs @@ -1,28 +1,6 @@ -ian;mo;jo;jul;ngrain(n);ngrain(n)_sd;nshootconc(n);nshootconc(n)_sd;tauxcouv(n);tauxcouv(n)_sd;CNgrain;CNgrain_sd;mafruit;mafruit_sd;nfruitnou;nfruitnou_sd;QNplante;QNplante_sd;Qfix;Qfix_sd;masec(n);masec(n)_sd;fapar;fapar_sd;lai(n);lai(n)_sd;hauteur;hauteur_sd;iflos;iflos_sd;imats;imats_sd;ilaxs;ilaxs_sd;iamfs;iamfs_sd;ilevs;ilevs_sd;Nfruitnou;Nfruitnou_sd -2006;2;23;54;-999.99;-999.99;-999.99;-999.99;0.3225;0.019;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;2;24;55;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.115;0.007;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;2;28;59;-999.99;-999.99;-999.99;-999.99;0.345;0.031;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.2;0.028;-999.99;-999.99;0.1;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;3;6;65;-999.99;-999.99;-999.99;-999.99;0.4075;0.01;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.125;0.029;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;3;13;72;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.275;0.021;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;3;14;73;-999.99;-999.99;-999.99;-999.99;0.4625;0.043;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.1375;0.025;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;3;20;79;-999.99;-999.99;-999.99;-999.99;0.545;0.034;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.1875;0.025;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;3;21;80;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.49;0.014;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;3;29;88;-999.99;-999.99;20.65;1.768;0.5925;0.059;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;1.43;0.085;0.605;0.021;1.09;0.085;0.25;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;453;0;-999.99;-999.99;-999.99;-999.99 -2006;4;4;94;-999.99;-999.99;-999.99;-999.99;0.59;0.048;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.635;0.007;-999.99;-999.99;0.3125;0.025;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;4;12;102;-999.99;-999.99;-999.99;-999.99;0.5675;0.021;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;4;18;108;-999.99;-999.99;-999.99;-999.99;0.5675;0.033;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.425;0.035;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;4;19;109;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.72;0.014;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;4;25;115;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;4;26;116;-999.99;-999.99;11.2;0.99;0.595;0.025;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;4.405;0.375;-999.99;-999.99;1.775;0.148;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;4;27;117;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.5775;0.021;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;5;3;123;-999.99;-999.99;-999.99;-999.99;0.605;0.035;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;5;4;124;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.755;0.007;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;5;12;132;-999.99;-999.99;-999.99;-999.99;0.62;0.014;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.7;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;5;15;135;-999.99;-999.99;7.85;0.636;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;7.165;0.304;-999.99;-999.99;0.955;0.219;-999.99;-999.99;500;0;-999.99;-999.99;500;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;5;17;137;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;6;13;164;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;6;14;165;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;8.575;0.332;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;7;4;185;54.66;4.378;-999.99;-999.99;-999.99;-999.99;1.42925;0.046;3.825;0.263;-999.99;-999.99;77;6.603;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;550;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;7;7;188;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;7;8;189;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 -2006;11;29;333;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +ian;mo;jo;jul;mafruit;masec(n);lai(n) +2006;3;29;88;-999.99;1.43;1.09 +2006;4;26;116;-999.99;4.405;1.775 +2006;5;15;135;-999.99;7.165;0.955 +2006;6;14;165;-999.99;8.575;-999.99 +2006;7;4;185;3.825;-999.99;-999.99 diff --git a/inst/extdata/stics_example_1/SC_Wheat_2005-2006_N0.sd b/inst/extdata/stics_example_1/SC_Wheat_2005-2006_N0.sd new file mode 100644 index 00000000..6b730dce --- /dev/null +++ b/inst/extdata/stics_example_1/SC_Wheat_2005-2006_N0.sd @@ -0,0 +1,28 @@ +ian;mo;jo;jul;ngrain(n);ngrain(n)_sd;nshootconc(n);nshootconc(n)_sd;tauxcouv(n);tauxcouv(n)_sd;CNgrain;CNgrain_sd;mafruit;mafruit_sd;nfruitnou;nfruitnou_sd;QNplante;QNplante_sd;Qfix;Qfix_sd;masec(n);masec(n)_sd;fapar;fapar_sd;lai(n);lai(n)_sd;hauteur;hauteur_sd;iflos;iflos_sd;imats;imats_sd;ilaxs;ilaxs_sd;iamfs;iamfs_sd;ilevs;ilevs_sd;Nfruitnou;Nfruitnou_sd +2006;2;23;54;-999.99;-999.99;-999.99;-999.99;0.3225;0.019;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;2;24;55;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.115;0.007;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;2;28;59;-999.99;-999.99;-999.99;-999.99;0.345;0.031;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.2;0.028;-999.99;-999.99;0.1;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;3;6;65;-999.99;-999.99;-999.99;-999.99;0.4075;0.01;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.125;0.029;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;3;13;72;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.275;0.021;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;3;14;73;-999.99;-999.99;-999.99;-999.99;0.4625;0.043;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.1375;0.025;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;3;20;79;-999.99;-999.99;-999.99;-999.99;0.545;0.034;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.1875;0.025;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;3;21;80;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.49;0.014;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;3;29;88;-999.99;-999.99;20.65;1.768;0.5925;0.059;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;1.43;0.085;0.605;0.021;1.09;0.085;0.25;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;453;0;-999.99;-999.99;-999.99;-999.99 +2006;4;4;94;-999.99;-999.99;-999.99;-999.99;0.59;0.048;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.635;0.007;-999.99;-999.99;0.3125;0.025;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;4;12;102;-999.99;-999.99;-999.99;-999.99;0.5675;0.021;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;4;18;108;-999.99;-999.99;-999.99;-999.99;0.5675;0.033;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.425;0.035;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;4;19;109;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.72;0.014;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;4;25;115;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;4;26;116;-999.99;-999.99;11.2;0.99;0.595;0.025;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;4.405;0.375;-999.99;-999.99;1.775;0.148;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;4;27;117;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.5775;0.021;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;5;3;123;-999.99;-999.99;-999.99;-999.99;0.605;0.035;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;5;4;124;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.755;0.007;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;5;12;132;-999.99;-999.99;-999.99;-999.99;0.62;0.014;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;0.7;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;5;15;135;-999.99;-999.99;7.85;0.636;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;7.165;0.304;-999.99;-999.99;0.955;0.219;-999.99;-999.99;500;0;-999.99;-999.99;500;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;5;17;137;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;6;13;164;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;6;14;165;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;8.575;0.332;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;7;4;185;54.66;4.378;-999.99;-999.99;-999.99;-999.99;1.42925;0.046;3.825;0.263;-999.99;-999.99;77;6.603;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;550;0;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;7;7;188;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;7;8;189;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 +2006;11;29;333;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99;-999.99 diff --git a/inst/extdata/stics_example_1/mod_sSC_Pea_2005-2006_N0.sti b/inst/extdata/stics_example_1/mod_sSC_Pea_2005-2006_N0.sti index 4c3e3290..7b9a4650 100644 --- a/inst/extdata/stics_example_1/mod_sSC_Pea_2005-2006_N0.sti +++ b/inst/extdata/stics_example_1/mod_sSC_Pea_2005-2006_N0.sti @@ -1,311 +1,311 @@ -ian;mo;jo;jul;lai(n);masec(n) -2005; 9;26;269; 0.00000; 0.00000 -2005; 9;27;270; 0.00000; 0.00000 -2005; 9;28;271; 0.00000; 0.00000 -2005; 9;29;272; 0.00000; 0.00000 -2005; 9;30;273; 0.00000; 0.00000 -2005;10; 1;274; 0.00000; 0.00000 -2005;10; 2;275; 0.00000; 0.00000 -2005;10; 3;276; 0.00000; 0.00000 -2005;10; 4;277; 0.00000; 0.00000 -2005;10; 5;278; 0.00000; 0.00000 -2005;10; 6;279; 0.00000; 0.00000 -2005;10; 7;280; 0.00000; 0.00000 -2005;10; 8;281; 0.00000; 0.00000 -2005;10; 9;282; 0.00000; 0.00000 -2005;10;10;283; 0.00000; 0.00000 -2005;10;11;284; 0.00000; 0.00000 -2005;10;12;285; 0.00000; 0.00000 -2005;10;13;286; 0.00000; 0.00000 -2005;10;14;287; 0.00000; 0.00000 -2005;10;15;288; 0.00000; 0.00000 -2005;10;16;289; 0.00000; 0.00000 -2005;10;17;290; 0.00000; 0.00000 -2005;10;18;291; 0.00000; 0.00000 -2005;10;19;292; 0.00000; 0.00000 -2005;10;20;293; 0.00000; 0.00000 -2005;10;21;294; 0.00000; 0.00000 -2005;10;22;295; 0.00000; 0.00000 -2005;10;23;296; 0.00000; 0.00000 -2005;10;24;297; 0.00000; 0.00000 -2005;10;25;298; 0.00000; 0.00000 -2005;10;26;299; 0.00000; 0.00000 -2005;10;27;300; 0.00000; 0.00000 -2005;10;28;301; 0.00000; 0.00000 -2005;10;29;302; 0.00000; 0.00000 -2005;10;30;303; 0.00000; 0.00000 -2005;10;31;304; 0.00000; 0.00000 -2005;11; 1;305; 0.00000; 0.00000 -2005;11; 2;306; 0.00000; 0.00000 -2005;11; 3;307; 0.00000; 0.00000 -2005;11; 4;308; 0.00000; 0.00000 -2005;11; 5;309; 0.00000; 0.00000 -2005;11; 6;310; 0.00000; 0.00000 -2005;11; 7;311; 0.00000; 0.00000 -2005;11; 8;312; 0.00000; 0.00000 -2005;11; 9;313; 0.00000; 0.00000 -2005;11;10;314; 0.00000; 0.00000 -2005;11;11;315; 0.00000; 0.00000 -2005;11;12;316; 0.00000; 0.00000 -2005;11;13;317; 0.00000; 0.00000 -2005;11;14;318; 0.00000; 0.00000 -2005;11;15;319; 0.00000; 0.00000 -2005;11;16;320; 0.00000; 0.00000 -2005;11;17;321; 0.00000; 0.00000 -2005;11;18;322; 0.00000; 0.00000 -2005;11;19;323; 0.00000; 0.00000 -2005;11;20;324; 0.00000; 0.00000 -2005;11;21;325; 0.00000; 0.00000 -2005;11;22;326; 0.00000; 0.00000 -2005;11;23;327; 0.00000; 0.00000 -2005;11;24;328; 0.00000; 0.00000 -2005;11;25;329; 0.00000; 0.00000 -2005;11;26;330; 0.00000; 0.00000 -2005;11;27;331; 0.00000; 0.00000 -2005;11;28;332; 0.00000; 0.00000 -2005;11;29;333; 0.00000; 0.00000 -2005;11;30;334; 0.00000; 0.00000 -2005;12; 1;335; 0.00000; 0.00000 -2005;12; 2;336; 0.00000; 0.00000 -2005;12; 3;337; 0.00000; 0.00000 -2005;12; 4;338; 0.00000; 0.00000 -2005;12; 5;339; 0.00000; 0.00000 -2005;12; 6;340; 0.00000; 0.00000 -2005;12; 7;341; 0.00000; 0.00000 -2005;12; 8;342; 0.00000; 0.00000 -2005;12; 9;343; 0.00000; 0.00000 -2005;12;10;344; 0.00000; 0.00000 -2005;12;11;345; 0.00000; 0.00000 -2005;12;12;346; 0.00000; 0.00000 -2005;12;13;347; 0.00000; 0.00000 -2005;12;14;348; 0.00000; 0.00000 -2005;12;15;349; 0.00000; 0.00000 -2005;12;16;350; 0.00000; 0.00000 -2005;12;17;351; 0.00001; 0.00042 -2005;12;18;352; 0.00008; 0.00173 -2005;12;19;353; 0.00009; 0.00196 -2005;12;20;354; 0.00010; 0.00210 -2005;12;21;355; 0.00010; 0.00217 -2005;12;22;356; 0.00010; 0.00222 -2005;12;23;357; 0.00010; 0.00222 -2005;12;24;358; 0.00010; 0.00224 -2005;12;25;359; 0.00012; 0.00240 -2005;12;26;360; 0.00012; 0.00240 -2005;12;27;361; 0.00013; 0.00245 -2005;12;28;362; 0.00013; 0.00246 -2005;12;29;363; 0.00013; 0.00258 -2005;12;30;364; 0.00013; 0.00259 -2005;12;31;365; 0.00017; 0.00284 -2006; 1; 1; 1; 0.00025; 0.00360 -2006; 1; 2; 2; 0.00033; 0.00400 -2006; 1; 3; 3; 0.00041; 0.00425 -2006; 1; 4; 4; 0.00047; 0.00477 -2006; 1; 5; 5; 0.00053; 0.00512 -2006; 1; 6; 6; 0.00056; 0.00530 -2006; 1; 7; 7; 0.00061; 0.00550 -2006; 1; 8; 8; 0.00072; 0.00633 -2006; 1; 9; 9; 0.00088; 0.00690 -2006; 1;10; 10; 0.00102; 0.00760 -2006; 1;11; 11; 0.00115; 0.00802 -2006; 1;12; 12; 0.00117; 0.00824 -2006; 1;13; 13; 0.00131; 0.00942 -2006; 1;14; 14; 0.00143; 0.01030 -2006; 1;15; 15; 0.00161; 0.01152 -2006; 1;16; 16; 0.00171; 0.01191 -2006; 1;17; 17; 0.00184; 0.01251 -2006; 1;18; 18; 0.00202; 0.01291 -2006; 1;19; 19; 0.00228; 0.01384 -2006; 1;20; 20; 0.00261; 0.01475 -2006; 1;21; 21; 0.00282; 0.01535 -2006; 1;22; 22; 0.00316; 0.01698 -2006; 1;23; 23; 0.00336; 0.01816 -2006; 1;24; 24; 0.00348; 0.01886 -2006; 1;25; 25; 0.00369; 0.01992 -2006; 1;26; 26; 0.00404; 0.02084 -2006; 1;27; 27; 0.00404; 0.02084 -2006; 1;28; 28; 0.00418; 0.02112 -2006; 1;29; 29; 0.00418; 0.02113 -2006; 1;30; 30; 0.00418; 0.02113 -2006; 1;31; 31; 0.00431; 0.02125 -2006; 2; 1; 32; 0.00454; 0.02161 -2006; 2; 2; 33; 0.00492; 0.02266 -2006; 2; 3; 34; 0.00535; 0.02297 -2006; 2; 4; 35; 0.00542; 0.02303 -2006; 2; 5; 36; 0.00549; 0.02321 -2006; 2; 6; 37; 0.00556; 0.02351 -2006; 2; 7; 38; 0.00568; 0.02394 -2006; 2; 8; 39; 0.00591; 0.02443 -2006; 2; 9; 40; 0.00598; 0.02458 -2006; 2;10; 41; 0.00638; 0.02610 -2006; 2;11; 42; 0.00667; 0.02727 -2006; 2;12; 43; 0.00683; 0.02797 -2006; 2;13; 44; 0.00701; 0.02865 -2006; 2;14; 45; 0.00762; 0.02972 -2006; 2;15; 46; 0.00810; 0.03029 -2006; 2;16; 47; 0.00871; 0.03096 -2006; 2;17; 48; 0.00986; 0.03311 -2006; 2;18; 49; 0.01113; 0.03583 -2006; 2;19; 50; 0.01245; 0.03764 -2006; 2;20; 51; 0.01392; 0.03999 -2006; 2;21; 52; 0.01547; 0.04181 -2006; 2;22; 53; 0.01673; 0.04307 -2006; 2;23; 54; 0.01760; 0.04418 -2006; 2;24; 55; 0.01871; 0.04593 -2006; 2;25; 56; 0.01980; 0.04794 -2006; 2;26; 57; 0.02060; 0.04887 -2006; 2;27; 58; 0.02208; 0.04986 -2006; 2;28; 59; 0.02279; 0.05080 -2006; 3; 1; 60; 0.02341; 0.05153 -2006; 3; 2; 61; 0.02516; 0.05323 -2006; 3; 3; 62; 0.02704; 0.05479 -2006; 3; 4; 63; 0.03039; 0.05665 -2006; 3; 5; 64; 0.03408; 0.05827 -2006; 3; 6; 65; 0.03512; 0.05901 -2006; 3; 7; 66; 0.03741; 0.06050 -2006; 3; 8; 67; 0.04027; 0.06165 -2006; 3; 9; 68; 0.04500; 0.06282 -2006; 3;10; 69; 0.05126; 0.06401 -2006; 3;11; 70; 0.05544; 0.06629 -2006; 3;12; 71; 0.06002; 0.06779 -2006; 3;13; 72; 0.06495; 0.07272 -2006; 3;14; 73; 0.06826; 0.07638 -2006; 3;15; 74; 0.07352; 0.08090 -2006; 3;16; 75; 0.08089; 0.08693 -2006; 3;17; 76; 0.08925; 0.09263 -2006; 3;18; 77; 0.09879; 0.09581 -2006; 3;19; 78; 0.11090; 0.10256 -2006; 3;20; 79; 0.12583; 0.11136 -2006; 3;21; 80; 0.14622; 0.12031 -2006; 3;22; 81; 0.16874; 0.12632 -2006; 3;23; 82; 0.18884; 0.13469 -2006; 3;24; 83; 0.21010; 0.14517 -2006; 3;25; 84; 0.23791; 0.15933 -2006; 3;26; 85; 0.27384; 0.17273 -2006; 3;27; 86; 0.30897; 0.18447 -2006; 3;28; 87; 0.34852; 0.19795 -2006; 3;29; 88; 0.37890; 0.26007 -2006; 3;30; 89; 0.40955; 0.30981 -2006; 3;31; 90; 0.44650; 0.37561 -2006; 4; 1; 91; 0.49002; 0.40455 -2006; 4; 2; 92; 0.52478; 0.46334 -2006; 4; 3; 93; 0.55899; 0.51635 -2006; 4; 4; 94; 0.59566; 0.59556 -2006; 4; 5; 95; 0.62886; 0.65580 -2006; 4; 6; 96; 0.67018; 0.74671 -2006; 4; 7; 97; 0.70247; 0.83206 -2006; 4; 8; 98; 0.73877; 0.90341 -2006; 4; 9; 99; 0.78180; 0.96334 -2006; 4;10;100; 0.82826; 1.02264 -2006; 4;11;101; 0.85707; 1.11006 -2006; 4;12;102; 0.88408; 1.16831 -2006; 4;13;103; 0.91521; 1.25757 -2006; 4;14;104; 0.95867; 1.36611 -2006; 4;15;105; 1.00935; 1.42550 -2006; 4;16;106; 1.06923; 1.52144 -2006; 4;17;107; 1.12725; 1.61533 -2006; 4;18;108; 1.18169; 1.69524 -2006; 4;19;109; 1.23707; 1.84083 -2006; 4;20;110; 1.29263; 1.99168 -2006; 4;21;111; 1.36537; 2.14525 -2006; 4;22;112; 1.44140; 2.30071 -2006; 4;23;113; 1.53157; 2.43086 -2006; 4;24;114; 1.61146; 2.56754 -2006; 4;25;115; 1.69561; 2.65385 -2006; 4;26;116; 1.76576; 2.80425 -2006; 4;27;117; 1.85240; 2.87346 -2006; 4;28;118; 1.92520; 2.99206 -2006; 4;29;119; 1.99352; 3.15279 -2006; 4;30;120; 2.06303; 3.33858 -2006; 5; 1;121; 2.11982; 3.50388 -2006; 5; 2;122; 2.18794; 3.67864 -2006; 5; 3;123; 2.27463; 3.85046 -2006; 5; 4;124; 2.36732; 4.01157 -2006; 5; 5;125; 2.46143; 4.10349 -2006; 5; 6;126; 2.54495; 4.19761 -2006; 5; 7;127; 2.62740; 4.32098 -2006; 5; 8;128; 2.70919; 4.38850 -2006; 5; 9;129; 2.75569; 4.54176 -2006; 5;10;130; 2.80669; 4.70341 -2006; 5;11;131; 2.87770; 4.90583 -2006; 5;12;132; 2.93390; 5.01960 -2006; 5;13;133; 3.01173; 5.12228 -2006; 5;14;134; 3.07949; 5.28986 -2006; 5;15;135; 3.07125; 5.43864 -2006; 5;16;136; 3.05854; 5.60000 -2006; 5;17;137; 3.05018; 5.75348 -2006; 5;18;138; 3.02852; 5.79221 -2006; 5;19;139; 2.99319; 5.90628 -2006; 5;20;140; 2.95057; 6.03511 -2006; 5;21;141; 2.92930; 6.18094 -2006; 5;22;142; 2.86556; 6.25036 -2006; 5;23;143; 2.79087; 6.34040 -2006; 5;24;144; 2.76045; 6.50081 -2006; 5;25;145; 2.69261; 6.65962 -2006; 5;26;146; 2.64903; 6.78363 -2006; 5;27;147; 2.57992; 6.94131 -2006; 5;28;148; 2.50965; 7.09532 -2006; 5;29;149; 2.46817; 7.19468 -2006; 5;30;150; 2.39914; 7.32794 -2006; 5;31;151; 2.35601; 7.46571 -2006; 6; 1;152; 2.28017; 7.61736 -2006; 6; 2;153; 2.22116; 7.75954 -2006; 6; 3;154; 2.17737; 7.91287 -2006; 6; 4;155; 2.06625; 8.06134 -2006; 6; 5;156; 2.00808; 8.20937 -2006; 6; 6;157; 1.89814; 8.34763 -2006; 6; 7;158; 1.84196; 8.47538 -2006; 6; 8;159; 1.69261; 8.58604 -2006; 6; 9;160; 1.60238; 8.68368 -2006; 6;10;161; 1.43792; 8.76381 -2006; 6;11;162; 1.36708; 8.84445 -2006; 6;12;163; 1.28009; 8.91410 -2006; 6;13;164; 1.13727; 8.97459 -2006; 6;14;165; 1.06662; 9.02721 -2006; 6;15;166; 0.00000; 9.02721 -2006; 6;16;167; 0.00000; 9.02721 -2006; 6;17;168; 0.00000; 9.02721 -2006; 6;18;169; 0.00000; 9.02721 -2006; 6;19;170; 0.00000; 9.02721 -2006; 6;20;171; 0.00000; 9.02721 -2006; 6;21;172; 0.00000; 9.02721 -2006; 6;22;173; 0.00000; 9.02721 -2006; 6;23;174; 0.00000; 9.02721 -2006; 6;24;175; 0.00000; 9.02721 -2006; 6;25;176; 0.00000; 9.02721 -2006; 6;26;177; 0.00000; 9.02721 -2006; 6;27;178; 0.00000; 9.02721 -2006; 6;28;179; 0.00000; 9.02721 -2006; 6;29;180; 0.00000; 9.02721 -2006; 6;30;181; 0.00000; 9.02721 -2006; 7; 1;182; 0.00000; 9.02721 -2006; 7; 2;183; 0.00000; 9.02721 -2006; 7; 3;184; 0.00000; 9.02721 -2006; 7; 4;185; 0.00000; 9.02721 -2006; 7; 5;186; 0.00000; 9.02721 -2006; 7; 6;187; 0.00000; 9.02721 -2006; 7; 7;188; 0.00000; 9.02721 -2006; 7; 8;189; 0.00000; 9.02721 -2006; 7; 9;190; 0.00000; 9.02721 -2006; 7;10;191; 0.00000; 9.02721 -2006; 7;11;192; 0.00000; 9.02721 -2006; 7;12;193; 0.00000; 9.02721 -2006; 7;13;194; 0.00000; 9.02721 -2006; 7;14;195; 0.00000; 9.02721 -2006; 7;15;196; 0.00000; 9.02721 -2006; 7;16;197; 0.00000; 9.02721 -2006; 7;17;198; 0.00000; 9.02721 -2006; 7;18;199; 0.00000; 9.02721 -2006; 7;19;200; 0.00000; 9.02721 -2006; 7;20;201; 0.00000; 9.02721 -2006; 7;21;202; 0.00000; 9.02721 -2006; 7;22;203; 0.00000; 9.02721 -2006; 7;23;204; 0.00000; 9.02721 -2006; 7;24;205; 0.00000; 9.02721 -2006; 7;25;206; 0.00000; 9.02721 -2006; 7;26;207; 0.00000; 9.02721 -2006; 7;27;208; 0.00000; 9.02721 -2006; 7;28;209; 0.00000; 9.02721 -2006; 7;29;210; 0.00000; 9.02721 -2006; 7;30;211; 0.00000; 9.02721 -2006; 7;31;212; 0.00000; 9.02721 -2006; 8; 1;213; 0.00000; 9.02721 +ian;mo;jo;jul;lai(n);masec(n);mafruit +2005;9;26;269;0;0;0 +2005;9;27;270;0;0;0 +2005;9;28;271;0;0;0 +2005;9;29;272;0;0;0 +2005;9;30;273;0;0;0 +2005;10;1;274;0;0;0 +2005;10;2;275;0;0;0 +2005;10;3;276;0;0;0 +2005;10;4;277;0;0;0 +2005;10;5;278;0;0;0 +2005;10;6;279;0;0;0 +2005;10;7;280;0;0;0 +2005;10;8;281;0;0;0 +2005;10;9;282;0;0;0 +2005;10;10;283;0;0;0 +2005;10;11;284;0;0;0 +2005;10;12;285;0;0;0 +2005;10;13;286;0;0;0 +2005;10;14;287;0;0;0 +2005;10;15;288;0;0;0 +2005;10;16;289;0;0;0 +2005;10;17;290;0;0;0 +2005;10;18;291;0;0;0 +2005;10;19;292;0;0;0 +2005;10;20;293;0;0;0 +2005;10;21;294;0;0;0 +2005;10;22;295;0;0;0 +2005;10;23;296;0;0;0 +2005;10;24;297;0;0;0 +2005;10;25;298;0;0;0 +2005;10;26;299;0;0;0 +2005;10;27;300;0;0;0 +2005;10;28;301;0;0;0 +2005;10;29;302;0;0;0 +2005;10;30;303;0;0;0 +2005;10;31;304;0;0;0 +2005;11;1;305;0;0;0 +2005;11;2;306;0;0;0 +2005;11;3;307;0;0;0 +2005;11;4;308;0;0;0 +2005;11;5;309;0;0;0 +2005;11;6;310;0;0;0 +2005;11;7;311;0;0;0 +2005;11;8;312;0;0;0 +2005;11;9;313;0;0;0 +2005;11;10;314;0;0;0 +2005;11;11;315;0;0;0 +2005;11;12;316;0;0;0 +2005;11;13;317;0;0;0 +2005;11;14;318;0;0;0 +2005;11;15;319;0;0;0 +2005;11;16;320;0;0;0 +2005;11;17;321;0;0;0 +2005;11;18;322;0;0;0 +2005;11;19;323;0;0;0 +2005;11;20;324;0;0;0 +2005;11;21;325;0;0;0 +2005;11;22;326;0;0;0 +2005;11;23;327;0;0;0 +2005;11;24;328;0;0;0 +2005;11;25;329;0;0;0 +2005;11;26;330;0;0;0 +2005;11;27;331;0;0;0 +2005;11;28;332;0;0;0 +2005;11;29;333;0;0;0 +2005;11;30;334;0;0;0 +2005;12;1;335;0;0;0 +2005;12;2;336;0;0;0 +2005;12;3;337;0;0;0 +2005;12;4;338;0;0;0 +2005;12;5;339;0;0;0 +2005;12;6;340;0;0;0 +2005;12;7;341;0;0;0 +2005;12;8;342;0;0;0 +2005;12;9;343;0;0;0 +2005;12;10;344;0;0;0 +2005;12;11;345;0;0;0 +2005;12;12;346;0;0;0 +2005;12;13;347;0;0;0 +2005;12;14;348;0;0;0 +2005;12;15;349;0;0;0 +2005;12;16;350;0;0;0 +2005;12;17;351;0.00001;0.00042;0 +2005;12;18;352;0.00008;0.00173;0 +2005;12;19;353;0.00009;0.00196;0 +2005;12;20;354;0.0001;0.0021;0 +2005;12;21;355;0.0001;0.00217;0 +2005;12;22;356;0.0001;0.00222;0 +2005;12;23;357;0.0001;0.00222;0 +2005;12;24;358;0.0001;0.00224;0 +2005;12;25;359;0.00012;0.0024;0 +2005;12;26;360;0.00012;0.0024;0 +2005;12;27;361;0.00013;0.00245;0 +2005;12;28;362;0.00013;0.00246;0 +2005;12;29;363;0.00013;0.00258;0 +2005;12;30;364;0.00013;0.00259;0 +2005;12;31;365;0.00017;0.00284;0 +2006;1;1;1;0.00025;0.0036;0 +2006;1;2;2;0.00033;0.004;0 +2006;1;3;3;0.00041;0.00425;0 +2006;1;4;4;0.00047;0.00477;0 +2006;1;5;5;0.00053;0.00512;0 +2006;1;6;6;0.00056;0.0053;0 +2006;1;7;7;0.00061;0.0055;0 +2006;1;8;8;0.00072;0.00633;0 +2006;1;9;9;0.00088;0.0069;0 +2006;1;10;10;0.00102;0.0076;0 +2006;1;11;11;0.00115;0.00802;0 +2006;1;12;12;0.00117;0.00824;0 +2006;1;13;13;0.00131;0.00942;0 +2006;1;14;14;0.00143;0.0103;0 +2006;1;15;15;0.00161;0.01152;0 +2006;1;16;16;0.00171;0.01191;0 +2006;1;17;17;0.00184;0.01251;0 +2006;1;18;18;0.00202;0.01291;0 +2006;1;19;19;0.00228;0.01384;0 +2006;1;20;20;0.00261;0.01475;0 +2006;1;21;21;0.00282;0.01535;0 +2006;1;22;22;0.00316;0.01698;0 +2006;1;23;23;0.00336;0.01816;0 +2006;1;24;24;0.00348;0.01886;0 +2006;1;25;25;0.00369;0.01992;0 +2006;1;26;26;0.00404;0.02084;0 +2006;1;27;27;0.00404;0.02084;0 +2006;1;28;28;0.00418;0.02112;0 +2006;1;29;29;0.00418;0.02113;0 +2006;1;30;30;0.00418;0.02113;0 +2006;1;31;31;0.00431;0.02125;0 +2006;2;1;32;0.00454;0.02161;0 +2006;2;2;33;0.00492;0.02266;0 +2006;2;3;34;0.00535;0.02297;0 +2006;2;4;35;0.00542;0.02303;0 +2006;2;5;36;0.00549;0.02321;0 +2006;2;6;37;0.00556;0.02351;0 +2006;2;7;38;0.00568;0.02394;0 +2006;2;8;39;0.00591;0.02443;0 +2006;2;9;40;0.00598;0.02458;0 +2006;2;10;41;0.00638;0.0261;0 +2006;2;11;42;0.00667;0.02727;0 +2006;2;12;43;0.00683;0.02797;0 +2006;2;13;44;0.00701;0.02865;0 +2006;2;14;45;0.00762;0.02972;0 +2006;2;15;46;0.0081;0.03029;0 +2006;2;16;47;0.00871;0.03096;0 +2006;2;17;48;0.00986;0.03311;0 +2006;2;18;49;0.01113;0.03583;0 +2006;2;19;50;0.01245;0.03764;0 +2006;2;20;51;0.01392;0.03999;0 +2006;2;21;52;0.01547;0.04181;0 +2006;2;22;53;0.01673;0.04307;0 +2006;2;23;54;0.0176;0.04418;0 +2006;2;24;55;0.01871;0.04593;0 +2006;2;25;56;0.0198;0.04794;0 +2006;2;26;57;0.0206;0.04887;0 +2006;2;27;58;0.02208;0.04986;0 +2006;2;28;59;0.02279;0.0508;0 +2006;3;1;60;0.02341;0.05153;0 +2006;3;2;61;0.02516;0.05323;0 +2006;3;3;62;0.02704;0.05479;0 +2006;3;4;63;0.03039;0.05665;0 +2006;3;5;64;0.03408;0.05827;0 +2006;3;6;65;0.03512;0.05901;0 +2006;3;7;66;0.03741;0.0605;0 +2006;3;8;67;0.04027;0.06165;0 +2006;3;9;68;0.045;0.06282;0 +2006;3;10;69;0.05126;0.06401;0 +2006;3;11;70;0.05544;0.06629;0 +2006;3;12;71;0.06002;0.06779;0 +2006;3;13;72;0.06495;0.07272;0 +2006;3;14;73;0.06826;0.07638;0 +2006;3;15;74;0.07352;0.0809;0 +2006;3;16;75;0.08089;0.08693;0 +2006;3;17;76;0.08925;0.09263;0 +2006;3;18;77;0.09879;0.09581;0 +2006;3;19;78;0.1109;0.10256;0 +2006;3;20;79;0.12583;0.11136;0 +2006;3;21;80;0.14622;0.12031;0 +2006;3;22;81;0.16874;0.12632;0 +2006;3;23;82;0.18884;0.13469;0 +2006;3;24;83;0.2101;0.14517;0 +2006;3;25;84;0.23791;0.15933;0 +2006;3;26;85;0.27384;0.17273;0 +2006;3;27;86;0.30897;0.18447;0 +2006;3;28;87;0.34852;0.19795;0 +2006;3;29;88;0.3789;0.26007;0 +2006;3;30;89;0.40955;0.30981;0 +2006;3;31;90;0.4465;0.37561;0 +2006;4;1;91;0.49002;0.40455;0 +2006;4;2;92;0.52478;0.46334;0 +2006;4;3;93;0.55899;0.51635;0 +2006;4;4;94;0.59566;0.59556;0 +2006;4;5;95;0.62886;0.6558;0 +2006;4;6;96;0.67018;0.74671;0 +2006;4;7;97;0.70247;0.83206;0 +2006;4;8;98;0.73877;0.90341;0 +2006;4;9;99;0.7818;0.96334;0 +2006;4;10;100;0.82826;1.02264;0 +2006;4;11;101;0.85707;1.11006;0 +2006;4;12;102;0.88408;1.16831;0 +2006;4;13;103;0.91521;1.25757;0 +2006;4;14;104;0.95867;1.36611;0 +2006;4;15;105;1.00935;1.4255;0 +2006;4;16;106;1.06923;1.52144;0 +2006;4;17;107;1.12725;1.61533;0 +2006;4;18;108;1.18169;1.69524;0 +2006;4;19;109;1.23707;1.84083;0 +2006;4;20;110;1.29263;1.99168;0 +2006;4;21;111;1.36537;2.14525;0 +2006;4;22;112;1.4414;2.30071;0 +2006;4;23;113;1.53157;2.43086;0 +2006;4;24;114;1.61146;2.56754;0 +2006;4;25;115;1.69561;2.65385;0 +2006;4;26;116;1.76576;2.80425;0 +2006;4;27;117;1.8524;2.87346;0 +2006;4;28;118;1.9252;2.99206;0 +2006;4;29;119;1.99352;3.15279;0 +2006;4;30;120;2.06303;3.33858;0 +2006;5;1;121;2.11982;3.50388;0 +2006;5;2;122;2.18794;3.67864;0 +2006;5;3;123;2.27463;3.85046;0 +2006;5;4;124;2.36732;4.01157;0 +2006;5;5;125;2.46143;4.10349;0 +2006;5;6;126;2.54495;4.19761;0 +2006;5;7;127;2.6274;4.32098;0 +2006;5;8;128;2.70919;4.3885;0 +2006;5;9;129;2.75569;4.54176;0 +2006;5;10;130;2.80669;4.70341;0 +2006;5;11;131;2.8777;4.90583;0 +2006;5;12;132;2.9339;5.0196;0 +2006;5;13;133;3.01173;5.12228;0 +2006;5;14;134;3.07949;5.28986;0 +2006;5;15;135;3.07125;5.43864;0 +2006;5;16;136;3.05854;5.6;0 +2006;5;17;137;3.05018;5.75348;0 +2006;5;18;138;3.02852;5.79221;0 +2006;5;19;139;2.99319;5.90628;0 +2006;5;20;140;2.95057;6.03511;0 +2006;5;21;141;2.9293;6.18094;0 +2006;5;22;142;2.86556;6.25036;0 +2006;5;23;143;2.79087;6.3404;0 +2006;5;24;144;2.76045;6.50081;0 +2006;5;25;145;2.69261;6.65962;0 +2006;5;26;146;2.64903;6.78363;0 +2006;5;27;147;2.57992;6.94131;0 +2006;5;28;148;2.50965;7.09532;0 +2006;5;29;149;2.46817;7.19468;0.2395404 +2006;5;30;150;2.39914;7.32794;0.5766882 +2006;5;31;151;2.35601;7.46571;0.9252463 +2006;6;1;152;2.28017;7.61736;1.3089208 +2006;6;2;153;2.22116;7.75954;1.6686362 +2006;6;3;154;2.17737;7.91287;2.0565611 +2006;6;4;155;2.06625;8.06134;2.4321902 +2006;6;5;156;2.00808;8.20937;2.8067061 +2006;6;6;157;1.89814;8.34763;3.1565039 +2006;6;7;158;1.84196;8.47538;3.4797114 +2006;6;8;159;1.69261;8.58604;3.7596812 +2006;6;9;160;1.60238;8.68368;4.0067104 +2006;6;10;161;1.43792;8.76381;4.2094393 +2006;6;11;162;1.36708;8.84445;4.4134585 +2006;6;12;163;1.28009;8.9141;4.589673 +2006;6;13;164;1.13727;8.97459;4.7427127 +2006;6;14;165;1.06662;9.02721;4.8758413 +2006;6;15;166;0;9.02721;4.8758413 +2006;6;16;167;0;9.02721;4.8758413 +2006;6;17;168;0;9.02721;4.8758413 +2006;6;18;169;0;9.02721;4.8758413 +2006;6;19;170;0;9.02721;4.8758413 +2006;6;20;171;0;9.02721;4.8758413 +2006;6;21;172;0;9.02721;4.8758413 +2006;6;22;173;0;9.02721;4.8758413 +2006;6;23;174;0;9.02721;4.8758413 +2006;6;24;175;0;9.02721;4.8758413 +2006;6;25;176;0;9.02721;4.8758413 +2006;6;26;177;0;9.02721;4.8758413 +2006;6;27;178;0;9.02721;4.8758413 +2006;6;28;179;0;9.02721;4.8758413 +2006;6;29;180;0;9.02721;4.8758413 +2006;6;30;181;0;9.02721;4.8758413 +2006;7;1;182;0;9.02721;4.8758413 +2006;7;2;183;0;9.02721;4.8758413 +2006;7;3;184;0;9.02721;4.8758413 +2006;7;4;185;0;9.02721;4.8758413 +2006;7;5;186;0;9.02721;4.8758413 +2006;7;6;187;0;9.02721;4.8758413 +2006;7;7;188;0;9.02721;4.8758413 +2006;7;8;189;0;9.02721;4.8758413 +2006;7;9;190;0;9.02721;4.8758413 +2006;7;10;191;0;9.02721;4.8758413 +2006;7;11;192;0;9.02721;4.8758413 +2006;7;12;193;0;9.02721;4.8758413 +2006;7;13;194;0;9.02721;4.8758413 +2006;7;14;195;0;9.02721;4.8758413 +2006;7;15;196;0;9.02721;4.8758413 +2006;7;16;197;0;9.02721;4.8758413 +2006;7;17;198;0;9.02721;4.8758413 +2006;7;18;199;0;9.02721;4.8758413 +2006;7;19;200;0;9.02721;4.8758413 +2006;7;20;201;0;9.02721;4.8758413 +2006;7;21;202;0;9.02721;4.8758413 +2006;7;22;203;0;9.02721;4.8758413 +2006;7;23;204;0;9.02721;4.8758413 +2006;7;24;205;0;9.02721;4.8758413 +2006;7;25;206;0;9.02721;4.8758413 +2006;7;26;207;0;9.02721;4.8758413 +2006;7;27;208;0;9.02721;4.8758413 +2006;7;28;209;0;9.02721;4.8758413 +2006;7;29;210;0;9.02721;4.8758413 +2006;7;30;211;0;9.02721;4.8758413 +2006;7;31;212;0;9.02721;4.8758413 +2006;8;1;213;0;9.02721;4.8758413 diff --git a/inst/extdata/stics_example_1/mod_sSC_Wheat_2005-2006_N0.sti b/inst/extdata/stics_example_1/mod_sSC_Wheat_2005-2006_N0.sti index 2901474a..65f6c8f0 100644 --- a/inst/extdata/stics_example_1/mod_sSC_Wheat_2005-2006_N0.sti +++ b/inst/extdata/stics_example_1/mod_sSC_Wheat_2005-2006_N0.sti @@ -1,311 +1,311 @@ -ian;mo;jo;jul;lai(n);masec(n) -2005; 9;26;269; 0.00000; 0.00000 -2005; 9;27;270; 0.00000; 0.00000 -2005; 9;28;271; 0.00000; 0.00000 -2005; 9;29;272; 0.00000; 0.00000 -2005; 9;30;273; 0.00000; 0.00000 -2005;10; 1;274; 0.00000; 0.00000 -2005;10; 2;275; 0.00000; 0.00000 -2005;10; 3;276; 0.00000; 0.00000 -2005;10; 4;277; 0.00000; 0.00000 -2005;10; 5;278; 0.00000; 0.00000 -2005;10; 6;279; 0.00000; 0.00000 -2005;10; 7;280; 0.00000; 0.00000 -2005;10; 8;281; 0.00000; 0.00000 -2005;10; 9;282; 0.00000; 0.00000 -2005;10;10;283; 0.00000; 0.00000 -2005;10;11;284; 0.00000; 0.00000 -2005;10;12;285; 0.00000; 0.00000 -2005;10;13;286; 0.00000; 0.00000 -2005;10;14;287; 0.00000; 0.00000 -2005;10;15;288; 0.00000; 0.00000 -2005;10;16;289; 0.00000; 0.00000 -2005;10;17;290; 0.00000; 0.00000 -2005;10;18;291; 0.00000; 0.00000 -2005;10;19;292; 0.00000; 0.00000 -2005;10;20;293; 0.00000; 0.00000 -2005;10;21;294; 0.00000; 0.00000 -2005;10;22;295; 0.00000; 0.00000 -2005;10;23;296; 0.00000; 0.00000 -2005;10;24;297; 0.00000; 0.00000 -2005;10;25;298; 0.00000; 0.00000 -2005;10;26;299; 0.00000; 0.00000 -2005;10;27;300; 0.00000; 0.00000 -2005;10;28;301; 0.00000; 0.00000 -2005;10;29;302; 0.00000; 0.00000 -2005;10;30;303; 0.00000; 0.00000 -2005;10;31;304; 0.00000; 0.00000 -2005;11; 1;305; 0.00000; 0.00000 -2005;11; 2;306; 0.00000; 0.00000 -2005;11; 3;307; 0.00000; 0.00000 -2005;11; 4;308; 0.00000; 0.00000 -2005;11; 5;309; 0.00000; 0.00000 -2005;11; 6;310; 0.00000; 0.00000 -2005;11; 7;311; 0.00000; 0.00000 -2005;11; 8;312; 0.00000; 0.00000 -2005;11; 9;313; 0.00000; 0.00000 -2005;11;10;314; 0.00000; 0.00000 -2005;11;11;315; 0.00000; 0.00000 -2005;11;12;316; 0.00000; 0.00000 -2005;11;13;317; 0.00000; 0.00000 -2005;11;14;318; 0.00000; 0.00000 -2005;11;15;319; 0.00000; 0.00000 -2005;11;16;320; 0.00000; 0.00000 -2005;11;17;321; 0.00000; 0.00000 -2005;11;18;322; 0.00000; 0.00000 -2005;11;19;323; 0.00000; 0.00000 -2005;11;20;324; 0.00000; 0.00000 -2005;11;21;325; 0.00000; 0.00000 -2005;11;22;326; 0.00000; 0.00000 -2005;11;23;327; 0.00000; 0.00000 -2005;11;24;328; 0.00000; 0.00000 -2005;11;25;329; 0.00000; 0.00000 -2005;11;26;330; 0.00000; 0.00000 -2005;11;27;331; 0.00000; 0.00000 -2005;11;28;332; 0.00000; 0.00000 -2005;11;29;333; 0.00019; 0.00159 -2005;11;30;334; 0.00084; 0.00311 -2005;12; 1;335; 0.00131; 0.00396 -2005;12; 2;336; 0.00214; 0.00478 -2005;12; 3;337; 0.00405; 0.00756 -2005;12; 4;338; 0.00561; 0.00966 -2005;12; 5;339; 0.00778; 0.01080 -2005;12; 6;340; 0.00972; 0.01186 -2005;12; 7;341; 0.01154; 0.01343 -2005;12; 8;342; 0.01357; 0.01425 -2005;12; 9;343; 0.01546; 0.01607 -2005;12;10;344; 0.01806; 0.01951 -2005;12;11;345; 0.01870; 0.01978 -2005;12;12;346; 0.01870; 0.01979 -2005;12;13;347; 0.01878; 0.01988 -2005;12;14;348; 0.01904; 0.02011 -2005;12;15;349; 0.02010; 0.02075 -2005;12;16;350; 0.02146; 0.02164 -2005;12;17;351; 0.02368; 0.02285 -2005;12;18;352; 0.02653; 0.02690 -2005;12;19;353; 0.02715; 0.02822 -2005;12;20;354; 0.02745; 0.02886 -2005;12;21;355; 0.02763; 0.02918 -2005;12;22;356; 0.02784; 0.02934 -2005;12;23;357; 0.02784; 0.02935 -2005;12;24;358; 0.02784; 0.02939 -2005;12;25;359; 0.02848; 0.02994 -2005;12;26;360; 0.02850; 0.02994 -2005;12;27;361; 0.02889; 0.03011 -2005;12;28;362; 0.02889; 0.03015 -2005;12;29;363; 0.02912; 0.03059 -2005;12;30;364; 0.02912; 0.03060 -2005;12;31;365; 0.03090; 0.03145 -2006; 1; 1; 1; 0.03448; 0.03383 -2006; 1; 2; 2; 0.03796; 0.03512 -2006; 1; 3; 3; 0.04136; 0.03596 -2006; 1; 4; 4; 0.04415; 0.03791 -2006; 1; 5; 5; 0.04648; 0.03930 -2006; 1; 6; 6; 0.04751; 0.04004 -2006; 1; 7; 7; 0.04976; 0.04086 -2006; 1; 8; 8; 0.05389; 0.04415 -2006; 1; 9; 9; 0.05990; 0.04625 -2006; 1;10; 10; 0.06499; 0.04924 -2006; 1;11; 11; 0.06984; 0.05112 -2006; 1;12; 12; 0.07072; 0.05237 -2006; 1;13; 13; 0.07532; 0.05846 -2006; 1;14; 14; 0.07964; 0.06322 -2006; 1;15; 15; 0.08554; 0.06980 -2006; 1;16; 16; 0.08890; 0.07210 -2006; 1;17; 17; 0.09325; 0.07546 -2006; 1;18; 18; 0.09886; 0.07771 -2006; 1;19; 19; 0.10698; 0.08300 -2006; 1;20; 20; 0.11722; 0.08805 -2006; 1;21; 21; 0.12340; 0.09215 -2006; 1;22; 22; 0.13313; 0.10353 -2006; 1;23; 23; 0.13904; 0.11297 -2006; 1;24; 24; 0.14255; 0.11898 -2006; 1;25; 25; 0.14839; 0.12808 -2006; 1;26; 26; 0.15788; 0.13553 -2006; 1;27; 27; 0.15788; 0.13553 -2006; 1;28; 28; 0.16196; 0.13802 -2006; 1;29; 29; 0.16196; 0.13804 -2006; 1;30; 30; 0.16196; 0.13810 -2006; 1;31; 31; 0.16536; 0.13916 -2006; 2; 1; 32; 0.17148; 0.14247 -2006; 2; 2; 33; 0.18183; 0.15207 -2006; 2; 3; 34; 0.19295; 0.15502 -2006; 2; 4; 35; 0.19474; 0.15566 -2006; 2; 5; 36; 0.19705; 0.15759 -2006; 2; 6; 37; 0.19871; 0.16110 -2006; 2; 7; 38; 0.20192; 0.16588 -2006; 2; 8; 39; 0.20784; 0.17137 -2006; 2; 9; 40; 0.20977; 0.17309 -2006; 2;10; 41; 0.21982; 0.19023 -2006; 2;11; 42; 0.22717; 0.20442 -2006; 2;12; 43; 0.23125; 0.21323 -2006; 2;13; 44; 0.23592; 0.22161 -2006; 2;14; 45; 0.25098; 0.23366 -2006; 2;15; 46; 0.26289; 0.24068 -2006; 2;16; 47; 0.27814; 0.24895 -2006; 2;17; 48; 0.30595; 0.27292 -2006; 2;18; 49; 0.30818; 0.30230 -2006; 2;19; 50; 0.31010; 0.32077 -2006; 2;20; 51; 0.31272; 0.34806 -2006; 2;21; 52; 0.31532; 0.36843 -2006; 2;22; 53; 0.31753; 0.38430 -2006; 2;23; 54; 0.31906; 0.39949 -2006; 2;24; 55; 0.32100; 0.42256 -2006; 2;25; 56; 0.32290; 0.44931 -2006; 2;26; 57; 0.32416; 0.46141 -2006; 2;27; 58; 0.32672; 0.47426 -2006; 2;28; 59; 0.32794; 0.48748 -2006; 3; 1; 60; 0.32902; 0.49792 -2006; 3; 2; 61; 0.33203; 0.51966 -2006; 3; 3; 62; 0.33527; 0.53960 -2006; 3; 4; 63; 0.34102; 0.55912 -2006; 3; 5; 64; 0.34736; 0.57614 -2006; 3; 6; 65; 0.34916; 0.58633 -2006; 3; 7; 66; 0.35309; 0.60499 -2006; 3; 8; 67; 0.35801; 0.61899 -2006; 3; 9; 68; 0.36616; 0.63101 -2006; 3;10; 69; 0.37698; 0.64232 -2006; 3;11; 70; 0.38418; 0.66771 -2006; 3;12; 71; 0.39145; 0.68423 -2006; 3;13; 72; 0.39952; 0.73357 -2006; 3;14; 73; 0.40270; 0.76232 -2006; 3;15; 74; 0.40784; 0.79959 -2006; 3;16; 75; 0.41606; 0.84262 -2006; 3;17; 76; 0.42414; 0.87866 -2006; 3;18; 77; 0.43281; 0.89947 -2006; 3;19; 78; 0.45104; 0.94547 -2006; 3;20; 79; 0.46807; 0.98867 -2006; 3;21; 80; 0.48903; 1.02670 -2006; 3;22; 81; 0.51639; 1.05289 -2006; 3;23; 82; 0.54487; 1.09223 -2006; 3;24; 83; 0.56979; 1.13358 -2006; 3;25; 84; 0.59821; 1.22970 -2006; 3;26; 85; 0.62606; 1.29862 -2006; 3;27; 86; 0.65151; 1.35542 -2006; 3;28; 87; 0.68367; 1.41772 -2006; 3;29; 88; 0.70829; 1.50755 -2006; 3;30; 89; 0.73455; 1.58220 -2006; 3;31; 90; 0.76853; 1.68183 -2006; 4; 1; 91; 0.80638; 1.72690 -2006; 4; 2; 92; 0.84121; 1.82288 -2006; 4; 3; 93; 0.87152; 1.90155 -2006; 4; 4; 94; 0.89819; 2.01407 -2006; 4; 5; 95; 0.91868; 2.09972 -2006; 4; 6; 96; 0.95112; 2.22252 -2006; 4; 7; 97; 0.97312; 2.34065 -2006; 4; 8; 98; 0.99576; 2.43686 -2006; 4; 9; 99; 1.02054; 2.51668 -2006; 4;10;100; 1.05614; 2.59619 -2006; 4;11;101; 1.07655; 2.72729 -2006; 4;12;102; 1.08791; 2.81188 -2006; 4;13;103; 1.10657; 2.93792 -2006; 4;14;104; 1.13425; 3.06580 -2006; 4;15;105; 1.15338; 3.13337 -2006; 4;16;106; 1.18670; 3.24514 -2006; 4;17;107; 1.22028; 3.34608 -2006; 4;18;108; 1.25438; 3.43135 -2006; 4;19;109; 1.28633; 3.58392 -2006; 4;20;110; 1.31890; 3.73021 -2006; 4;21;111; 1.36625; 3.87348 -2006; 4;22;112; 1.40554; 4.01453 -2006; 4;23;113; 1.44069; 4.12939 -2006; 4;24;114; 1.48852; 4.25232 -2006; 4;25;115; 1.54143; 4.33006 -2006; 4;26;116; 1.58275; 4.47369 -2006; 4;27;117; 1.62656; 4.54202 -2006; 4;28;118; 1.66901; 4.67177 -2006; 4;29;119; 1.70999; 4.83380 -2006; 4;30;120; 1.72776; 5.01650 -2006; 5; 1;121; 1.72146; 5.18361 -2006; 5; 2;122; 1.76114; 5.35239 -2006; 5; 3;123; 1.81390; 5.51879 -2006; 5; 4;124; 1.87025; 5.67711 -2006; 5; 5;125; 1.93050; 5.77062 -2006; 5; 6;126; 1.99230; 5.87764 -2006; 5; 7;127; 1.98974; 6.01985 -2006; 5; 8;128; 1.98744; 6.09570 -2006; 5; 9;129; 1.98120; 6.30577 -2006; 5;10;130; 1.96910; 6.49412 -2006; 5;11;131; 1.96731; 6.69805 -2006; 5;12;132; 1.95845; 6.82519 -2006; 5;13;133; 1.93949; 6.93298 -2006; 5;14;134; 1.92436; 7.14770 -2006; 5;15;135; 1.91582; 7.32015 -2006; 5;16;136; 1.90476; 7.51728 -2006; 5;17;137; 1.88473; 7.70635 -2006; 5;18;138; 1.85203; 7.75586 -2006; 5;19;139; 1.83312; 7.96125 -2006; 5;20;140; 1.78156; 8.13084 -2006; 5;21;141; 1.72782; 8.23564 -2006; 5;22;142; 1.66691; 8.29733 -2006; 5;23;143; 1.63799; 8.39332 -2006; 5;24;144; 1.58052; 8.54066 -2006; 5;25;145; 1.55427; 8.66686 -2006; 5;26;146; 1.48139; 8.76779 -2006; 5;27;147; 1.44631; 8.90056 -2006; 5;28;148; 1.38398; 9.02525 -2006; 5;29;149; 1.35662; 9.11242 -2006; 5;30;150; 1.29601; 9.23257 -2006; 5;31;151; 1.26700; 9.34646 -2006; 6; 1;152; 1.18979; 9.46989 -2006; 6; 2;153; 1.16478; 9.58296 -2006; 6; 3;154; 1.14320; 9.70518 -2006; 6; 4;155; 1.08354; 9.82113 -2006; 6; 5;156; 1.04606; 9.93700 -2006; 6; 6;157; 0.99683; 10.05101 -2006; 6; 7;158; 0.91389; 10.16092 -2006; 6; 8;159; 0.87244; 10.26656 -2006; 6; 9;160; 0.83578; 10.36457 -2006; 6;10;161; 0.73963; 10.44869 -2006; 6;11;162; 0.68301; 10.54188 -2006; 6;12;163; 0.63108; 10.62646 -2006; 6;13;164; 0.57651; 10.69878 -2006; 6;14;165; 0.47027; 10.76222 -2006; 6;15;166; 0.41638; 10.81463 -2006; 6;16;167; 0.37073; 10.85601 -2006; 6;17;168; 0.32599; 10.89757 -2006; 6;18;169; 0.28924; 10.92107 -2006; 6;19;170; 0.18985; 10.96528 -2006; 6;20;171; 0.12868; 10.98396 -2006; 6;21;172; 0.06496; 11.00867 -2006; 6;22;173; 0.00000; 11.02411 -2006; 6;23;174; 0.00000; 11.06378 -2006; 6;24;175; 0.00000; 11.06378 -2006; 6;25;176; 0.00000; 11.06378 -2006; 6;26;177; 0.00000; 11.06378 -2006; 6;27;178; 0.00000; 11.06378 -2006; 6;28;179; 0.00000; 11.06378 -2006; 6;29;180; 0.00000; 11.06378 -2006; 6;30;181; 0.00000; 11.06378 -2006; 7; 1;182; 0.00000; 11.06378 -2006; 7; 2;183; 0.00000; 11.06378 -2006; 7; 3;184; 0.00000; 11.06378 -2006; 7; 4;185; 0.00000; 11.06378 -2006; 7; 5;186; 0.00000; 11.06378 -2006; 7; 6;187; 0.00000; 11.06378 -2006; 7; 7;188; 0.00000; 11.06378 -2006; 7; 8;189; 0.00000; 11.06378 -2006; 7; 9;190; 0.00000; 11.06378 -2006; 7;10;191; 0.00000; 11.06378 -2006; 7;11;192; 0.00000; 11.06378 -2006; 7;12;193; 0.00000; 11.06378 -2006; 7;13;194; 0.00000; 11.06378 -2006; 7;14;195; 0.00000; 11.06378 -2006; 7;15;196; 0.00000; 11.06378 -2006; 7;16;197; 0.00000; 11.06378 -2006; 7;17;198; 0.00000; 11.06378 -2006; 7;18;199; 0.00000; 11.06378 -2006; 7;19;200; 0.00000; 11.06378 -2006; 7;20;201; 0.00000; 11.06378 -2006; 7;21;202; 0.00000; 11.06378 -2006; 7;22;203; 0.00000; 11.06378 -2006; 7;23;204; 0.00000; 11.06378 -2006; 7;24;205; 0.00000; 11.06378 -2006; 7;25;206; 0.00000; 11.06378 -2006; 7;26;207; 0.00000; 11.06378 -2006; 7;27;208; 0.00000; 11.06378 -2006; 7;28;209; 0.00000; 11.06378 -2006; 7;29;210; 0.00000; 11.06378 -2006; 7;30;211; 0.00000; 11.06378 -2006; 7;31;212; 0.00000; 11.06378 -2006; 8; 1;213; 0.00000; 11.06378 +ian;mo;jo;jul;lai(n);masec(n);mafruit +2005;9;26;269;0;0;0 +2005;9;27;270;0;0;0 +2005;9;28;271;0;0;0 +2005;9;29;272;0;0;0 +2005;9;30;273;0;0;0 +2005;10;1;274;0;0;0 +2005;10;2;275;0;0;0 +2005;10;3;276;0;0;0 +2005;10;4;277;0;0;0 +2005;10;5;278;0;0;0 +2005;10;6;279;0;0;0 +2005;10;7;280;0;0;0 +2005;10;8;281;0;0;0 +2005;10;9;282;0;0;0 +2005;10;10;283;0;0;0 +2005;10;11;284;0;0;0 +2005;10;12;285;0;0;0 +2005;10;13;286;0;0;0 +2005;10;14;287;0;0;0 +2005;10;15;288;0;0;0 +2005;10;16;289;0;0;0 +2005;10;17;290;0;0;0 +2005;10;18;291;0;0;0 +2005;10;19;292;0;0;0 +2005;10;20;293;0;0;0 +2005;10;21;294;0;0;0 +2005;10;22;295;0;0;0 +2005;10;23;296;0;0;0 +2005;10;24;297;0;0;0 +2005;10;25;298;0;0;0 +2005;10;26;299;0;0;0 +2005;10;27;300;0;0;0 +2005;10;28;301;0;0;0 +2005;10;29;302;0;0;0 +2005;10;30;303;0;0;0 +2005;10;31;304;0;0;0 +2005;11;1;305;0;0;0 +2005;11;2;306;0;0;0 +2005;11;3;307;0;0;0 +2005;11;4;308;0;0;0 +2005;11;5;309;0;0;0 +2005;11;6;310;0;0;0 +2005;11;7;311;0;0;0 +2005;11;8;312;0;0;0 +2005;11;9;313;0;0;0 +2005;11;10;314;0;0;0 +2005;11;11;315;0;0;0 +2005;11;12;316;0;0;0 +2005;11;13;317;0;0;0 +2005;11;14;318;0;0;0 +2005;11;15;319;0;0;0 +2005;11;16;320;0;0;0 +2005;11;17;321;0;0;0 +2005;11;18;322;0;0;0 +2005;11;19;323;0;0;0 +2005;11;20;324;0;0;0 +2005;11;21;325;0;0;0 +2005;11;22;326;0;0;0 +2005;11;23;327;0;0;0 +2005;11;24;328;0;0;0 +2005;11;25;329;0;0;0 +2005;11;26;330;0;0;0 +2005;11;27;331;0;0;0 +2005;11;28;332;0;0;0 +2005;11;29;333;0.00019;0.00159;0 +2005;11;30;334;0.00084;0.00311;0 +2005;12;1;335;0.00131;0.00396;0 +2005;12;2;336;0.00214;0.00478;0 +2005;12;3;337;0.00405;0.00756;0 +2005;12;4;338;0.00561;0.00966;0 +2005;12;5;339;0.00778;0.0108;0 +2005;12;6;340;0.00972;0.01186;0 +2005;12;7;341;0.01154;0.01343;0 +2005;12;8;342;0.01357;0.01425;0 +2005;12;9;343;0.01546;0.01607;0 +2005;12;10;344;0.01806;0.01951;0 +2005;12;11;345;0.0187;0.01978;0 +2005;12;12;346;0.0187;0.01979;0 +2005;12;13;347;0.01878;0.01988;0 +2005;12;14;348;0.01904;0.02011;0 +2005;12;15;349;0.0201;0.02075;0 +2005;12;16;350;0.02146;0.02164;0 +2005;12;17;351;0.02368;0.02285;0 +2005;12;18;352;0.02653;0.0269;0 +2005;12;19;353;0.02715;0.02822;0 +2005;12;20;354;0.02745;0.02886;0 +2005;12;21;355;0.02763;0.02918;0 +2005;12;22;356;0.02784;0.02934;0 +2005;12;23;357;0.02784;0.02935;0 +2005;12;24;358;0.02784;0.02939;0 +2005;12;25;359;0.02848;0.02994;0 +2005;12;26;360;0.0285;0.02994;0 +2005;12;27;361;0.02889;0.03011;0 +2005;12;28;362;0.02889;0.03015;0 +2005;12;29;363;0.02912;0.03059;0 +2005;12;30;364;0.02912;0.0306;0 +2005;12;31;365;0.0309;0.03145;0 +2006;1;1;1;0.03448;0.03383;0 +2006;1;2;2;0.03796;0.03512;0 +2006;1;3;3;0.04136;0.03596;0 +2006;1;4;4;0.04415;0.03791;0 +2006;1;5;5;0.04648;0.0393;0 +2006;1;6;6;0.04751;0.04004;0 +2006;1;7;7;0.04976;0.04086;0 +2006;1;8;8;0.05389;0.04415;0 +2006;1;9;9;0.0599;0.04625;0 +2006;1;10;10;0.06499;0.04924;0 +2006;1;11;11;0.06984;0.05112;0 +2006;1;12;12;0.07072;0.05237;0 +2006;1;13;13;0.07532;0.05846;0 +2006;1;14;14;0.07964;0.06322;0 +2006;1;15;15;0.08554;0.0698;0 +2006;1;16;16;0.0889;0.0721;0 +2006;1;17;17;0.09325;0.07546;0 +2006;1;18;18;0.09886;0.07771;0 +2006;1;19;19;0.10698;0.083;0 +2006;1;20;20;0.11722;0.08805;0 +2006;1;21;21;0.1234;0.09215;0 +2006;1;22;22;0.13313;0.10353;0 +2006;1;23;23;0.13904;0.11297;0 +2006;1;24;24;0.14255;0.11898;0 +2006;1;25;25;0.14839;0.12808;0 +2006;1;26;26;0.15788;0.13553;0 +2006;1;27;27;0.15788;0.13553;0 +2006;1;28;28;0.16196;0.13802;0 +2006;1;29;29;0.16196;0.13804;0 +2006;1;30;30;0.16196;0.1381;0 +2006;1;31;31;0.16536;0.13916;0 +2006;2;1;32;0.17148;0.14247;0 +2006;2;2;33;0.18183;0.15207;0 +2006;2;3;34;0.19295;0.15502;0 +2006;2;4;35;0.19474;0.15566;0 +2006;2;5;36;0.19705;0.15759;0 +2006;2;6;37;0.19871;0.1611;0 +2006;2;7;38;0.20192;0.16588;0 +2006;2;8;39;0.20784;0.17137;0 +2006;2;9;40;0.20977;0.17309;0 +2006;2;10;41;0.21982;0.19023;0 +2006;2;11;42;0.22717;0.20442;0 +2006;2;12;43;0.23125;0.21323;0 +2006;2;13;44;0.23592;0.22161;0 +2006;2;14;45;0.25098;0.23366;0 +2006;2;15;46;0.26289;0.24068;0 +2006;2;16;47;0.27814;0.24895;0 +2006;2;17;48;0.30595;0.27292;0 +2006;2;18;49;0.30818;0.3023;0 +2006;2;19;50;0.3101;0.32077;0 +2006;2;20;51;0.31272;0.34806;0 +2006;2;21;52;0.31532;0.36843;0 +2006;2;22;53;0.31753;0.3843;0 +2006;2;23;54;0.31906;0.39949;0 +2006;2;24;55;0.321;0.42256;0 +2006;2;25;56;0.3229;0.44931;0 +2006;2;26;57;0.32416;0.46141;0 +2006;2;27;58;0.32672;0.47426;0 +2006;2;28;59;0.32794;0.48748;0 +2006;3;1;60;0.32902;0.49792;0 +2006;3;2;61;0.33203;0.51966;0 +2006;3;3;62;0.33527;0.5396;0 +2006;3;4;63;0.34102;0.55912;0 +2006;3;5;64;0.34736;0.57614;0 +2006;3;6;65;0.34916;0.58633;0 +2006;3;7;66;0.35309;0.60499;0 +2006;3;8;67;0.35801;0.61899;0 +2006;3;9;68;0.36616;0.63101;0 +2006;3;10;69;0.37698;0.64232;0 +2006;3;11;70;0.38418;0.66771;0 +2006;3;12;71;0.39145;0.68423;0 +2006;3;13;72;0.39952;0.73357;0 +2006;3;14;73;0.4027;0.76232;0 +2006;3;15;74;0.40784;0.79959;0 +2006;3;16;75;0.41606;0.84262;0 +2006;3;17;76;0.42414;0.87866;0 +2006;3;18;77;0.43281;0.89947;0 +2006;3;19;78;0.45104;0.94547;0 +2006;3;20;79;0.46807;0.98867;0 +2006;3;21;80;0.48903;1.0267;0 +2006;3;22;81;0.51639;1.05289;0 +2006;3;23;82;0.54487;1.09223;0 +2006;3;24;83;0.56979;1.13358;0 +2006;3;25;84;0.59821;1.2297;0 +2006;3;26;85;0.62606;1.29862;0 +2006;3;27;86;0.65151;1.35542;0 +2006;3;28;87;0.68367;1.41772;0 +2006;3;29;88;0.70829;1.50755;0 +2006;3;30;89;0.73455;1.5822;0 +2006;3;31;90;0.76853;1.68183;0 +2006;4;1;91;0.80638;1.7269;0 +2006;4;2;92;0.84121;1.82288;0 +2006;4;3;93;0.87152;1.90155;0 +2006;4;4;94;0.89819;2.01407;0 +2006;4;5;95;0.91868;2.09972;0 +2006;4;6;96;0.95112;2.22252;0 +2006;4;7;97;0.97312;2.34065;0 +2006;4;8;98;0.99576;2.43686;0 +2006;4;9;99;1.02054;2.51668;0 +2006;4;10;100;1.05614;2.59619;0 +2006;4;11;101;1.07655;2.72729;0 +2006;4;12;102;1.08791;2.81188;0 +2006;4;13;103;1.10657;2.93792;0 +2006;4;14;104;1.13425;3.0658;0 +2006;4;15;105;1.15338;3.13337;0 +2006;4;16;106;1.1867;3.24514;0 +2006;4;17;107;1.22028;3.34608;0 +2006;4;18;108;1.25438;3.43135;0 +2006;4;19;109;1.28633;3.58392;0 +2006;4;20;110;1.3189;3.73021;0 +2006;4;21;111;1.36625;3.87348;0 +2006;4;22;112;1.40554;4.01453;0 +2006;4;23;113;1.44069;4.12939;0 +2006;4;24;114;1.48852;4.25232;0 +2006;4;25;115;1.54143;4.33006;0 +2006;4;26;116;1.58275;4.47369;0 +2006;4;27;117;1.62656;4.54202;0 +2006;4;28;118;1.66901;4.67177;0 +2006;4;29;119;1.70999;4.8338;0 +2006;4;30;120;1.72776;5.0165;0 +2006;5;1;121;1.72146;5.18361;0 +2006;5;2;122;1.76114;5.35239;0 +2006;5;3;123;1.8139;5.51879;0 +2006;5;4;124;1.87025;5.67711;0 +2006;5;5;125;1.9305;5.77062;0 +2006;5;6;126;1.9923;5.87764;0 +2006;5;7;127;1.98974;6.01985;0 +2006;5;8;128;1.98744;6.0957;0 +2006;5;9;129;1.9812;6.30577;0 +2006;5;10;130;1.9691;6.49412;0 +2006;5;11;131;1.96731;6.69805;0 +2006;5;12;132;1.95845;6.82519;0 +2006;5;13;133;1.93949;6.93298;0 +2006;5;14;134;1.92436;7.1477;0 +2006;5;15;135;1.91582;7.32015;0 +2006;5;16;136;1.90476;7.51728;0 +2006;5;17;137;1.88473;7.70635;0 +2006;5;18;138;1.85203;7.75586;0 +2006;5;19;139;1.83312;7.96125;0 +2006;5;20;140;1.78156;8.13084;0 +2006;5;21;141;1.72782;8.23564;0 +2006;5;22;142;1.66691;8.29733;0 +2006;5;23;143;1.63799;8.39332;0 +2006;5;24;144;1.58052;8.54066;0 +2006;5;25;145;1.55427;8.66686;0 +2006;5;26;146;1.48139;8.76779;0 +2006;5;27;147;1.44631;8.90056;0 +2006;5;28;148;1.38398;9.02525;0.0694375 +2006;5;29;149;1.35662;9.11242;0.309155 +2006;5;30;150;1.29601;9.23257;0.6395675 +2006;5;31;151;1.267;9.34646;0.952765 +2006;6;1;152;1.18979;9.46989;1.2921975 +2006;6;2;153;1.16478;9.58296;1.60314 +2006;6;3;154;1.1432;9.70518;1.939245 +2006;6;4;155;1.08354;9.82113;2.2581075 +2006;6;5;156;1.04606;9.937;2.57675 +2006;6;6;157;0.99683;10.05101;2.8902775 +2006;6;7;158;0.91389;10.16092;3.19253 +2006;6;8;159;0.87244;10.26656;3.48304 +2006;6;9;160;0.83578;10.36457;3.7525675 +2006;6;10;161;0.73963;10.44869;3.9838975 +2006;6;11;162;0.68301;10.54188;4.24017 +2006;6;12;163;0.63108;10.62646;4.472765 +2006;6;13;164;0.57651;10.69878;4.671645 +2006;6;14;165;0.47027;10.76222;4.846105 +2006;6;15;166;0.41638;10.81463;4.9902325 +2006;6;16;167;0.37073;10.85601;5.1040275 +2006;6;17;168;0.32599;10.89757;5.2183175 +2006;6;18;169;0.28924;10.92107;5.2829425 +2006;6;19;170;0.18985;10.96528;5.40452 +2006;6;20;171;0.12868;10.98396;5.45589 +2006;6;21;172;0.06496;11.00867;5.5238425 +2006;6;22;173;0;11.02411;5.5663025 +2006;6;23;174;0;11.06378;5.675395 +2006;6;24;175;0;11.06378;5.675395 +2006;6;25;176;0;11.06378;5.675395 +2006;6;26;177;0;11.06378;5.675395 +2006;6;27;178;0;11.06378;5.675395 +2006;6;28;179;0;11.06378;5.675395 +2006;6;29;180;0;11.06378;5.675395 +2006;6;30;181;0;11.06378;5.675395 +2006;7;1;182;0;11.06378;5.675395 +2006;7;2;183;0;11.06378;5.675395 +2006;7;3;184;0;11.06378;5.675395 +2006;7;4;185;0;11.06378;5.675395 +2006;7;5;186;0;11.06378;5.675395 +2006;7;6;187;0;11.06378;5.675395 +2006;7;7;188;0;11.06378;5.675395 +2006;7;8;189;0;11.06378;5.675395 +2006;7;9;190;0;11.06378;5.675395 +2006;7;10;191;0;11.06378;5.675395 +2006;7;11;192;0;11.06378;5.675395 +2006;7;12;193;0;11.06378;5.675395 +2006;7;13;194;0;11.06378;5.675395 +2006;7;14;195;0;11.06378;5.675395 +2006;7;15;196;0;11.06378;5.675395 +2006;7;16;197;0;11.06378;5.675395 +2006;7;17;198;0;11.06378;5.675395 +2006;7;18;199;0;11.06378;5.675395 +2006;7;19;200;0;11.06378;5.675395 +2006;7;20;201;0;11.06378;5.675395 +2006;7;21;202;0;11.06378;5.675395 +2006;7;22;203;0;11.06378;5.675395 +2006;7;23;204;0;11.06378;5.675395 +2006;7;24;205;0;11.06378;5.675395 +2006;7;25;206;0;11.06378;5.675395 +2006;7;26;207;0;11.06378;5.675395 +2006;7;27;208;0;11.06378;5.675395 +2006;7;28;209;0;11.06378;5.675395 +2006;7;29;210;0;11.06378;5.675395 +2006;7;30;211;0;11.06378;5.675395 +2006;7;31;212;0;11.06378;5.675395 +2006;8;1;213;0;11.06378;5.675395 diff --git a/inst/extdata/stics_example_1/mod_saIC_Wheat_Pea_2005-2006_N0.sti b/inst/extdata/stics_example_1/mod_saIC_Wheat_Pea_2005-2006_N0.sti index d6f68bf2..1126ba70 100644 --- a/inst/extdata/stics_example_1/mod_saIC_Wheat_Pea_2005-2006_N0.sti +++ b/inst/extdata/stics_example_1/mod_saIC_Wheat_Pea_2005-2006_N0.sti @@ -1,311 +1,311 @@ -ian;mo;jo;jul;lai(n);masec(n) -2005; 9;26;269; 0.00000; 0.00000 -2005; 9;27;270; 0.00000; 0.00000 -2005; 9;28;271; 0.00000; 0.00000 -2005; 9;29;272; 0.00000; 0.00000 -2005; 9;30;273; 0.00000; 0.00000 -2005;10; 1;274; 0.00000; 0.00000 -2005;10; 2;275; 0.00000; 0.00000 -2005;10; 3;276; 0.00000; 0.00000 -2005;10; 4;277; 0.00000; 0.00000 -2005;10; 5;278; 0.00000; 0.00000 -2005;10; 6;279; 0.00000; 0.00000 -2005;10; 7;280; 0.00000; 0.00000 -2005;10; 8;281; 0.00000; 0.00000 -2005;10; 9;282; 0.00000; 0.00000 -2005;10;10;283; 0.00000; 0.00000 -2005;10;11;284; 0.00000; 0.00000 -2005;10;12;285; 0.00000; 0.00000 -2005;10;13;286; 0.00000; 0.00000 -2005;10;14;287; 0.00000; 0.00000 -2005;10;15;288; 0.00000; 0.00000 -2005;10;16;289; 0.00000; 0.00000 -2005;10;17;290; 0.00000; 0.00000 -2005;10;18;291; 0.00000; 0.00000 -2005;10;19;292; 0.00000; 0.00000 -2005;10;20;293; 0.00000; 0.00000 -2005;10;21;294; 0.00000; 0.00000 -2005;10;22;295; 0.00000; 0.00000 -2005;10;23;296; 0.00000; 0.00000 -2005;10;24;297; 0.00000; 0.00000 -2005;10;25;298; 0.00000; 0.00000 -2005;10;26;299; 0.00000; 0.00000 -2005;10;27;300; 0.00000; 0.00000 -2005;10;28;301; 0.00000; 0.00000 -2005;10;29;302; 0.00000; 0.00000 -2005;10;30;303; 0.00000; 0.00000 -2005;10;31;304; 0.00000; 0.00000 -2005;11; 1;305; 0.00000; 0.00000 -2005;11; 2;306; 0.00000; 0.00000 -2005;11; 3;307; 0.00000; 0.00000 -2005;11; 4;308; 0.00000; 0.00000 -2005;11; 5;309; 0.00000; 0.00000 -2005;11; 6;310; 0.00000; 0.00000 -2005;11; 7;311; 0.00000; 0.00000 -2005;11; 8;312; 0.00000; 0.00000 -2005;11; 9;313; 0.00000; 0.00000 -2005;11;10;314; 0.00000; 0.00000 -2005;11;11;315; 0.00000; 0.00000 -2005;11;12;316; 0.00000; 0.00000 -2005;11;13;317; 0.00000; 0.00000 -2005;11;14;318; 0.00000; 0.00000 -2005;11;15;319; 0.00000; 0.00000 -2005;11;16;320; 0.00000; 0.00000 -2005;11;17;321; 0.00000; 0.00000 -2005;11;18;322; 0.00000; 0.00000 -2005;11;19;323; 0.00000; 0.00000 -2005;11;20;324; 0.00000; 0.00000 -2005;11;21;325; 0.00000; 0.00000 -2005;11;22;326; 0.00000; 0.00000 -2005;11;23;327; 0.00000; 0.00000 -2005;11;24;328; 0.00000; 0.00000 -2005;11;25;329; 0.00000; 0.00000 -2005;11;26;330; 0.00000; 0.00000 -2005;11;27;331; 0.00000; 0.00000 -2005;11;28;332; 0.00000; 0.00000 -2005;11;29;333; 0.00000; 0.00000 -2005;11;30;334; 0.00000; 0.00000 -2005;12; 1;335; 0.00000; 0.00000 -2005;12; 2;336; 0.00000; 0.00000 -2005;12; 3;337; 0.00000; 0.00000 -2005;12; 4;338; 0.00000; 0.00000 -2005;12; 5;339; 0.00000; 0.00000 -2005;12; 6;340; 0.00000; 0.00000 -2005;12; 7;341; 0.00000; 0.00000 -2005;12; 8;342; 0.00000; 0.00000 -2005;12; 9;343; 0.00000; 0.00000 -2005;12;10;344; 0.00000; 0.00000 -2005;12;11;345; 0.00000; 0.00000 -2005;12;12;346; 0.00000; 0.00000 -2005;12;13;347; 0.00000; 0.00000 -2005;12;14;348; 0.00000; 0.00000 -2005;12;15;349; 0.00000; 0.00000 -2005;12;16;350; 0.00000; 0.00000 -2005;12;17;351; 0.00001; 0.00000 -2005;12;18;352; 0.00004; 0.00000 -2005;12;19;353; 0.00005; 0.00000 -2005;12;20;354; 0.00005; 0.00000 -2005;12;21;355; 0.00005; 0.00000 -2005;12;22;356; 0.00006; 0.00000 -2005;12;23;357; 0.00006; 0.00000 -2005;12;24;358; 0.00006; 0.00000 -2005;12;25;359; 0.00006; 0.00000 -2005;12;26;360; 0.00006; 0.00000 -2005;12;27;361; 0.00007; 0.00000 -2005;12;28;362; 0.00007; 0.00000 -2005;12;29;363; 0.00007; 0.00000 -2005;12;30;364; 0.00007; 0.00000 -2005;12;31;365; 0.00009; 0.00000 -2006; 1; 1; 1; 0.00013; 0.00001 -2006; 1; 2; 2; 0.00017; 0.00001 -2006; 1; 3; 3; 0.00021; 0.00001 -2006; 1; 4; 4; 0.00024; 0.00001 -2006; 1; 5; 5; 0.00027; 0.00001 -2006; 1; 6; 6; 0.00028; 0.00002 -2006; 1; 7; 7; 0.00031; 0.00002 -2006; 1; 8; 8; 0.00036; 0.00002 -2006; 1; 9; 9; 0.00044; 0.00003 -2006; 1;10; 10; 0.00051; 0.00004 -2006; 1;11; 11; 0.00058; 0.00004 -2006; 1;12; 12; 0.00059; 0.00005 -2006; 1;13; 13; 0.00066; 0.00007 -2006; 1;14; 14; 0.00072; 0.00008 -2006; 1;15; 15; 0.00081; 0.00011 -2006; 1;16; 16; 0.00086; 0.00011 -2006; 1;17; 17; 0.00092; 0.00013 -2006; 1;18; 18; 0.00101; 0.00014 -2006; 1;19; 19; 0.00114; 0.00016 -2006; 1;20; 20; 0.00131; 0.00019 -2006; 1;21; 21; 0.00141; 0.00021 -2006; 1;22; 22; 0.00158; 0.00027 -2006; 1;23; 23; 0.00168; 0.00032 -2006; 1;24; 24; 0.00175; 0.00035 -2006; 1;25; 25; 0.00185; 0.00040 -2006; 1;26; 26; 0.00202; 0.00044 -2006; 1;27; 27; 0.00202; 0.00044 -2006; 1;28; 28; 0.00210; 0.00045 -2006; 1;29; 29; 0.00210; 0.00045 -2006; 1;30; 30; 0.00210; 0.00045 -2006; 1;31; 31; 0.00216; 0.00046 -2006; 2; 1; 32; 0.00227; 0.00048 -2006; 2; 2; 33; 0.00247; 0.00054 -2006; 2; 3; 34; 0.00268; 0.00056 -2006; 2; 4; 35; 0.00271; 0.00056 -2006; 2; 5; 36; 0.00275; 0.00058 -2006; 2; 6; 37; 0.00278; 0.00060 -2006; 2; 7; 38; 0.00284; 0.00063 -2006; 2; 8; 39; 0.00296; 0.00066 -2006; 2; 9; 40; 0.00300; 0.00067 -2006; 2;10; 41; 0.00319; 0.00079 -2006; 2;11; 42; 0.00334; 0.00088 -2006; 2;12; 43; 0.00342; 0.00094 -2006; 2;13; 44; 0.00351; 0.00099 -2006; 2;14; 45; 0.00381; 0.00108 -2006; 2;15; 46; 0.00405; 0.00114 -2006; 2;16; 47; 0.00436; 0.00121 -2006; 2;17; 48; 0.00493; 0.00145 -2006; 2;18; 49; 0.00557; 0.00179 -2006; 2;19; 50; 0.00623; 0.00205 -2006; 2;20; 51; 0.00697; 0.00242 -2006; 2;21; 52; 0.00774; 0.00274 -2006; 2;22; 53; 0.00837; 0.00297 -2006; 2;23; 54; 0.00881; 0.00318 -2006; 2;24; 55; 0.00936; 0.00353 -2006; 2;25; 56; 0.00990; 0.00395 -2006; 2;26; 57; 0.01028; 0.00414 -2006; 2;27; 58; 0.01102; 0.00438 -2006; 2;28; 59; 0.01137; 0.00460 -2006; 3; 1; 60; 0.01168; 0.00478 -2006; 3; 2; 61; 0.01255; 0.00523 -2006; 3; 3; 62; 0.01349; 0.00566 -2006; 3; 4; 63; 0.01516; 0.00622 -2006; 3; 5; 64; 0.01700; 0.00676 -2006; 3; 6; 65; 0.01752; 0.00701 -2006; 3; 7; 66; 0.01866; 0.00753 -2006; 3; 8; 67; 0.02009; 0.00797 -2006; 3; 9; 68; 0.02245; 0.00843 -2006; 3;10; 69; 0.02558; 0.00894 -2006; 3;11; 70; 0.02766; 0.00993 -2006; 3;12; 71; 0.02994; 0.01059 -2006; 3;13; 72; 0.03241; 0.01273 -2006; 3;14; 73; 0.03385; 0.01415 -2006; 3;15; 74; 0.03612; 0.01591 -2006; 3;16; 75; 0.03946; 0.01837 -2006; 3;17; 76; 0.04327; 0.02070 -2006; 3;18; 77; 0.04778; 0.02203 -2006; 3;19; 78; 0.05367; 0.02480 -2006; 3;20; 79; 0.06060; 0.02833 -2006; 3;21; 80; 0.06978; 0.03188 -2006; 3;22; 81; 0.08053; 0.03421 -2006; 3;23; 82; 0.09021; 0.03736 -2006; 3;24; 83; 0.09981; 0.04113 -2006; 3;25; 84; 0.11319; 0.04630 -2006; 3;26; 85; 0.13011; 0.05113 -2006; 3;27; 86; 0.14700; 0.05534 -2006; 3;28; 87; 0.16612; 0.06011 -2006; 3;29; 88; 0.18145; 0.08173 -2006; 3;30; 89; 0.19880; 0.10217 -2006; 3;31; 90; 0.22142; 0.13222 -2006; 4; 1; 91; 0.24789; 0.14675 -2006; 4; 2; 92; 0.26970; 0.17671 -2006; 4; 3; 93; 0.29078; 0.20442 -2006; 4; 4; 94; 0.31315; 0.24697 -2006; 4; 5; 95; 0.33292; 0.27989 -2006; 4; 6; 96; 0.35802; 0.33168 -2006; 4; 7; 97; 0.37632; 0.37780 -2006; 4; 8; 98; 0.39743; 0.41769 -2006; 4; 9; 99; 0.42321; 0.45251 -2006; 4;10;100; 0.45261; 0.48765 -2006; 4;11;101; 0.47031; 0.53822 -2006; 4;12;102; 0.48636; 0.57094 -2006; 4;13;103; 0.50534; 0.62199 -2006; 4;14;104; 0.53021; 0.68286 -2006; 4;15;105; 0.55857; 0.71586 -2006; 4;16;106; 0.59314; 0.76852 -2006; 4;17;107; 0.62515; 0.81912 -2006; 4;18;108; 0.65464; 0.86138 -2006; 4;19;109; 0.68449; 0.93814 -2006; 4;20;110; 0.71285; 1.01556 -2006; 4;21;111; 0.74927; 1.09391 -2006; 4;22;112; 0.78687; 1.17170 -2006; 4;23;113; 0.83019; 1.23468 -2006; 4;24;114; 0.86886; 1.30116 -2006; 4;25;115; 0.90943; 1.34275 -2006; 4;26;116; 0.94460; 1.41605 -2006; 4;27;117; 0.98660; 1.45302 -2006; 4;28;118; 1.02300; 1.51117 -2006; 4;29;119; 1.05682; 1.59200 -2006; 4;30;120; 1.09102; 1.68882 -2006; 5; 1;121; 1.11955; 1.77457 -2006; 5; 2;122; 1.15335; 1.86474 -2006; 5; 3;123; 1.19538; 1.95490 -2006; 5; 4;124; 1.24183; 2.03981 -2006; 5; 5;125; 1.28929; 2.08836 -2006; 5; 6;126; 1.33380; 2.13939 -2006; 5; 7;127; 1.37886; 2.20868 -2006; 5; 8;128; 1.42373; 2.24660 -2006; 5; 9;129; 1.45164; 2.33757 -2006; 5;10;130; 1.48099; 2.43332 -2006; 5;11;131; 1.51834; 2.55021 -2006; 5;12;132; 1.55121; 2.61719 -2006; 5;13;133; 1.59624; 2.67513 -2006; 5;14;134; 1.63480; 2.78089 -2006; 5;15;135; 1.67634; 2.87309 -2006; 5;16;136; 1.67314; 2.97507 -2006; 5;17;137; 1.67148; 3.07178 -2006; 5;18;138; 1.66769; 3.09473 -2006; 5;19;139; 1.66378; 3.16544 -2006; 5;20;140; 1.65583; 3.24504 -2006; 5;21;141; 1.64802; 3.33689 -2006; 5;22;142; 1.63674; 3.37897 -2006; 5;23;143; 1.62009; 3.43023 -2006; 5;24;144; 1.60634; 3.52673 -2006; 5;25;145; 1.57319; 3.62132 -2006; 5;26;146; 1.53524; 3.69310 -2006; 5;27;147; 1.48927; 3.78712 -2006; 5;28;148; 1.42166; 3.87868 -2006; 5;29;149; 1.35270; 3.93541 -2006; 5;30;150; 1.27253; 4.01000 -2006; 5;31;151; 1.17584; 4.08481 -2006; 6; 1;152; 1.12796; 4.16733 -2006; 6; 2;153; 1.04906; 4.24270 -2006; 6; 3;154; 0.96216; 4.32231 -2006; 6; 4;155; 0.86845; 4.39620 -2006; 6; 5;156; 0.77400; 4.46613 -2006; 6; 6;157; 0.74180; 4.53399 -2006; 6; 7;158; 0.65332; 4.59612 -2006; 6; 8;159; 0.52692; 4.64771 -2006; 6; 9;160; 0.45515; 4.69264 -2006; 6;10;161; 0.34334; 4.72451 -2006; 6;11;162; 0.21364; 4.74821 -2006; 6;12;163; 0.05168; 4.75592 -2006; 6;13;164; 0.00000; 4.75592 -2006; 6;14;165; 0.00000; 4.75592 -2006; 6;15;166; 0.00000; 4.75592 -2006; 6;16;167; 0.00000; 4.75592 -2006; 6;17;168; 0.00000; 4.75592 -2006; 6;18;169; 0.00000; 4.75592 -2006; 6;19;170; 0.00000; 4.75592 -2006; 6;20;171; 0.00000; 4.75592 -2006; 6;21;172; 0.00000; 4.75592 -2006; 6;22;173; 0.00000; 4.75592 -2006; 6;23;174; 0.00000; 4.75592 -2006; 6;24;175; 0.00000; 4.75592 -2006; 6;25;176; 0.00000; 4.75592 -2006; 6;26;177; 0.00000; 4.75592 -2006; 6;27;178; 0.00000; 4.75592 -2006; 6;28;179; 0.00000; 4.75592 -2006; 6;29;180; 0.00000; 4.75592 -2006; 6;30;181; 0.00000; 4.75592 -2006; 7; 1;182; 0.00000; 4.75592 -2006; 7; 2;183; 0.00000; 4.75592 -2006; 7; 3;184; 0.00000; 4.75592 -2006; 7; 4;185; 0.00000; 4.75592 -2006; 7; 5;186; 0.00000; 4.75592 -2006; 7; 6;187; 0.00000; 4.75592 -2006; 7; 7;188; 0.00000; 4.75592 -2006; 7; 8;189; 0.00000; 4.75592 -2006; 7; 9;190; 0.00000; 4.75592 -2006; 7;10;191; 0.00000; 4.75592 -2006; 7;11;192; 0.00000; 4.75592 -2006; 7;12;193; 0.00000; 4.75592 -2006; 7;13;194; 0.00000; 4.75592 -2006; 7;14;195; 0.00000; 4.75592 -2006; 7;15;196; 0.00000; 4.75592 -2006; 7;16;197; 0.00000; 4.75592 -2006; 7;17;198; 0.00000; 4.75592 -2006; 7;18;199; 0.00000; 4.75592 -2006; 7;19;200; 0.00000; 4.75592 -2006; 7;20;201; 0.00000; 4.75592 -2006; 7;21;202; 0.00000; 4.75592 -2006; 7;22;203; 0.00000; 4.75592 -2006; 7;23;204; 0.00000; 4.75592 -2006; 7;24;205; 0.00000; 4.75592 -2006; 7;25;206; 0.00000; 4.75592 -2006; 7;26;207; 0.00000; 4.75592 -2006; 7;27;208; 0.00000; 4.75592 -2006; 7;28;209; 0.00000; 4.75592 -2006; 7;29;210; 0.00000; 4.75592 -2006; 7;30;211; 0.00000; 4.75592 -2006; 7;31;212; 0.00000; 4.75592 -2006; 8; 1;213; 0.00000; 4.75592 +ian;mo;jo;jul;lai(n);masec(n);mafruit +2005;9;26;269;0;0;0 +2005;9;27;270;0;0;0 +2005;9;28;271;0;0;0 +2005;9;29;272;0;0;0 +2005;9;30;273;0;0;0 +2005;10;1;274;0;0;0 +2005;10;2;275;0;0;0 +2005;10;3;276;0;0;0 +2005;10;4;277;0;0;0 +2005;10;5;278;0;0;0 +2005;10;6;279;0;0;0 +2005;10;7;280;0;0;0 +2005;10;8;281;0;0;0 +2005;10;9;282;0;0;0 +2005;10;10;283;0;0;0 +2005;10;11;284;0;0;0 +2005;10;12;285;0;0;0 +2005;10;13;286;0;0;0 +2005;10;14;287;0;0;0 +2005;10;15;288;0;0;0 +2005;10;16;289;0;0;0 +2005;10;17;290;0;0;0 +2005;10;18;291;0;0;0 +2005;10;19;292;0;0;0 +2005;10;20;293;0;0;0 +2005;10;21;294;0;0;0 +2005;10;22;295;0;0;0 +2005;10;23;296;0;0;0 +2005;10;24;297;0;0;0 +2005;10;25;298;0;0;0 +2005;10;26;299;0;0;0 +2005;10;27;300;0;0;0 +2005;10;28;301;0;0;0 +2005;10;29;302;0;0;0 +2005;10;30;303;0;0;0 +2005;10;31;304;0;0;0 +2005;11;1;305;0;0;0 +2005;11;2;306;0;0;0 +2005;11;3;307;0;0;0 +2005;11;4;308;0;0;0 +2005;11;5;309;0;0;0 +2005;11;6;310;0;0;0 +2005;11;7;311;0;0;0 +2005;11;8;312;0;0;0 +2005;11;9;313;0;0;0 +2005;11;10;314;0;0;0 +2005;11;11;315;0;0;0 +2005;11;12;316;0;0;0 +2005;11;13;317;0;0;0 +2005;11;14;318;0;0;0 +2005;11;15;319;0;0;0 +2005;11;16;320;0;0;0 +2005;11;17;321;0;0;0 +2005;11;18;322;0;0;0 +2005;11;19;323;0;0;0 +2005;11;20;324;0;0;0 +2005;11;21;325;0;0;0 +2005;11;22;326;0;0;0 +2005;11;23;327;0;0;0 +2005;11;24;328;0;0;0 +2005;11;25;329;0;0;0 +2005;11;26;330;0;0;0 +2005;11;27;331;0;0;0 +2005;11;28;332;0;0;0 +2005;11;29;333;0;0;0 +2005;11;30;334;0;0;0 +2005;12;1;335;0;0;0 +2005;12;2;336;0;0;0 +2005;12;3;337;0;0;0 +2005;12;4;338;0;0;0 +2005;12;5;339;0;0;0 +2005;12;6;340;0;0;0 +2005;12;7;341;0;0;0 +2005;12;8;342;0;0;0 +2005;12;9;343;0;0;0 +2005;12;10;344;0;0;0 +2005;12;11;345;0;0;0 +2005;12;12;346;0;0;0 +2005;12;13;347;0;0;0 +2005;12;14;348;0;0;0 +2005;12;15;349;0;0;0 +2005;12;16;350;0;0;0 +2005;12;17;351;0.00001;0;0 +2005;12;18;352;0.00004;0;0 +2005;12;19;353;0.00005;0;0 +2005;12;20;354;0.00005;0;0 +2005;12;21;355;0.00005;0;0 +2005;12;22;356;0.00006;0;0 +2005;12;23;357;0.00006;0;0 +2005;12;24;358;0.00006;0;0 +2005;12;25;359;0.00006;0;0 +2005;12;26;360;0.00006;0;0 +2005;12;27;361;0.00007;0;0 +2005;12;28;362;0.00007;0;0 +2005;12;29;363;0.00007;0;0 +2005;12;30;364;0.00007;0;0 +2005;12;31;365;0.00009;0;0 +2006;1;1;1;0.00013;0.00001;0 +2006;1;2;2;0.00017;0.00001;0 +2006;1;3;3;0.00021;0.00001;0 +2006;1;4;4;0.00024;0.00001;0 +2006;1;5;5;0.00027;0.00001;0 +2006;1;6;6;0.00028;0.00002;0 +2006;1;7;7;0.00031;0.00002;0 +2006;1;8;8;0.00036;0.00002;0 +2006;1;9;9;0.00044;0.00003;0 +2006;1;10;10;0.00051;0.00004;0 +2006;1;11;11;0.00058;0.00004;0 +2006;1;12;12;0.00059;0.00005;0 +2006;1;13;13;0.00066;0.00007;0 +2006;1;14;14;0.00072;0.00008;0 +2006;1;15;15;0.00081;0.00011;0 +2006;1;16;16;0.00086;0.00011;0 +2006;1;17;17;0.00092;0.00013;0 +2006;1;18;18;0.00101;0.00014;0 +2006;1;19;19;0.00114;0.00016;0 +2006;1;20;20;0.00131;0.00019;0 +2006;1;21;21;0.00141;0.00021;0 +2006;1;22;22;0.00158;0.00027;0 +2006;1;23;23;0.00168;0.00032;0 +2006;1;24;24;0.00175;0.00035;0 +2006;1;25;25;0.00185;0.0004;0 +2006;1;26;26;0.00202;0.00044;0 +2006;1;27;27;0.00202;0.00044;0 +2006;1;28;28;0.0021;0.00045;0 +2006;1;29;29;0.0021;0.00045;0 +2006;1;30;30;0.0021;0.00045;0 +2006;1;31;31;0.00216;0.00046;0 +2006;2;1;32;0.00227;0.00048;0 +2006;2;2;33;0.00247;0.00054;0 +2006;2;3;34;0.00268;0.00056;0 +2006;2;4;35;0.00271;0.00056;0 +2006;2;5;36;0.00275;0.00058;0 +2006;2;6;37;0.00278;0.0006;0 +2006;2;7;38;0.00284;0.00063;0 +2006;2;8;39;0.00296;0.00066;0 +2006;2;9;40;0.003;0.00067;0 +2006;2;10;41;0.00319;0.00079;0 +2006;2;11;42;0.00334;0.00088;0 +2006;2;12;43;0.00342;0.00094;0 +2006;2;13;44;0.00351;0.00099;0 +2006;2;14;45;0.00381;0.00108;0 +2006;2;15;46;0.00405;0.00114;0 +2006;2;16;47;0.00436;0.00121;0 +2006;2;17;48;0.00493;0.00145;0 +2006;2;18;49;0.00557;0.00179;0 +2006;2;19;50;0.00623;0.00205;0 +2006;2;20;51;0.00697;0.00242;0 +2006;2;21;52;0.00774;0.00274;0 +2006;2;22;53;0.00837;0.00297;0 +2006;2;23;54;0.00881;0.00318;0 +2006;2;24;55;0.00936;0.00353;0 +2006;2;25;56;0.0099;0.00395;0 +2006;2;26;57;0.01028;0.00414;0 +2006;2;27;58;0.01102;0.00438;0 +2006;2;28;59;0.01137;0.0046;0 +2006;3;1;60;0.01168;0.00478;0 +2006;3;2;61;0.01255;0.00523;0 +2006;3;3;62;0.01349;0.00566;0 +2006;3;4;63;0.01516;0.00622;0 +2006;3;5;64;0.017;0.00676;0 +2006;3;6;65;0.01752;0.00701;0 +2006;3;7;66;0.01866;0.00753;0 +2006;3;8;67;0.02009;0.00797;0 +2006;3;9;68;0.02245;0.00843;0 +2006;3;10;69;0.02558;0.00894;0 +2006;3;11;70;0.02766;0.00993;0 +2006;3;12;71;0.02994;0.01059;0 +2006;3;13;72;0.03241;0.01273;0 +2006;3;14;73;0.03385;0.01415;0 +2006;3;15;74;0.03612;0.01591;0 +2006;3;16;75;0.03946;0.01837;0 +2006;3;17;76;0.04327;0.0207;0 +2006;3;18;77;0.04778;0.02203;0 +2006;3;19;78;0.05367;0.0248;0 +2006;3;20;79;0.0606;0.02833;0 +2006;3;21;80;0.06978;0.03188;0 +2006;3;22;81;0.08053;0.03421;0 +2006;3;23;82;0.09021;0.03736;0 +2006;3;24;83;0.09981;0.04113;0 +2006;3;25;84;0.11319;0.0463;0 +2006;3;26;85;0.13011;0.05113;0 +2006;3;27;86;0.147;0.05534;0 +2006;3;28;87;0.16612;0.06011;0 +2006;3;29;88;0.18145;0.08173;0 +2006;3;30;89;0.1988;0.10217;0 +2006;3;31;90;0.22142;0.13222;0 +2006;4;1;91;0.24789;0.14675;0 +2006;4;2;92;0.2697;0.17671;0 +2006;4;3;93;0.29078;0.20442;0 +2006;4;4;94;0.31315;0.24697;0 +2006;4;5;95;0.33292;0.27989;0 +2006;4;6;96;0.35802;0.33168;0 +2006;4;7;97;0.37632;0.3778;0 +2006;4;8;98;0.39743;0.41769;0 +2006;4;9;99;0.42321;0.45251;0 +2006;4;10;100;0.45261;0.48765;0 +2006;4;11;101;0.47031;0.53822;0 +2006;4;12;102;0.48636;0.57094;0 +2006;4;13;103;0.50534;0.62199;0 +2006;4;14;104;0.53021;0.68286;0 +2006;4;15;105;0.55857;0.71586;0 +2006;4;16;106;0.59314;0.76852;0 +2006;4;17;107;0.62515;0.81912;0 +2006;4;18;108;0.65464;0.86138;0 +2006;4;19;109;0.68449;0.93814;0 +2006;4;20;110;0.71285;1.01556;0 +2006;4;21;111;0.74927;1.09391;0 +2006;4;22;112;0.78687;1.1717;0 +2006;4;23;113;0.83019;1.23468;0 +2006;4;24;114;0.86886;1.30116;0 +2006;4;25;115;0.90943;1.34275;0 +2006;4;26;116;0.9446;1.41605;0 +2006;4;27;117;0.9866;1.45302;0 +2006;4;28;118;1.023;1.51117;0 +2006;4;29;119;1.05682;1.592;0 +2006;4;30;120;1.09102;1.68882;0 +2006;5;1;121;1.11955;1.77457;0 +2006;5;2;122;1.15335;1.86474;0 +2006;5;3;123;1.19538;1.9549;0 +2006;5;4;124;1.24183;2.03981;0 +2006;5;5;125;1.28929;2.08836;0 +2006;5;6;126;1.3338;2.13939;0 +2006;5;7;127;1.37886;2.20868;0 +2006;5;8;128;1.42373;2.2466;0 +2006;5;9;129;1.45164;2.33757;0 +2006;5;10;130;1.48099;2.43332;0 +2006;5;11;131;1.51834;2.55021;0 +2006;5;12;132;1.55121;2.61719;0 +2006;5;13;133;1.59624;2.67513;0 +2006;5;14;134;1.6348;2.78089;0 +2006;5;15;135;1.67634;2.87309;0 +2006;5;16;136;1.67314;2.97507;0 +2006;5;17;137;1.67148;3.07178;0 +2006;5;18;138;1.66769;3.09473;0 +2006;5;19;139;1.66378;3.16544;0 +2006;5;20;140;1.65583;3.24504;0 +2006;5;21;141;1.64802;3.33689;0 +2006;5;22;142;1.63674;3.37897;0 +2006;5;23;143;1.62009;3.43023;0 +2006;5;24;144;1.60634;3.52673;0 +2006;5;25;145;1.57319;3.62132;0.0539396 +2006;5;26;146;1.53524;3.6931;0.235543 +2006;5;27;147;1.48927;3.78712;0.4734136 +2006;5;28;148;1.42166;3.87868;0.7050604 +2006;5;29;149;1.3527;3.93541;0.8485873 +2006;5;30;150;1.27253;4.01;1.0373 +2006;5;31;151;1.17584;4.08481;1.2265693 +2006;6;1;152;1.12796;4.16733;1.4353449 +2006;6;2;153;1.04906;4.2427;1.626031 +2006;6;3;154;0.96216;4.32231;1.8274443 +2006;6;4;155;0.86845;4.3962;2.014386 +2006;6;5;156;0.774;4.46613;2.1913089 +2006;6;6;157;0.7418;4.53399;2.3629947 +2006;6;7;158;0.65332;4.59612;2.5201836 +2006;6;8;159;0.52692;4.64771;2.6507063 +2006;6;9;160;0.45515;4.69264;2.7643792 +2006;6;10;161;0.34334;4.72451;2.8450103 +2006;6;11;162;0.21364;4.74821;2.9049713 +2006;6;12;163;0.05168;4.75592;2.9244776 +2006;6;13;164;0;4.75592;2.9244776 +2006;6;14;165;0;4.75592;2.9244776 +2006;6;15;166;0;4.75592;2.9244776 +2006;6;16;167;0;4.75592;2.9244776 +2006;6;17;168;0;4.75592;2.9244776 +2006;6;18;169;0;4.75592;2.9244776 +2006;6;19;170;0;4.75592;2.9244776 +2006;6;20;171;0;4.75592;2.9244776 +2006;6;21;172;0;4.75592;2.9244776 +2006;6;22;173;0;4.75592;2.9244776 +2006;6;23;174;0;4.75592;2.9244776 +2006;6;24;175;0;4.75592;2.9244776 +2006;6;25;176;0;4.75592;2.9244776 +2006;6;26;177;0;4.75592;2.9244776 +2006;6;27;178;0;4.75592;2.9244776 +2006;6;28;179;0;4.75592;2.9244776 +2006;6;29;180;0;4.75592;2.9244776 +2006;6;30;181;0;4.75592;2.9244776 +2006;7;1;182;0;4.75592;2.9244776 +2006;7;2;183;0;4.75592;2.9244776 +2006;7;3;184;0;4.75592;2.9244776 +2006;7;4;185;0;4.75592;2.9244776 +2006;7;5;186;0;4.75592;2.9244776 +2006;7;6;187;0;4.75592;2.9244776 +2006;7;7;188;0;4.75592;2.9244776 +2006;7;8;189;0;4.75592;2.9244776 +2006;7;9;190;0;4.75592;2.9244776 +2006;7;10;191;0;4.75592;2.9244776 +2006;7;11;192;0;4.75592;2.9244776 +2006;7;12;193;0;4.75592;2.9244776 +2006;7;13;194;0;4.75592;2.9244776 +2006;7;14;195;0;4.75592;2.9244776 +2006;7;15;196;0;4.75592;2.9244776 +2006;7;16;197;0;4.75592;2.9244776 +2006;7;17;198;0;4.75592;2.9244776 +2006;7;18;199;0;4.75592;2.9244776 +2006;7;19;200;0;4.75592;2.9244776 +2006;7;20;201;0;4.75592;2.9244776 +2006;7;21;202;0;4.75592;2.9244776 +2006;7;22;203;0;4.75592;2.9244776 +2006;7;23;204;0;4.75592;2.9244776 +2006;7;24;205;0;4.75592;2.9244776 +2006;7;25;206;0;4.75592;2.9244776 +2006;7;26;207;0;4.75592;2.9244776 +2006;7;27;208;0;4.75592;2.9244776 +2006;7;28;209;0;4.75592;2.9244776 +2006;7;29;210;0;4.75592;2.9244776 +2006;7;30;211;0;4.75592;2.9244776 +2006;7;31;212;0;4.75592;2.9244776 +2006;8;1;213;0;4.75592;2.9244776 diff --git a/inst/extdata/stics_example_1/mod_spIC_Wheat_Pea_2005-2006_N0.sti b/inst/extdata/stics_example_1/mod_spIC_Wheat_Pea_2005-2006_N0.sti index 8e10bbf1..d1da2833 100644 --- a/inst/extdata/stics_example_1/mod_spIC_Wheat_Pea_2005-2006_N0.sti +++ b/inst/extdata/stics_example_1/mod_spIC_Wheat_Pea_2005-2006_N0.sti @@ -1,311 +1,311 @@ -ian;mo;jo;jul;lai(n);masec(n) -2005; 9;26;269; 0.00000; 0.00000 -2005; 9;27;270; 0.00000; 0.00000 -2005; 9;28;271; 0.00000; 0.00000 -2005; 9;29;272; 0.00000; 0.00000 -2005; 9;30;273; 0.00000; 0.00000 -2005;10; 1;274; 0.00000; 0.00000 -2005;10; 2;275; 0.00000; 0.00000 -2005;10; 3;276; 0.00000; 0.00000 -2005;10; 4;277; 0.00000; 0.00000 -2005;10; 5;278; 0.00000; 0.00000 -2005;10; 6;279; 0.00000; 0.00000 -2005;10; 7;280; 0.00000; 0.00000 -2005;10; 8;281; 0.00000; 0.00000 -2005;10; 9;282; 0.00000; 0.00000 -2005;10;10;283; 0.00000; 0.00000 -2005;10;11;284; 0.00000; 0.00000 -2005;10;12;285; 0.00000; 0.00000 -2005;10;13;286; 0.00000; 0.00000 -2005;10;14;287; 0.00000; 0.00000 -2005;10;15;288; 0.00000; 0.00000 -2005;10;16;289; 0.00000; 0.00000 -2005;10;17;290; 0.00000; 0.00000 -2005;10;18;291; 0.00000; 0.00000 -2005;10;19;292; 0.00000; 0.00000 -2005;10;20;293; 0.00000; 0.00000 -2005;10;21;294; 0.00000; 0.00000 -2005;10;22;295; 0.00000; 0.00000 -2005;10;23;296; 0.00000; 0.00000 -2005;10;24;297; 0.00000; 0.00000 -2005;10;25;298; 0.00000; 0.00000 -2005;10;26;299; 0.00000; 0.00000 -2005;10;27;300; 0.00000; 0.00000 -2005;10;28;301; 0.00000; 0.00000 -2005;10;29;302; 0.00000; 0.00000 -2005;10;30;303; 0.00000; 0.00000 -2005;10;31;304; 0.00000; 0.00000 -2005;11; 1;305; 0.00000; 0.00000 -2005;11; 2;306; 0.00000; 0.00000 -2005;11; 3;307; 0.00000; 0.00000 -2005;11; 4;308; 0.00000; 0.00000 -2005;11; 5;309; 0.00000; 0.00000 -2005;11; 6;310; 0.00000; 0.00000 -2005;11; 7;311; 0.00000; 0.00000 -2005;11; 8;312; 0.00000; 0.00000 -2005;11; 9;313; 0.00000; 0.00000 -2005;11;10;314; 0.00000; 0.00000 -2005;11;11;315; 0.00000; 0.00000 -2005;11;12;316; 0.00000; 0.00000 -2005;11;13;317; 0.00000; 0.00000 -2005;11;14;318; 0.00000; 0.00000 -2005;11;15;319; 0.00000; 0.00000 -2005;11;16;320; 0.00000; 0.00000 -2005;11;17;321; 0.00000; 0.00000 -2005;11;18;322; 0.00000; 0.00000 -2005;11;19;323; 0.00000; 0.00000 -2005;11;20;324; 0.00000; 0.00000 -2005;11;21;325; 0.00000; 0.00000 -2005;11;22;326; 0.00000; 0.00000 -2005;11;23;327; 0.00000; 0.00000 -2005;11;24;328; 0.00000; 0.00000 -2005;11;25;329; 0.00000; 0.00000 -2005;11;26;330; 0.00000; 0.00000 -2005;11;27;331; 0.00000; 0.00000 -2005;11;28;332; 0.00000; 0.00000 -2005;11;29;333; 0.00009; 0.00000 -2005;11;30;334; 0.00061; 0.00002 -2005;12; 1;335; 0.00084; 0.00003 -2005;12; 2;336; 0.00119; 0.00004 -2005;12; 3;337; 0.00196; 0.00011 -2005;12; 4;338; 0.00257; 0.00016 -2005;12; 5;339; 0.00336; 0.00020 -2005;12; 6;340; 0.00423; 0.00026 -2005;12; 7;341; 0.00508; 0.00035 -2005;12; 8;342; 0.00596; 0.00041 -2005;12; 9;343; 0.00689; 0.00056 -2005;12;10;344; 0.00802; 0.00085 -2005;12;11;345; 0.00827; 0.00087 -2005;12;12;346; 0.00827; 0.00087 -2005;12;13;347; 0.00831; 0.00088 -2005;12;14;348; 0.00844; 0.00091 -2005;12;15;349; 0.00896; 0.00098 -2005;12;16;350; 0.00963; 0.00108 -2005;12;17;351; 0.01073; 0.00123 -2005;12;18;352; 0.01214; 0.00174 -2005;12;19;353; 0.01237; 0.00187 -2005;12;20;354; 0.01252; 0.00196 -2005;12;21;355; 0.01260; 0.00200 -2005;12;22;356; 0.01271; 0.00202 -2005;12;23;357; 0.01271; 0.00202 -2005;12;24;358; 0.01271; 0.00203 -2005;12;25;359; 0.01302; 0.00211 -2005;12;26;360; 0.01303; 0.00211 -2005;12;27;361; 0.01323; 0.00213 -2005;12;28;362; 0.01323; 0.00214 -2005;12;29;363; 0.01334; 0.00220 -2005;12;30;364; 0.01334; 0.00220 -2005;12;31;365; 0.01422; 0.00233 -2006; 1; 1; 1; 0.01599; 0.00271 -2006; 1; 2; 2; 0.01747; 0.00291 -2006; 1; 3; 3; 0.01914; 0.00306 -2006; 1; 4; 4; 0.02052; 0.00343 -2006; 1; 5; 5; 0.02156; 0.00368 -2006; 1; 6; 6; 0.02208; 0.00382 -2006; 1; 7; 7; 0.02318; 0.00399 -2006; 1; 8; 8; 0.02522; 0.00468 -2006; 1; 9; 9; 0.02749; 0.00503 -2006; 1;10; 10; 0.02969; 0.00562 -2006; 1;11; 11; 0.03152; 0.00597 -2006; 1;12; 12; 0.03191; 0.00622 -2006; 1;13; 13; 0.03417; 0.00759 -2006; 1;14; 14; 0.03555; 0.00830 -2006; 1;15; 15; 0.03752; 0.00933 -2006; 1;16; 16; 0.03857; 0.00969 -2006; 1;17; 17; 0.04023; 0.01037 -2006; 1;18; 18; 0.04224; 0.01078 -2006; 1;19; 19; 0.04551; 0.01187 -2006; 1;20; 20; 0.04876; 0.01271 -2006; 1;21; 21; 0.05073; 0.01339 -2006; 1;22; 22; 0.05396; 0.01527 -2006; 1;23; 23; 0.05564; 0.01661 -2006; 1;24; 24; 0.05665; 0.01749 -2006; 1;25; 25; 0.05845; 0.01890 -2006; 1;26; 26; 0.06119; 0.02002 -2006; 1;27; 27; 0.06119; 0.02002 -2006; 1;28; 28; 0.06312; 0.02065 -2006; 1;29; 29; 0.06312; 0.02066 -2006; 1;30; 30; 0.06312; 0.02067 -2006; 1;31; 31; 0.06472; 0.02095 -2006; 2; 1; 32; 0.06760; 0.02181 -2006; 2; 2; 33; 0.07147; 0.02376 -2006; 2; 3; 34; 0.07475; 0.02424 -2006; 2; 4; 35; 0.07545; 0.02438 -2006; 2; 5; 36; 0.07653; 0.02489 -2006; 2; 6; 37; 0.07731; 0.02578 -2006; 2; 7; 38; 0.07850; 0.02676 -2006; 2; 8; 39; 0.08050; 0.02779 -2006; 2; 9; 40; 0.08113; 0.02811 -2006; 2;10; 41; 0.08582; 0.03252 -2006; 2;11; 42; 0.08785; 0.03469 -2006; 2;12; 43; 0.08849; 0.03607 -2006; 2;13; 44; 0.08969; 0.03749 -2006; 2;14; 45; 0.09396; 0.03957 -2006; 2;15; 46; 0.09663; 0.04071 -2006; 2;16; 47; 0.10087; 0.04221 -2006; 2;17; 48; 0.10867; 0.04643 -2006; 2;18; 49; 0.11597; 0.05134 -2006; 2;19; 50; 0.12329; 0.05487 -2006; 2;20; 51; 0.13165; 0.05987 -2006; 2;21; 52; 0.13900; 0.06394 -2006; 2;22; 53; 0.14657; 0.06721 -2006; 2;23; 54; 0.15215; 0.07056 -2006; 2;24; 55; 0.15918; 0.07582 -2006; 2;25; 56; 0.16560; 0.08179 -2006; 2;26; 57; 0.16951; 0.08461 -2006; 2;27; 58; 0.17842; 0.08800 -2006; 2;28; 59; 0.18181; 0.09147 -2006; 3; 1; 60; 0.18415; 0.09423 -2006; 3; 2; 61; 0.19544; 0.10053 -2006; 3; 3; 62; 0.20635; 0.10594 -2006; 3; 4; 63; 0.22579; 0.11171 -2006; 3; 5; 64; 0.24712; 0.11711 -2006; 3; 6; 65; 0.25319; 0.12042 -2006; 3; 7; 66; 0.26762; 0.12743 -2006; 3; 8; 67; 0.28454; 0.13256 -2006; 3; 9; 68; 0.31340; 0.13748 -2006; 3;10; 69; 0.31636; 0.14431 -2006; 3;11; 70; 0.31832; 0.15921 -2006; 3;12; 71; 0.31938; 0.16762 -2006; 3;13; 72; 0.31983; 0.19428 -2006; 3;14; 73; 0.31952; 0.21176 -2006; 3;15; 74; 0.31837; 0.23239 -2006; 3;16; 75; 0.32013; 0.25736 -2006; 3;17; 76; 0.32277; 0.27939 -2006; 3;18; 77; 0.32543; 0.29168 -2006; 3;19; 78; 0.32869; 0.31509 -2006; 3;20; 79; 0.33005; 0.34021 -2006; 3;21; 80; 0.33585; 0.36283 -2006; 3;22; 81; 0.34447; 0.37828 -2006; 3;23; 82; 0.35074; 0.39965 -2006; 3;24; 83; 0.35751; 0.42369 -2006; 3;25; 84; 0.36560; 0.45171 -2006; 3;26; 85; 0.37754; 0.49860 -2006; 3;27; 86; 0.38807; 0.53413 -2006; 3;28; 87; 0.39860; 0.57198 -2006; 3;29; 88; 0.40418; 0.62750 -2006; 3;30; 89; 0.41282; 0.67426 -2006; 3;31; 90; 0.42666; 0.73684 -2006; 4; 1; 91; 0.44334; 0.76423 -2006; 4; 2; 92; 0.45426; 0.82151 -2006; 4; 3; 93; 0.46830; 0.86977 -2006; 4; 4; 94; 0.48133; 0.94025 -2006; 4; 5; 95; 0.49429; 0.99383 -2006; 4; 6; 96; 0.50927; 1.07188 -2006; 4; 7; 97; 0.51855; 1.14754 -2006; 4; 8; 98; 0.52862; 1.20776 -2006; 4; 9; 99; 0.54168; 1.25701 -2006; 4;10;100; 0.56015; 1.30587 -2006; 4;11;101; 0.56994; 1.38917 -2006; 4;12;102; 0.57824; 1.44202 -2006; 4;13;103; 0.59015; 1.52253 -2006; 4;14;104; 0.59951; 1.60469 -2006; 4;15;105; 0.61647; 1.64661 -2006; 4;16;106; 0.63832; 1.71710 -2006; 4;17;107; 0.65088; 1.78081 -2006; 4;18;108; 0.66512; 1.83359 -2006; 4;19;109; 0.66794; 1.93071 -2006; 4;20;110; 0.67752; 2.02409 -2006; 4;21;111; 0.69108; 2.11455 -2006; 4;22;112; 0.69737; 2.20231 -2006; 4;23;113; 0.71893; 2.27262 -2006; 4;24;114; 0.72987; 2.34652 -2006; 4;25;115; 0.75122; 2.39183 -2006; 4;26;116; 0.76462; 2.47599 -2006; 4;27;117; 0.78238; 2.51536 -2006; 4;28;118; 0.79493; 2.58839 -2006; 4;29;119; 0.78565; 2.68442 -2006; 4;30;120; 0.78549; 2.79570 -2006; 5; 1;121; 0.78218; 2.89655 -2006; 5; 2;122; 0.78603; 2.99695 -2006; 5; 3;123; 0.77991; 3.09342 -2006; 5; 4;124; 0.80660; 3.18503 -2006; 5; 5;125; 0.83438; 3.23679 -2006; 5; 6;126; 0.85977; 3.29390 -2006; 5; 7;127; 0.88691; 3.37302 -2006; 5; 8;128; 0.88096; 3.41439 -2006; 5; 9;129; 0.87719; 3.52908 -2006; 5;10;130; 0.86607; 3.64011 -2006; 5;11;131; 0.85843; 3.76138 -2006; 5;12;132; 0.84089; 3.83183 -2006; 5;13;133; 0.83275; 3.88793 -2006; 5;14;134; 0.80794; 4.00060 -2006; 5;15;135; 0.79540; 4.09487 -2006; 5;16;136; 0.77080; 4.20034 -2006; 5;17;137; 0.75893; 4.30113 -2006; 5;18;138; 0.74341; 4.32487 -2006; 5;19;139; 0.71025; 4.40538 -2006; 5;20;140; 0.69622; 4.48667 -2006; 5;21;141; 0.68127; 4.57947 -2006; 5;22;142; 0.66831; 4.60381 -2006; 5;23;143; 0.63956; 4.64685 -2006; 5;24;144; 0.62563; 4.72140 -2006; 5;25;145; 0.60858; 4.79049 -2006; 5;26;146; 0.58903; 4.84264 -2006; 5;27;147; 0.56697; 4.91200 -2006; 5;28;148; 0.55443; 4.97936 -2006; 5;29;149; 0.53835; 5.02255 -2006; 5;30;150; 0.52023; 5.08096 -2006; 5;31;151; 0.49696; 5.13884 -2006; 6; 1;152; 0.47634; 5.20362 -2006; 6; 2;153; 0.43767; 5.26098 -2006; 6; 3;154; 0.41993; 5.32336 -2006; 6; 4;155; 0.39712; 5.38268 -2006; 6; 5;156; 0.37359; 5.44106 -2006; 6; 6;157; 0.34646; 5.49739 -2006; 6; 7;158; 0.32190; 5.55132 -2006; 6; 8;159; 0.29612; 5.60224 -2006; 6; 9;160; 0.24691; 5.64726 -2006; 6;10;161; 0.22291; 5.68532 -2006; 6;11;162; 0.20166; 5.72814 -2006; 6;12;163; 0.18049; 5.76961 -2006; 6;13;164; 0.16299; 5.80874 -2006; 6;14;165; 0.14220; 5.84565 -2006; 6;15;166; 0.11619; 5.87587 -2006; 6;16;167; 0.08754; 5.89879 -2006; 6;17;168; 0.05782; 5.92544 -2006; 6;18;169; 0.00000; 5.93899 -2006; 6;19;170; 0.00000; 5.96796 -2006; 6;20;171; 0.00000; 5.98374 -2006; 6;21;172; 0.00000; 6.00259 -2006; 6;22;173; 0.00000; 6.01506 -2006; 6;23;174; 0.00000; 6.04898 -2006; 6;24;175; 0.00000; 6.04898 -2006; 6;25;176; 0.00000; 6.04898 -2006; 6;26;177; 0.00000; 6.04898 -2006; 6;27;178; 0.00000; 6.04898 -2006; 6;28;179; 0.00000; 6.04898 -2006; 6;29;180; 0.00000; 6.04898 -2006; 6;30;181; 0.00000; 6.04898 -2006; 7; 1;182; 0.00000; 6.04898 -2006; 7; 2;183; 0.00000; 6.04898 -2006; 7; 3;184; 0.00000; 6.04898 -2006; 7; 4;185; 0.00000; 6.04898 -2006; 7; 5;186; 0.00000; 6.04898 -2006; 7; 6;187; 0.00000; 6.04898 -2006; 7; 7;188; 0.00000; 6.04898 -2006; 7; 8;189; 0.00000; 6.04898 -2006; 7; 9;190; 0.00000; 6.04898 -2006; 7;10;191; 0.00000; 6.04898 -2006; 7;11;192; 0.00000; 6.04898 -2006; 7;12;193; 0.00000; 6.04898 -2006; 7;13;194; 0.00000; 6.04898 -2006; 7;14;195; 0.00000; 6.04898 -2006; 7;15;196; 0.00000; 6.04898 -2006; 7;16;197; 0.00000; 6.04898 -2006; 7;17;198; 0.00000; 6.04898 -2006; 7;18;199; 0.00000; 6.04898 -2006; 7;19;200; 0.00000; 6.04898 -2006; 7;20;201; 0.00000; 6.04898 -2006; 7;21;202; 0.00000; 6.04898 -2006; 7;22;203; 0.00000; 6.04898 -2006; 7;23;204; 0.00000; 6.04898 -2006; 7;24;205; 0.00000; 6.04898 -2006; 7;25;206; 0.00000; 6.04898 -2006; 7;26;207; 0.00000; 6.04898 -2006; 7;27;208; 0.00000; 6.04898 -2006; 7;28;209; 0.00000; 6.04898 -2006; 7;29;210; 0.00000; 6.04898 -2006; 7;30;211; 0.00000; 6.04898 -2006; 7;31;212; 0.00000; 6.04898 -2006; 8; 1;213; 0.00000; 6.04898 +ian;mo;jo;jul;lai(n);masec(n);mafruit +2005;9;26;269;0;0;0 +2005;9;27;270;0;0;0 +2005;9;28;271;0;0;0 +2005;9;29;272;0;0;0 +2005;9;30;273;0;0;0 +2005;10;1;274;0;0;0 +2005;10;2;275;0;0;0 +2005;10;3;276;0;0;0 +2005;10;4;277;0;0;0 +2005;10;5;278;0;0;0 +2005;10;6;279;0;0;0 +2005;10;7;280;0;0;0 +2005;10;8;281;0;0;0 +2005;10;9;282;0;0;0 +2005;10;10;283;0;0;0 +2005;10;11;284;0;0;0 +2005;10;12;285;0;0;0 +2005;10;13;286;0;0;0 +2005;10;14;287;0;0;0 +2005;10;15;288;0;0;0 +2005;10;16;289;0;0;0 +2005;10;17;290;0;0;0 +2005;10;18;291;0;0;0 +2005;10;19;292;0;0;0 +2005;10;20;293;0;0;0 +2005;10;21;294;0;0;0 +2005;10;22;295;0;0;0 +2005;10;23;296;0;0;0 +2005;10;24;297;0;0;0 +2005;10;25;298;0;0;0 +2005;10;26;299;0;0;0 +2005;10;27;300;0;0;0 +2005;10;28;301;0;0;0 +2005;10;29;302;0;0;0 +2005;10;30;303;0;0;0 +2005;10;31;304;0;0;0 +2005;11;1;305;0;0;0 +2005;11;2;306;0;0;0 +2005;11;3;307;0;0;0 +2005;11;4;308;0;0;0 +2005;11;5;309;0;0;0 +2005;11;6;310;0;0;0 +2005;11;7;311;0;0;0 +2005;11;8;312;0;0;0 +2005;11;9;313;0;0;0 +2005;11;10;314;0;0;0 +2005;11;11;315;0;0;0 +2005;11;12;316;0;0;0 +2005;11;13;317;0;0;0 +2005;11;14;318;0;0;0 +2005;11;15;319;0;0;0 +2005;11;16;320;0;0;0 +2005;11;17;321;0;0;0 +2005;11;18;322;0;0;0 +2005;11;19;323;0;0;0 +2005;11;20;324;0;0;0 +2005;11;21;325;0;0;0 +2005;11;22;326;0;0;0 +2005;11;23;327;0;0;0 +2005;11;24;328;0;0;0 +2005;11;25;329;0;0;0 +2005;11;26;330;0;0;0 +2005;11;27;331;0;0;0 +2005;11;28;332;0;0;0 +2005;11;29;333;0.00009;0;0 +2005;11;30;334;0.00061;0.00002;0 +2005;12;1;335;0.00084;0.00003;0 +2005;12;2;336;0.00119;0.00004;0 +2005;12;3;337;0.00196;0.00011;0 +2005;12;4;338;0.00257;0.00016;0 +2005;12;5;339;0.00336;0.0002;0 +2005;12;6;340;0.00423;0.00026;0 +2005;12;7;341;0.00508;0.00035;0 +2005;12;8;342;0.00596;0.00041;0 +2005;12;9;343;0.00689;0.00056;0 +2005;12;10;344;0.00802;0.00085;0 +2005;12;11;345;0.00827;0.00087;0 +2005;12;12;346;0.00827;0.00087;0 +2005;12;13;347;0.00831;0.00088;0 +2005;12;14;348;0.00844;0.00091;0 +2005;12;15;349;0.00896;0.00098;0 +2005;12;16;350;0.00963;0.00108;0 +2005;12;17;351;0.01073;0.00123;0 +2005;12;18;352;0.01214;0.00174;0 +2005;12;19;353;0.01237;0.00187;0 +2005;12;20;354;0.01252;0.00196;0 +2005;12;21;355;0.0126;0.002;0 +2005;12;22;356;0.01271;0.00202;0 +2005;12;23;357;0.01271;0.00202;0 +2005;12;24;358;0.01271;0.00203;0 +2005;12;25;359;0.01302;0.00211;0 +2005;12;26;360;0.01303;0.00211;0 +2005;12;27;361;0.01323;0.00213;0 +2005;12;28;362;0.01323;0.00214;0 +2005;12;29;363;0.01334;0.0022;0 +2005;12;30;364;0.01334;0.0022;0 +2005;12;31;365;0.01422;0.00233;0 +2006;1;1;1;0.01599;0.00271;0 +2006;1;2;2;0.01747;0.00291;0 +2006;1;3;3;0.01914;0.00306;0 +2006;1;4;4;0.02052;0.00343;0 +2006;1;5;5;0.02156;0.00368;0 +2006;1;6;6;0.02208;0.00382;0 +2006;1;7;7;0.02318;0.00399;0 +2006;1;8;8;0.02522;0.00468;0 +2006;1;9;9;0.02749;0.00503;0 +2006;1;10;10;0.02969;0.00562;0 +2006;1;11;11;0.03152;0.00597;0 +2006;1;12;12;0.03191;0.00622;0 +2006;1;13;13;0.03417;0.00759;0 +2006;1;14;14;0.03555;0.0083;0 +2006;1;15;15;0.03752;0.00933;0 +2006;1;16;16;0.03857;0.00969;0 +2006;1;17;17;0.04023;0.01037;0 +2006;1;18;18;0.04224;0.01078;0 +2006;1;19;19;0.04551;0.01187;0 +2006;1;20;20;0.04876;0.01271;0 +2006;1;21;21;0.05073;0.01339;0 +2006;1;22;22;0.05396;0.01527;0 +2006;1;23;23;0.05564;0.01661;0 +2006;1;24;24;0.05665;0.01749;0 +2006;1;25;25;0.05845;0.0189;0 +2006;1;26;26;0.06119;0.02002;0 +2006;1;27;27;0.06119;0.02002;0 +2006;1;28;28;0.06312;0.02065;0 +2006;1;29;29;0.06312;0.02066;0 +2006;1;30;30;0.06312;0.02067;0 +2006;1;31;31;0.06472;0.02095;0 +2006;2;1;32;0.0676;0.02181;0 +2006;2;2;33;0.07147;0.02376;0 +2006;2;3;34;0.07475;0.02424;0 +2006;2;4;35;0.07545;0.02438;0 +2006;2;5;36;0.07653;0.02489;0 +2006;2;6;37;0.07731;0.02578;0 +2006;2;7;38;0.0785;0.02676;0 +2006;2;8;39;0.0805;0.02779;0 +2006;2;9;40;0.08113;0.02811;0 +2006;2;10;41;0.08582;0.03252;0 +2006;2;11;42;0.08785;0.03469;0 +2006;2;12;43;0.08849;0.03607;0 +2006;2;13;44;0.08969;0.03749;0 +2006;2;14;45;0.09396;0.03957;0 +2006;2;15;46;0.09663;0.04071;0 +2006;2;16;47;0.10087;0.04221;0 +2006;2;17;48;0.10867;0.04643;0 +2006;2;18;49;0.11597;0.05134;0 +2006;2;19;50;0.12329;0.05487;0 +2006;2;20;51;0.13165;0.05987;0 +2006;2;21;52;0.139;0.06394;0 +2006;2;22;53;0.14657;0.06721;0 +2006;2;23;54;0.15215;0.07056;0 +2006;2;24;55;0.15918;0.07582;0 +2006;2;25;56;0.1656;0.08179;0 +2006;2;26;57;0.16951;0.08461;0 +2006;2;27;58;0.17842;0.088;0 +2006;2;28;59;0.18181;0.09147;0 +2006;3;1;60;0.18415;0.09423;0 +2006;3;2;61;0.19544;0.10053;0 +2006;3;3;62;0.20635;0.10594;0 +2006;3;4;63;0.22579;0.11171;0 +2006;3;5;64;0.24712;0.11711;0 +2006;3;6;65;0.25319;0.12042;0 +2006;3;7;66;0.26762;0.12743;0 +2006;3;8;67;0.28454;0.13256;0 +2006;3;9;68;0.3134;0.13748;0 +2006;3;10;69;0.31636;0.14431;0 +2006;3;11;70;0.31832;0.15921;0 +2006;3;12;71;0.31938;0.16762;0 +2006;3;13;72;0.31983;0.19428;0 +2006;3;14;73;0.31952;0.21176;0 +2006;3;15;74;0.31837;0.23239;0 +2006;3;16;75;0.32013;0.25736;0 +2006;3;17;76;0.32277;0.27939;0 +2006;3;18;77;0.32543;0.29168;0 +2006;3;19;78;0.32869;0.31509;0 +2006;3;20;79;0.33005;0.34021;0 +2006;3;21;80;0.33585;0.36283;0 +2006;3;22;81;0.34447;0.37828;0 +2006;3;23;82;0.35074;0.39965;0 +2006;3;24;83;0.35751;0.42369;0 +2006;3;25;84;0.3656;0.45171;0 +2006;3;26;85;0.37754;0.4986;0 +2006;3;27;86;0.38807;0.53413;0 +2006;3;28;87;0.3986;0.57198;0 +2006;3;29;88;0.40418;0.6275;0 +2006;3;30;89;0.41282;0.67426;0 +2006;3;31;90;0.42666;0.73684;0 +2006;4;1;91;0.44334;0.76423;0 +2006;4;2;92;0.45426;0.82151;0 +2006;4;3;93;0.4683;0.86977;0 +2006;4;4;94;0.48133;0.94025;0 +2006;4;5;95;0.49429;0.99383;0 +2006;4;6;96;0.50927;1.07188;0 +2006;4;7;97;0.51855;1.14754;0 +2006;4;8;98;0.52862;1.20776;0 +2006;4;9;99;0.54168;1.25701;0 +2006;4;10;100;0.56015;1.30587;0 +2006;4;11;101;0.56994;1.38917;0 +2006;4;12;102;0.57824;1.44202;0 +2006;4;13;103;0.59015;1.52253;0 +2006;4;14;104;0.59951;1.60469;0 +2006;4;15;105;0.61647;1.64661;0 +2006;4;16;106;0.63832;1.7171;0 +2006;4;17;107;0.65088;1.78081;0 +2006;4;18;108;0.66512;1.83359;0 +2006;4;19;109;0.66794;1.93071;0 +2006;4;20;110;0.67752;2.02409;0 +2006;4;21;111;0.69108;2.11455;0 +2006;4;22;112;0.69737;2.20231;0 +2006;4;23;113;0.71893;2.27262;0 +2006;4;24;114;0.72987;2.34652;0 +2006;4;25;115;0.75122;2.39183;0 +2006;4;26;116;0.76462;2.47599;0 +2006;4;27;117;0.78238;2.51536;0 +2006;4;28;118;0.79493;2.58839;0 +2006;4;29;119;0.78565;2.68442;0 +2006;4;30;120;0.78549;2.7957;0 +2006;5;1;121;0.78218;2.89655;0 +2006;5;2;122;0.78603;2.99695;0 +2006;5;3;123;0.77991;3.09342;0 +2006;5;4;124;0.8066;3.18503;0 +2006;5;5;125;0.83438;3.23679;0 +2006;5;6;126;0.85977;3.2939;0 +2006;5;7;127;0.88691;3.37302;0 +2006;5;8;128;0.88096;3.41439;0 +2006;5;9;129;0.87719;3.52908;0 +2006;5;10;130;0.86607;3.64011;0 +2006;5;11;131;0.85843;3.76138;0 +2006;5;12;132;0.84089;3.83183;0 +2006;5;13;133;0.83275;3.88793;0 +2006;5;14;134;0.80794;4.0006;0 +2006;5;15;135;0.7954;4.09487;0 +2006;5;16;136;0.7708;4.20034;0 +2006;5;17;137;0.75893;4.30113;0 +2006;5;18;138;0.74341;4.32487;0 +2006;5;19;139;0.71025;4.40538;0 +2006;5;20;140;0.69622;4.48667;0 +2006;5;21;141;0.68127;4.57947;0 +2006;5;22;142;0.66831;4.60381;0 +2006;5;23;143;0.63956;4.64685;0 +2006;5;24;144;0.62563;4.7214;0 +2006;5;25;145;0.60858;4.79049;0 +2006;5;26;146;0.58903;4.84264;0 +2006;5;27;147;0.56697;4.912;0 +2006;5;28;148;0.55443;4.97936;0 +2006;5;29;149;0.53835;5.02255;0.0620125 +2006;5;30;150;0.52023;5.08096;0.22264 +2006;5;31;151;0.49696;5.13884;0.38181 +2006;6;1;152;0.47634;5.20362;0.559955 +2006;6;2;153;0.43767;5.26098;0.717695 +2006;6;3;154;0.41993;5.32336;0.88924 +2006;6;4;155;0.39712;5.38268;1.05237 +2006;6;5;156;0.37359;5.44106;1.212915 +2006;6;6;157;0.34646;5.49739;1.3678225 +2006;6;7;158;0.3219;5.55132;1.51613 +2006;6;8;159;0.29612;5.60224;1.65616 +2006;6;9;160;0.24691;5.64726;1.779965 +2006;6;10;161;0.22291;5.68532;1.88463 +2006;6;11;162;0.20166;5.72814;2.002385 +2006;6;12;163;0.18049;5.76961;2.1164275 +2006;6;13;164;0.16299;5.80874;2.224035 +2006;6;14;165;0.1422;5.84565;2.3255375 +2006;6;15;166;0.11619;5.87587;2.4086425 +2006;6;16;167;0.08754;5.89879;2.4716725 +2006;6;17;168;0.05782;5.92544;2.54496 +2006;6;18;169;0;5.93899;2.5822225 +2006;6;19;170;0;5.96796;2.66189 +2006;6;20;171;0;5.98374;2.705285 +2006;6;21;172;0;6.00259;2.7571225 +2006;6;22;173;0;6.01506;2.791415 +2006;6;23;174;0;6.04898;2.884695 +2006;6;24;175;0;6.04898;2.884695 +2006;6;25;176;0;6.04898;2.884695 +2006;6;26;177;0;6.04898;2.884695 +2006;6;27;178;0;6.04898;2.884695 +2006;6;28;179;0;6.04898;2.884695 +2006;6;29;180;0;6.04898;2.884695 +2006;6;30;181;0;6.04898;2.884695 +2006;7;1;182;0;6.04898;2.884695 +2006;7;2;183;0;6.04898;2.884695 +2006;7;3;184;0;6.04898;2.884695 +2006;7;4;185;0;6.04898;2.884695 +2006;7;5;186;0;6.04898;2.884695 +2006;7;6;187;0;6.04898;2.884695 +2006;7;7;188;0;6.04898;2.884695 +2006;7;8;189;0;6.04898;2.884695 +2006;7;9;190;0;6.04898;2.884695 +2006;7;10;191;0;6.04898;2.884695 +2006;7;11;192;0;6.04898;2.884695 +2006;7;12;193;0;6.04898;2.884695 +2006;7;13;194;0;6.04898;2.884695 +2006;7;14;195;0;6.04898;2.884695 +2006;7;15;196;0;6.04898;2.884695 +2006;7;16;197;0;6.04898;2.884695 +2006;7;17;198;0;6.04898;2.884695 +2006;7;18;199;0;6.04898;2.884695 +2006;7;19;200;0;6.04898;2.884695 +2006;7;20;201;0;6.04898;2.884695 +2006;7;21;202;0;6.04898;2.884695 +2006;7;22;203;0;6.04898;2.884695 +2006;7;23;204;0;6.04898;2.884695 +2006;7;24;205;0;6.04898;2.884695 +2006;7;25;206;0;6.04898;2.884695 +2006;7;26;207;0;6.04898;2.884695 +2006;7;27;208;0;6.04898;2.884695 +2006;7;28;209;0;6.04898;2.884695 +2006;7;29;210;0;6.04898;2.884695 +2006;7;30;211;0;6.04898;2.884695 +2006;7;31;212;0;6.04898;2.884695 +2006;8;1;213;0;6.04898;2.884695 diff --git a/man/aesthetics.Rd b/man/aesthetics.Rd deleted file mode 100644 index f49924a1..00000000 --- a/man/aesthetics.Rd +++ /dev/null @@ -1,61 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/aesthetics.R -\name{aesthetics} -\alias{aesthetics} -\title{Manages the aesthetics of the graphics} -\usage{ -aesthetics( - sim, - obs = NULL, - type = c("dynamic", "scatter"), - overlap = NULL, - several_sit = FALSE, - shape_sit = c("none", "txt", "symbol", "group"), - one_version = TRUE, - iVersion = 1, - dot_args = NULL -) -} -\arguments{ -\item{sim}{A simulation list of data.frames} - -\item{obs}{An observation list of data.frames} - -\item{type}{The type of plot required, either "dynamic" or "scatter"} - -\item{overlap}{A list of lists containing the variables to represent on the -same graph when \code{type = "dynamic"}} - -\item{several_sit}{Boolean. Must be equal to \code{TRUE} if sim and obs gather -more than one situation and if situations should be differentiated -on the graph.} - -\item{shape_sit}{Shape to differentiate between situations when -\code{all_situations= TRUE}. See details.} - -\item{one_version}{Boolean. Must be \code{TRUE} if several versions will be -plotted on the same graph.} - -\item{iVersion}{Integer. Version number of sim} - -\item{dot_args}{List of dot arguments given to plot function} -} -\value{ -An aesthetics expression which will allow to manage the aesthetics -of the graphics -} -\description{ -Manages the shape, color and line type of the graphics according -to their content -} -\details{ -The \code{shape_sit} argument can be: -\itemize{ -\item "none" (the default): Same shape for all situations. -\item "txt": Writes the name of the situation above each point. -\item "symbol": One shape for each situation. -\item "group": One shape for each group of situations described in -\code{situation_group}. -} -} -\keyword{internal} diff --git a/man/aesthetics_dynamic.Rd b/man/aesthetics_dynamic.Rd deleted file mode 100644 index c53dacc3..00000000 --- a/man/aesthetics_dynamic.Rd +++ /dev/null @@ -1,42 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/aesthetics_dynamic.R -\name{aesthetics_dynamic} -\alias{aesthetics_dynamic} -\title{Manages the aesthetics of the graphics for dynamic plots} -\usage{ -aesthetics_dynamic( - sim, - aesthetics = template_aesthetics(), - overlap = NULL, - one_version = TRUE, - iVersion = 1, - dot_args = NULL, - is_mixture = FALSE -) -} -\arguments{ -\item{sim}{A simulation list of data.frames} - -\item{aesthetics}{Template aesthetics list} - -\item{overlap}{A list of lists containing the variables to represent on the -same graph when \code{type = "dynamic"}} - -\item{one_version}{Boolean. Must be \code{TRUE} if several versions will be -plotted on the same graph.} - -\item{iVersion}{Integer. Version number of sim} - -\item{dot_args}{List of dot arguments given to plot function} - -\item{is_mixture}{Boolean indicating whether the crop is a mixture or not} -} -\value{ -An aesthetics expression which will allow to manage the aesthetics -of the graphics -} -\description{ -Manages the shape, color and line type of the graphics according -to their content -} -\keyword{internal} diff --git a/man/aesthetics_scatter.Rd b/man/aesthetics_scatter.Rd deleted file mode 100644 index 144a0f73..00000000 --- a/man/aesthetics_scatter.Rd +++ /dev/null @@ -1,47 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/aesthetics_scatter.R -\name{aesthetics_scatter} -\alias{aesthetics_scatter} -\title{Manages the aesthetics of the graphics for scatter plots} -\usage{ -aesthetics_scatter( - sim, - aesthetics = template_aesthetics(), - overlap = NULL, - several_sit = FALSE, - one_version = TRUE, - iVersion = 1, - dot_args = NULL, - is_mixture = FALSE -) -} -\arguments{ -\item{sim}{A simulation list of data.frames} - -\item{aesthetics}{Template aesthetics list} - -\item{overlap}{A list of lists containing the variables to represent on the -same graph when \code{type = "dynamic"}} - -\item{several_sit}{Boolean. Must be equal to \code{TRUE} if sim and obs gather -more than one situation and if situations should be differentiated -on the graph.} - -\item{one_version}{Boolean. Must be \code{TRUE} if several versions will be -plotted on the same graph.} - -\item{iVersion}{Integer. Version number of sim} - -\item{dot_args}{List of dot arguments given to plot function} - -\item{is_mixture}{Boolean indicating whether the crop is a mixture or not} -} -\value{ -An aesthetics expression which will allow to manage the aesthetics -of the graphics -} -\description{ -Manages the shape, color and line type of the graphics according -to their content -} -\keyword{internal} diff --git a/man/cat_situations.Rd b/man/cat_situations.Rd index e3ce024d..f296c3b4 100644 --- a/man/cat_situations.Rd +++ b/man/cat_situations.Rd @@ -5,13 +5,7 @@ \title{Format simulation data and observation data in order to consider all situations} \usage{ -cat_situations( - list_sim = NULL, - obs = NULL, - obs_sd = NULL, - force = FALSE, - verbose = TRUE -) +cat_situations(list_sim = NULL, obs = NULL, obs_sd = NULL) } \arguments{ \item{list_sim}{A list (each element= version) of a list @@ -22,11 +16,6 @@ cat_situations( \item{obs_sd}{A list (each element= situation) of \code{data.frame}s for the standard deviation of the observations (named by situation)} - -\item{force}{Continue if the plot is not possible ? E.g. no observations for -scatter plots. If \code{TRUE}, return \code{NULL}, else return an error (default).} - -\item{verbose}{Boolean. Print information during execution.} } \value{ A list of three : a list (each element=version) of a list of a single diff --git a/man/cat_versions.Rd b/man/cat_versions.Rd new file mode 100644 index 00000000..368376b1 --- /dev/null +++ b/man/cat_versions.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/cat_situations.R +\name{cat_versions} +\alias{cat_versions} +\title{Format simulation and observation into a long data frame over versions} +\usage{ +cat_versions(list_sim = NULL) +} +\arguments{ +\item{list_sim}{A list (each element= version) of a list +(each element= situation) of simulations \code{data.frame}s} +} +\value{ +A dataframe +} +\description{ +Format the list of simulation data and observation data +into a long data frame with a new column for the version +} +\keyword{internal} diff --git a/man/cat_with_situation.Rd b/man/cat_with_situation.Rd new file mode 100644 index 00000000..0ce0e548 --- /dev/null +++ b/man/cat_with_situation.Rd @@ -0,0 +1,32 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/cat_situations.R +\name{cat_with_situation} +\alias{cat_with_situation} +\title{Format situations} +\usage{ +cat_with_situation(dot_args, obs, obs_sd, all_situations, v_names) +} +\arguments{ +\item{dot_args}{The dot arguments (the simulations).} + +\item{obs}{The observations.} + +\item{obs_sd}{The standard deviation of the observations.} + +\item{all_situations}{Boolean. Do we need all situations treated +separately or as one.} + +\item{v_names}{The version names.} +} +\value{ +The categorized situations. +} +\description{ +Format the data into a list of situations, with the situation repeated +as a column name, and the version also as a column name. In the case +of \code{all_situations==TRUE}, the situations are concatenated together +into one situation called "all_situations" (the data is a list of +one situation). The true situation name is still kept in the column +\code{sit_name} though. +} +\keyword{internal} diff --git a/man/detect_item_case.Rd b/man/detect_item_case.Rd new file mode 100644 index 00000000..cefa32c4 --- /dev/null +++ b/man/detect_item_case.Rd @@ -0,0 +1,36 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/aesthetics.R +\name{detect_item_case} +\alias{detect_item_case} +\title{Detect items cases} +\usage{ +detect_item_case( + type, + is_mixture, + one_version, + has_distinct_situations, + overlap +) +} +\arguments{ +\item{type}{The type of plot required, either 'dynamic' or 'scatter} + +\item{is_mixture}{A logical value indicating whether the crop is a mixture or not.} + +\item{one_version}{A logical value indicating whether the plot has one or multiple versions (e.g. of the model).} + +\item{has_distinct_situations}{A logical value indicating whether there are one or several situations to plot.} + +\item{overlap}{A logical value indicating whether there is any overlapping variables in the plot.} +} +\value{ +A unique character string for the plot. +} +\description{ +This function returns a unique string based on the type of plot, and +whether the situation is a mixture or not, if there is one or multiple +versions to plot, and if there is one or several situations to plot +into the same plot. +The output is used to choose the right plotting function in a switch. +} +\keyword{internal} diff --git a/man/detect_mixture.Rd b/man/detect_mixture.Rd new file mode 100644 index 00000000..015816e7 --- /dev/null +++ b/man/detect_mixture.Rd @@ -0,0 +1,37 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/aesthetics.R +\name{detect_mixture} +\alias{detect_mixture} +\title{Detects if a situation is a mixture} +\usage{ +detect_mixture(sim_situation) +} +\arguments{ +\item{sim_situation}{A data frame containing the simulated data for +one situation.} +} +\value{ +A logical value indicating if the situation is a mixture. +} +\description{ +This function checks if the situation is a mixture based on +the presence of a column named "Dominance" and the uniqueness +of its values. +} +\examples{ +\dontrun{ +sim_data <- data.frame( + Dominance = c("Principal", "Principal", "Associated", "Associated") +) +CroPlotR:::detect_mixture(sim_data) +# Output: TRUE + +sim_data <- data.frame(Dominance = c("Single Crop", "Single Crop")) +CroPlotR:::detect_mixture(sim_data) +# Output: FALSE + +sim_data <- data.frame(lai = c(1, 1.2)) +CroPlotR:::detect_mixture(sim_data) +# Output: FALSE +} +} diff --git a/man/detect_mixture_version_overlap.Rd b/man/detect_mixture_version_overlap.Rd index 90beaf60..de6c8be5 100644 --- a/man/detect_mixture_version_overlap.Rd +++ b/man/detect_mixture_version_overlap.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/aesthetics.R \name{detect_mixture_version_overlap} \alias{detect_mixture_version_overlap} -\title{Detect items cases} +\title{Detect items cases for dynamic plots} \usage{ detect_mixture_version_overlap(is_mixture, one_version, overlap) } diff --git a/man/detect_mixture_version_situations.Rd b/man/detect_mixture_version_situations.Rd index 859c35f7..fe342d63 100644 --- a/man/detect_mixture_version_situations.Rd +++ b/man/detect_mixture_version_situations.Rd @@ -2,16 +2,20 @@ % Please edit documentation in R/aesthetics.R \name{detect_mixture_version_situations} \alias{detect_mixture_version_situations} -\title{Detect items cases} +\title{Detect items cases for scatter plots} \usage{ -detect_mixture_version_situations(is_mixture, one_version, several_sit) +detect_mixture_version_situations( + is_mixture, + one_version, + has_distinct_situations +) } \arguments{ \item{is_mixture}{A logical value indicating whether the crop is a mixture or not.} \item{one_version}{A logical value indicating whether the plot has one or multiple versions (e.g. of the model).} -\item{several_sit}{A logical value indicating whether there are one or several situations to plot.} +\item{has_distinct_situations}{A logical value indicating whether there are one or several situations to plot.} } \value{ A character string indicating the case for computing the aesthetics of the plot. diff --git a/man/figures/README-unnamed-chunk-10-1.png b/man/figures/README-unnamed-chunk-10-1.png index 66c1f5a9..7f1b8b84 100644 Binary files a/man/figures/README-unnamed-chunk-10-1.png and b/man/figures/README-unnamed-chunk-10-1.png differ diff --git a/man/figures/README-unnamed-chunk-10-2.png b/man/figures/README-unnamed-chunk-10-2.png new file mode 100644 index 00000000..ac17dff7 Binary files /dev/null and b/man/figures/README-unnamed-chunk-10-2.png differ diff --git a/man/figures/README-unnamed-chunk-11-1.png b/man/figures/README-unnamed-chunk-11-1.png index 9e17ad51..87386d81 100644 Binary files a/man/figures/README-unnamed-chunk-11-1.png and b/man/figures/README-unnamed-chunk-11-1.png differ diff --git a/man/figures/README-unnamed-chunk-12-1.png b/man/figures/README-unnamed-chunk-12-1.png index 961585fa..cbad513b 100644 Binary files a/man/figures/README-unnamed-chunk-12-1.png and b/man/figures/README-unnamed-chunk-12-1.png differ diff --git a/man/figures/README-unnamed-chunk-13-1.png b/man/figures/README-unnamed-chunk-13-1.png index 67b6a3fa..7c1e7b9d 100644 Binary files a/man/figures/README-unnamed-chunk-13-1.png and b/man/figures/README-unnamed-chunk-13-1.png differ diff --git a/man/figures/README-unnamed-chunk-14-1.png b/man/figures/README-unnamed-chunk-14-1.png index dbe67312..893b2784 100644 Binary files a/man/figures/README-unnamed-chunk-14-1.png and b/man/figures/README-unnamed-chunk-14-1.png differ diff --git a/man/figures/README-unnamed-chunk-15-1.png b/man/figures/README-unnamed-chunk-15-1.png index 64c85c89..1cfdebb8 100644 Binary files a/man/figures/README-unnamed-chunk-15-1.png and b/man/figures/README-unnamed-chunk-15-1.png differ diff --git a/man/figures/README-unnamed-chunk-15-2.png b/man/figures/README-unnamed-chunk-15-2.png new file mode 100644 index 00000000..ebe8b219 Binary files /dev/null and b/man/figures/README-unnamed-chunk-15-2.png differ diff --git a/man/figures/README-unnamed-chunk-16-1.png b/man/figures/README-unnamed-chunk-16-1.png index 8d6bff35..7d820610 100644 Binary files a/man/figures/README-unnamed-chunk-16-1.png and b/man/figures/README-unnamed-chunk-16-1.png differ diff --git a/man/figures/README-unnamed-chunk-17-1.png b/man/figures/README-unnamed-chunk-17-1.png index 05708d32..2be96009 100644 Binary files a/man/figures/README-unnamed-chunk-17-1.png and b/man/figures/README-unnamed-chunk-17-1.png differ diff --git a/man/figures/README-unnamed-chunk-17-2.png b/man/figures/README-unnamed-chunk-17-2.png new file mode 100644 index 00000000..a9d2c185 Binary files /dev/null and b/man/figures/README-unnamed-chunk-17-2.png differ diff --git a/man/figures/README-unnamed-chunk-18-1.png b/man/figures/README-unnamed-chunk-18-1.png index 8aa2bf83..04322c9a 100644 Binary files a/man/figures/README-unnamed-chunk-18-1.png and b/man/figures/README-unnamed-chunk-18-1.png differ diff --git a/man/figures/README-unnamed-chunk-19-1.png b/man/figures/README-unnamed-chunk-19-1.png index 9198d098..101bd84c 100644 Binary files a/man/figures/README-unnamed-chunk-19-1.png and b/man/figures/README-unnamed-chunk-19-1.png differ diff --git a/man/figures/README-unnamed-chunk-19-2.png b/man/figures/README-unnamed-chunk-19-2.png new file mode 100644 index 00000000..2b67a617 Binary files /dev/null and b/man/figures/README-unnamed-chunk-19-2.png differ diff --git a/man/figures/README-unnamed-chunk-20-1.png b/man/figures/README-unnamed-chunk-20-1.png index bf4a790c..fc194db4 100644 Binary files a/man/figures/README-unnamed-chunk-20-1.png and b/man/figures/README-unnamed-chunk-20-1.png differ diff --git a/man/figures/README-unnamed-chunk-20-2.png b/man/figures/README-unnamed-chunk-20-2.png new file mode 100644 index 00000000..8d5184ca Binary files /dev/null and b/man/figures/README-unnamed-chunk-20-2.png differ diff --git a/man/figures/README-unnamed-chunk-21-1.png b/man/figures/README-unnamed-chunk-21-1.png index 8e1e81d2..072a48dd 100644 Binary files a/man/figures/README-unnamed-chunk-21-1.png and b/man/figures/README-unnamed-chunk-21-1.png differ diff --git a/man/figures/README-unnamed-chunk-21-2.png b/man/figures/README-unnamed-chunk-21-2.png new file mode 100644 index 00000000..dbd37242 Binary files /dev/null and b/man/figures/README-unnamed-chunk-21-2.png differ diff --git a/man/figures/README-unnamed-chunk-22-1.png b/man/figures/README-unnamed-chunk-22-1.png index e7006f54..0c463768 100644 Binary files a/man/figures/README-unnamed-chunk-22-1.png and b/man/figures/README-unnamed-chunk-22-1.png differ diff --git a/man/figures/README-unnamed-chunk-23-1.png b/man/figures/README-unnamed-chunk-23-1.png index 08585733..d1dc35cb 100644 Binary files a/man/figures/README-unnamed-chunk-23-1.png and b/man/figures/README-unnamed-chunk-23-1.png differ diff --git a/man/figures/README-unnamed-chunk-24-1.png b/man/figures/README-unnamed-chunk-24-1.png index f1a41914..165cc0bd 100644 Binary files a/man/figures/README-unnamed-chunk-24-1.png and b/man/figures/README-unnamed-chunk-24-1.png differ diff --git a/man/figures/README-unnamed-chunk-25-1.png b/man/figures/README-unnamed-chunk-25-1.png new file mode 100644 index 00000000..7acbe64b Binary files /dev/null and b/man/figures/README-unnamed-chunk-25-1.png differ diff --git a/man/figures/README-unnamed-chunk-26-1.png b/man/figures/README-unnamed-chunk-26-1.png index 6df59fcf..fd8cfc33 100644 Binary files a/man/figures/README-unnamed-chunk-26-1.png and b/man/figures/README-unnamed-chunk-26-1.png differ diff --git a/man/figures/README-unnamed-chunk-27-1.png b/man/figures/README-unnamed-chunk-27-1.png index 90fe1770..388d1889 100644 Binary files a/man/figures/README-unnamed-chunk-27-1.png and b/man/figures/README-unnamed-chunk-27-1.png differ diff --git a/man/figures/README-unnamed-chunk-28-1.png b/man/figures/README-unnamed-chunk-28-1.png index 6df59fcf..ee42540f 100644 Binary files a/man/figures/README-unnamed-chunk-28-1.png and b/man/figures/README-unnamed-chunk-28-1.png differ diff --git a/man/figures/README-unnamed-chunk-29-1.png b/man/figures/README-unnamed-chunk-29-1.png index 74237f60..91e66564 100644 Binary files a/man/figures/README-unnamed-chunk-29-1.png and b/man/figures/README-unnamed-chunk-29-1.png differ diff --git a/man/figures/README-unnamed-chunk-30-1.png b/man/figures/README-unnamed-chunk-30-1.png index 5a9a1008..59f70ae2 100644 Binary files a/man/figures/README-unnamed-chunk-30-1.png and b/man/figures/README-unnamed-chunk-30-1.png differ diff --git a/man/figures/README-unnamed-chunk-32-1.png b/man/figures/README-unnamed-chunk-32-1.png index 653b5791..11927884 100644 Binary files a/man/figures/README-unnamed-chunk-32-1.png and b/man/figures/README-unnamed-chunk-32-1.png differ diff --git a/man/figures/README-unnamed-chunk-41-1.png b/man/figures/README-unnamed-chunk-41-1.png index c0938af3..0d6b0819 100644 Binary files a/man/figures/README-unnamed-chunk-41-1.png and b/man/figures/README-unnamed-chunk-41-1.png differ diff --git a/man/figures/README-unnamed-chunk-42-1.png b/man/figures/README-unnamed-chunk-42-1.png index 1fbc814b..b898d68c 100644 Binary files a/man/figures/README-unnamed-chunk-42-1.png and b/man/figures/README-unnamed-chunk-42-1.png differ diff --git a/man/figures/README-unnamed-chunk-43-1.png b/man/figures/README-unnamed-chunk-43-1.png index eed4dbf9..6e97a115 100644 Binary files a/man/figures/README-unnamed-chunk-43-1.png and b/man/figures/README-unnamed-chunk-43-1.png differ diff --git a/man/figures/README-unnamed-chunk-44-1.png b/man/figures/README-unnamed-chunk-44-1.png new file mode 100644 index 00000000..74939a39 Binary files /dev/null and b/man/figures/README-unnamed-chunk-44-1.png differ diff --git a/man/figures/README-unnamed-chunk-45-1.png b/man/figures/README-unnamed-chunk-45-1.png index b263e5ae..c92a8848 100644 Binary files a/man/figures/README-unnamed-chunk-45-1.png and b/man/figures/README-unnamed-chunk-45-1.png differ diff --git a/man/figures/README-unnamed-chunk-46-1.png b/man/figures/README-unnamed-chunk-46-1.png new file mode 100644 index 00000000..f520f5e7 Binary files /dev/null and b/man/figures/README-unnamed-chunk-46-1.png differ diff --git a/man/figures/README-unnamed-chunk-47-1.png b/man/figures/README-unnamed-chunk-47-1.png index 2f6fb0bf..acdd398f 100644 Binary files a/man/figures/README-unnamed-chunk-47-1.png and b/man/figures/README-unnamed-chunk-47-1.png differ diff --git a/man/figures/README-unnamed-chunk-48-1.png b/man/figures/README-unnamed-chunk-48-1.png new file mode 100644 index 00000000..9bb6bec5 Binary files /dev/null and b/man/figures/README-unnamed-chunk-48-1.png differ diff --git a/man/figures/README-unnamed-chunk-50-1.png b/man/figures/README-unnamed-chunk-50-1.png new file mode 100644 index 00000000..f759e19a Binary files /dev/null and b/man/figures/README-unnamed-chunk-50-1.png differ diff --git a/man/figures/README-unnamed-chunk-6-1.png b/man/figures/README-unnamed-chunk-6-1.png index f992dc3b..264f8456 100644 Binary files a/man/figures/README-unnamed-chunk-6-1.png and b/man/figures/README-unnamed-chunk-6-1.png differ diff --git a/man/figures/README-unnamed-chunk-6-2.png b/man/figures/README-unnamed-chunk-6-2.png index 9f516c76..ee42540f 100644 Binary files a/man/figures/README-unnamed-chunk-6-2.png and b/man/figures/README-unnamed-chunk-6-2.png differ diff --git a/man/figures/README-unnamed-chunk-7-1.png b/man/figures/README-unnamed-chunk-7-1.png index 33474fbf..c4c9a4a6 100644 Binary files a/man/figures/README-unnamed-chunk-7-1.png and b/man/figures/README-unnamed-chunk-7-1.png differ diff --git a/man/figures/README-unnamed-chunk-7-2.png b/man/figures/README-unnamed-chunk-7-2.png index 97b44a4f..b451d4de 100644 Binary files a/man/figures/README-unnamed-chunk-7-2.png and b/man/figures/README-unnamed-chunk-7-2.png differ diff --git a/man/figures/README-unnamed-chunk-8-1.png b/man/figures/README-unnamed-chunk-8-1.png index df59f544..a04f46d9 100644 Binary files a/man/figures/README-unnamed-chunk-8-1.png and b/man/figures/README-unnamed-chunk-8-1.png differ diff --git a/man/figures/README-unnamed-chunk-8-2.png b/man/figures/README-unnamed-chunk-8-2.png index 8a7a4743..21b4f1ca 100644 Binary files a/man/figures/README-unnamed-chunk-8-2.png and b/man/figures/README-unnamed-chunk-8-2.png differ diff --git a/man/figures/README-unnamed-chunk-9-1.png b/man/figures/README-unnamed-chunk-9-1.png index f992dc3b..3a54e444 100644 Binary files a/man/figures/README-unnamed-chunk-9-1.png and b/man/figures/README-unnamed-chunk-9-1.png differ diff --git a/man/format_cropr.Rd b/man/format_cropr.Rd index 660e08fa..50596bf8 100644 --- a/man/format_cropr.Rd +++ b/man/format_cropr.Rd @@ -12,9 +12,9 @@ format_cropr( type = c("dynamic", "scatter"), select_dyn = c("sim", "common", "obs", "all"), select_scat = c("sim", "res"), - all_situations = FALSE, successive = NULL, reference_var = NULL, + variable = NULL, verbose = TRUE ) } @@ -31,12 +31,6 @@ format_cropr( \item{select_scat}{Which data to plot when \code{type= "scatter"}? See details.} -\item{all_situations}{Boolean (default = FALSE). If \code{TRUE}, plot all -situations on the same graph. -If \code{TRUE}, \code{sim} and \code{obs} are respectively an element of the first -element and the -second element of the output of cat_situations.} - \item{successive}{A list of lists containing the situations to be represented as a contiguous sequence when type = "dynamic" (dates should be contiguous) when \code{type = "dynamic"} (implies that the situations are correctly ordered).} @@ -45,6 +39,9 @@ when \code{type = "dynamic"} (implies that the situations are correctly ordered) select_scat is res. It is possible to select between observation and simulation of the reference variable.} +\item{variable}{A character vector indicating the variables to be kept in +the formatted data frame. If NULL (default), all variables are kept.} + \item{verbose}{Logical value for displaying information while running.} } \value{ diff --git a/man/generic_formatting.Rd b/man/generic_formatting.Rd index 998832f7..fb075113 100644 --- a/man/generic_formatting.Rd +++ b/man/generic_formatting.Rd @@ -6,21 +6,17 @@ \usage{ generic_formatting( df, - var, overlap, situation_group, type, shape_sit, - several_sit, - total_vers, - num_vers + has_distinct_situations, + total_vers ) } \arguments{ \item{df}{A data frame to be formatted (e.g. output from \code{format_cropr}).} -\item{var}{A character string indicating the variable to be formatted.} - \item{overlap}{A logical value indicating whether there is any overlapping variables desired in the plot.} @@ -32,15 +28,17 @@ scatter).} \item{shape_sit}{A logical value indicating whether the shape should be based on the situation.} -\item{several_sit}{A logical value indicating whether there are several +\item{has_distinct_situations}{A logical value indicating whether there +are several situations to plot.} \item{total_vers}{An integer indicating the total number of versions.} - -\item{num_vers}{An integer indicating the id of the current version.} } \value{ -A formatted data frame. +A long data frame with the formatted data, with columns +Date, Plant, Dominance, sit_name, version, variable, Simulated, Observed. +Column "Combi" can also be added if there are three different +characteristics to plot. } \description{ This function performs generic formatting on a data frame based on the input diff --git a/man/give_reference_var.Rd b/man/give_reference_var.Rd new file mode 100644 index 00000000..a9ab23fd --- /dev/null +++ b/man/give_reference_var.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/specific_plotting_scatter.R +\name{give_reference_var} +\alias{give_reference_var} +\title{Get reference variable for plotting} +\usage{ +give_reference_var(reference_var) +} +\arguments{ +\item{reference_var}{The reference variable name, if NULL "Observed" is used} +} +\value{ +A list with two elements: +\itemize{ +\item reference_var: The reference variable name: "Observed" or "Reference" +\item reference_var_name: The display name for the reference variable +} +} +\description{ +Return the reference variable and its display name for scatter +plots +} +\keyword{internal} diff --git a/man/give_y_var_type.Rd b/man/give_y_var_type.Rd new file mode 100644 index 00000000..9f1c55eb --- /dev/null +++ b/man/give_y_var_type.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/specific_plotting_scatter.R +\name{give_y_var_type} +\alias{give_y_var_type} +\title{Get y variable type for plotting} +\usage{ +give_y_var_type(select_scat) +} +\arguments{ +\item{select_scat}{Selection type, either "sim" for Simulated or any other +value for Residuals} +} +\value{ +A character string, either "Simulated" or "Residuals" +} +\description{ +Return the type of y variable for scatter plots based on +selection +} +\keyword{internal} diff --git a/man/parse_plot_situations_args.Rd b/man/parse_plot_situations_args.Rd new file mode 100644 index 00000000..669be03c --- /dev/null +++ b/man/parse_plot_situations_args.Rd @@ -0,0 +1,78 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/parse_plot_situations_arguments.R +\name{parse_plot_situations_args} +\alias{parse_plot_situations_args} +\title{Parse plot situations arguments} +\usage{ +parse_plot_situations_args( + dot_args, + obs = NULL, + obs_sd = NULL, + type = c("dynamic", "scatter"), + select_dyn = c("sim", "common", "obs", "all"), + select_scat = c("sim", "res"), + var = NULL, + title = NULL, + all_situations = TRUE, + overlap = NULL, + successive = NULL, + shape_sit = c("none", "txt", "symbol", "group"), + situation_group = NULL, + reference_var = NULL, + force = FALSE, + verbose = TRUE +) +} +\arguments{ +\item{obs}{A list (each element= situation) of observations \code{data.frame}s +(named by situation)} + +\item{obs_sd}{A list (each element= situation) of standard deviations of +observations \code{data.frame}s (named by situation)} + +\item{type}{The type of plot requested, either "dynamic" (date in X, variable +in Y) or scatter (simulated VS observed)} + +\item{select_dyn}{Which data to plot when \code{type= "dynamic"}? See details.} + +\item{select_scat}{Which data to plot when \code{type= "scatter"}? See details.} + +\item{var}{A vector of variables that should be displayed on the graph.} + +\item{title}{A vector of plot titles, named by situation. Use the situation +name if \code{NULL}, recycled if length one.} + +\item{all_situations}{Boolean (default = TRUE). If \code{TRUE}, plot all +situations on the same graph.} + +\item{overlap}{A list of lists containing the variables to represent on the +same graph when \code{type = "dynamic"}.} + +\item{successive}{A list of lists containing the situations to be represented +as a contiguous sequence when \code{type = "dynamic"} +(implies that the situations are correctly ordered).} + +\item{shape_sit}{Shape to differentiate between situations when +\code{all_situations= TRUE}. See details.} + +\item{situation_group}{A list of lists of situations to gather when +\code{shape_sit= "group"}.} + +\item{reference_var}{Variable selected on x-axis when type is scatter and +select_scat is res. It is possible to select +between observation and simulation of the reference variable. +(examples : reference_var = "lai_n_obs", reference_var = "mafruit_sim")} + +\item{force}{Continue if the plot is not possible ? E.g. no observations for +scatter plots. If \code{TRUE}, return \code{NULL}, else return an error (default).} + +\item{verbose}{Boolean. Print information during execution.} +} +\value{ +A list of parsed arguments, eventually corrected according to the +compatibility between options. +} +\description{ +This function parses the arguments for \code{plot_situations}. +} +\keyword{internal} diff --git a/man/plot_generic_situation.Rd b/man/plot_generic_situation.Rd deleted file mode 100644 index 6b3c0118..00000000 --- a/man/plot_generic_situation.Rd +++ /dev/null @@ -1,114 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/generic_plotting.R -\name{plot_generic_situation} -\alias{plot_generic_situation} -\title{Generic plotting of a situation} -\usage{ -plot_generic_situation( - sim, - obs = NULL, - obs_sd = NULL, - type = c("dynamic", "scatter"), - select_dyn = c("sim", "common", "obs", "all"), - select_scat = c("sim", "res"), - var = var, - title = NULL, - all_situations = TRUE, - overlap = NULL, - successive = NULL, - shape_sit = c("none", "txt", "symbol", "group"), - situation_group = NULL, - total_vers = 1, - num_vers = 1, - reference_var = NULL, - force = FALSE, - verbose = TRUE, - formater -) -} -\arguments{ -\item{sim}{A simulation data.frame} - -\item{obs}{An observation data.frame (variable names must match)} - -\item{obs_sd}{A data.frame of standard deviations of observations} - -\item{select_dyn}{Which data to plot when \code{type= "dynamic"}? See details.} - -\item{select_scat}{Which data to plot when \code{type= "scatter"}? See details.} - -\item{var}{A vector of variables that should be displayed on the graph.} - -\item{title}{The plot title} - -\item{all_situations}{Boolean (default = TRUE). If \code{TRUE}, plot all -situations on the same graph.} - -\item{overlap}{A list of lists containing the variables to represent on -the same graph when \code{type = "dynamic"}.} - -\item{successive}{A list of lists containing the situations to be represented -as a contiguous sequence when \code{type = "dynamic"} -(implies that the situations are correctly ordered).} - -\item{shape_sit}{Shape to differentiate between situations when -\code{all_situations= TRUE}. See details.} - -\item{situation_group}{A list of lists of situations to gather when -\code{shape_sit= "group"}.} - -\item{reference_var}{Variable selected on x-axis when type is scatter and -select_scat is res. It is possible to select -between observation and simulation of the reference variable. -(examples : reference_var = "lai_n_obs", reference_var = "mafruit_sim")} - -\item{force}{Continue if the plot is not possible ? E.g. no observations for -scatter plots. If \code{TRUE}, return \code{NULL}, else return an error (default).} - -\item{verbose}{Boolean. Print information during execution.} - -\item{formater}{The function used to format the models outputs and -observations in a standard way. You can design your own function that format -one situation and provide it here.} -} -\value{ -A ggplot object -} -\description{ -Plots outputs of a model (and observations) for one situation. -This function is used as a generic plotting function for any models. -To use it with your own model, please provide a wrapper function around your -model to format the outputs used by this function (see \code{\link[=format_cropr]{format_cropr()}} for a -template), and then provide your custom function as an argument to this one. -} -\details{ -The \code{select_dyn} argument can be: -\itemize{ -\item "sim" (the default): all variables with simulations outputs, and -observations when there are some -\item "common": variables with simulations outputs and observations in common -\item "obs": all variables with observations, and simulations outputs -when there are some -\item "all": all variables with any observations or simulations outputs -} - -The \code{select_scat} argument can be: -\itemize{ -\item "sim" (the default): plots observations in X and simulations in Y. -\item "res": plots observations in X and residuals(observations-simulations)in Y. -} - -The \code{shape_sit} argument can be: -\itemize{ -\item "none" (the default): Same shape for all situations. -\item "txt": Writes the name of the situation above each point. -\item "symbol": One shape for each situation. -\item "group": One shape for each group of situations described in -\code{situation_group}. -} -} -\note{ -The error bar will be equal to 2*\code{obs_sd} on each side of the point to -have 95\% confidence. -} -\keyword{internal} diff --git a/man/plot_situations.Rd b/man/plot_situations.Rd index d297b2da..3efc5b87 100644 --- a/man/plot_situations.Rd +++ b/man/plot_situations.Rd @@ -20,8 +20,7 @@ plot_situations( situation_group = NULL, reference_var = NULL, force = FALSE, - verbose = TRUE, - formater + verbose = TRUE ) } \arguments{ @@ -63,7 +62,7 @@ as a contiguous sequence when \code{type = "dynamic"} \item{situation_group}{A list of lists of situations to gather when \code{shape_sit= "group"}.} -\item{reference_var}{Variable selected on x-axis when type is scaĆ©tter and +\item{reference_var}{Variable selected on x-axis when type is scatter and select_scat is res. It is possible to select between observation and simulation of the reference variable. (examples : reference_var = "lai_n_obs", reference_var = "mafruit_sim")} @@ -72,11 +71,6 @@ between observation and simulation of the reference variable. scatter plots. If \code{TRUE}, return \code{NULL}, else return an error (default).} \item{verbose}{Boolean. Print information during execution.} - -\item{formater}{The function used to format the models outputs and -observations in a standard way. You can design your own function -that format one situation and provide it here (see \code{\link[=plot_generic_situation]{plot_generic_situation()}} -and \code{\link[=format_cropr]{format_cropr()}} for more information).} } \value{ A (printed) list of ggplot objects, each element being a plot for diff --git a/man/predictor_assessment.Rd b/man/predictor_assessment.Rd index 29b4d383..cc125ef5 100644 --- a/man/predictor_assessment.Rd +++ b/man/predictor_assessment.Rd @@ -164,26 +164,22 @@ on sim~obs. \item \code{Slope()}: Slope of regression line, computed using \code{\link[stats:lm]{stats::lm()}} on sim~obs. \item \code{RMSE()}: Root Mean Squared Error, computed as -\deqn{RMSE = \sqrt{\frac{\sum_1^n(\hat{y_i}-y_i)^2}{n}}} -{RMSE = sqrt(mean((sim-obs)^2)} +\deqn{RMSE = \sqrt{\frac{\sum_1^n(\hat{y_i}-y_i)^2}{n}}}{RMSE = sqrt(mean((sim-obs)^2)} \item \code{RMSEs()}: Systematic Root Mean Squared Error, computed as -\deqn{RMSEs = \sqrt{\frac{\sum_1^n(\sim{y_i}-y_i)^2}{n}}} -{RMSEs = sqrt(mean((fitted.values(lm(formula=sim~obs))-obs)^2)} +\deqn{RMSEs = \sqrt{\frac{\sum_1^n(\sim{y_i}-y_i)^2}{n}}}{RMSEs = sqrt(mean((fitted.values(lm(formula=sim~obs))-obs)^2)} \item \code{RMSEu()}: Unsystematic Root Mean Squared Error, computed as -\deqn{RMSEu = \sqrt{\frac{\sum_1^n(\sim{y_i}-\hat{y_i})^2}{n}}} -{RMSEu = sqrt(mean((fitted.values(lm(formula=sim~obs))-sim)^2)} +\deqn{RMSEu = \sqrt{\frac{\sum_1^n(\sim{y_i}-\hat{y_i})^2}{n}}}{RMSEu = sqrt(mean((fitted.values(lm(formula=sim~obs))-sim)^2)} \item \code{NSE()}: Nash-Sutcliffe Efficiency, alias of EF, provided for user convenience. \item \code{nRMSE()}: Normalized Root Mean Squared Error, also denoted as CV(RMSE), and computed as: -\deqn{nRMSE = \frac{RMSE}{\bar{y}}\cdot100} -{nRMSE = (RMSE/mean(obs))*100} +\deqn{nRMSE = \frac{RMSE}{\bar{y}}\cdot100}{nRMSE = (RMSE/mean(obs))*100} \item \code{rRMSE()}: Relative Root Mean Squared Error, computed as: \deqn{rRMSE = \frac{RMSE}{\bar{y}}}{rRMSE = (RMSE/mean(obs))} \item \code{rRMSEs()}: Relative Systematic Root Mean Squared Error, computed as \deqn{rRMSEs = \frac{RMSEs}{\bar{y}}}{rRMSEs = (RMSEs/mean(obs))} \item \code{rRMSEu()}: Relative Unsystematic Root Mean Squared Error, -computed as +computed as: \deqn{rRMSEu = \frac{RMSEu}{\bar{y}}}{rRMSEu = (RMSEu/mean(obs))} \item \code{pMSEs()}: Proportion of Systematic Mean Squared Error in Mean Square Error, computed as: @@ -201,8 +197,7 @@ Square Error, computed as: (3rd term of Kobayashi and Salam (2000) MSE decomposition), computed as: \deqn{LCS = 2*sd\_obs*sd\_sim*(1-r)} \item \code{rbias2()}: Relative bias squared, computed as: -\deqn{rbias2 = \frac{Bias^2}{\bar{y}^2}} -{rbias2 = Bias^2/mean(obs)^2} +\deqn{rbias2 = \frac{Bias^2}{\bar{y}^2}}{rbias2 = Bias^2/mean(obs)^2} \item \code{rSDSD()}: Relative difference between sd_obs and sd_sim squared, computed as: \deqn{rSDSD = \frac{SDSD}{\bar{y}^2}}{rSDSD = (SDSD/mean(obs)^2)} @@ -210,36 +205,29 @@ computed as: computed as: \deqn{rLCS = \frac{LCS}{\bar{y}^2}}{rLCS = (LCS/mean(obs)^2)} \item \code{MAE()}: Mean Absolute Error, computed as: -\deqn{MAE = \frac{\sum_1^n(\left|\hat{y_i}-y_i\right|)}{n}} -{MAE = mean(abs(sim-obs))} +\deqn{MAE = \frac{\sum_1^n(\left|\hat{y_i}-y_i\right|)}{n}}{MAE = mean(abs(sim-obs))} \item \code{ABS()}: Mean Absolute Bias, which is an alias of \code{MAE()} \item \code{FVU()}: Fraction of variance unexplained, computed as: \deqn{FVU = \frac{SS_{res}}{SS_{tot}}}{FVU = SS_res/SS_tot} \item \code{MSE()}: Mean squared Error, computed as: -\deqn{MSE = \frac{1}{n}\sum_{i=1}^n(Y_i-\hat{Y_i})^2} -{MSE = mean((sim-obs)^2)} +\deqn{MSE = \frac{1}{n}\sum_{i=1}^n(Y_i-\hat{Y_i})^2}{MSE = mean((sim-obs)^2)} \item \code{EF()}: Model efficiency, also called Nash-Sutcliffe efficiency (NSE). This statistic is related to the FVU as \eqn{EF= 1-FVU}. It is also related to the \eqn{R^2}{R2} because they share the same equation, except SStot is applied relative to the identity function (\emph{i.e.} 1:1 line) instead of the -regression line. It is computed -as: \deqn{EF = 1-\frac{SS_{res}}{SS_{tot}}}{EF = 1-SS_res/SS_tot} +regression line. It is computed as: +\deqn{EF = 1-\frac{SS_{res}}{SS_{tot}}}{EF = 1-SS_res/SS_tot} \item \code{Bias()}: Modelling bias, simply computed as: -\deqn{Bias = \frac{\sum_1^n(\hat{y_i}-y_i)}{n}} -{Bias = mean(sim-obs)} +\deqn{Bias = \frac{\sum_1^n(\hat{y_i}-y_i)}{n}}{Bias = mean(sim-obs)} \item \code{MAPE()}: Mean Absolute Percent Error, computed as: -\deqn{MAPE = \frac{\sum_1^n(\frac{\left|\hat{y_i}-y_i\right|} - {y_i})}{n}}{MAPE = mean(abs(obs-sim)/obs)} +\deqn{MAPE = \frac{\sum_1^n(\frac{\left|\hat{y_i}-y_i\right|}{y_i})}{n}}{MAPE = mean(abs(obs-sim)/obs)} \item \code{RME()}: Relative mean error, computed as: -\deqn{RME = \frac{\sum_1^n(\frac{\hat{y_i}-y_i}{y_i})}{n}} -{RME = mean((sim-obs)/obs)} +\deqn{RME = \frac{\sum_1^n(\frac{\hat{y_i}-y_i}{y_i})}{n}}{RME = mean((sim-obs)/obs)} \item \code{tSTUD()}: T student test of the mean difference, computed as: -\deqn{tSTUD = \frac{Bias}{\sqrt(\frac{var(M)}{n_obs})}} -{tSTUD = Bias/sqrt(var(M)/n_obs)} +\deqn{tSTUD = \frac{Bias}{\sqrt(\frac{var(M)}{n_obs})}}{tSTUD = Bias/sqrt(var(M)/n_obs)} \item \code{tLimit()}: T student threshold, computed using \code{\link[=qt]{qt()}}: -\deqn{tLimit = qt(1-\frac{\alpha}{2},df=length(obs)-1)} -{tLimit = qt(1-risk/2,df =length(obs)-1)} +\deqn{tLimit = qt(1-\frac{\alpha}{2},df=length(obs)-1)}{tLimit = qt(1-risk/2,df =length(obs)-1)} \item \code{Decision()}: Decision of the t student test of the mean difference (can bias be considered statistically not different from 0 at alpha level 0.05, i.e. 5\% probability of erroneously rejecting this hypothesis?), @@ -250,10 +238,8 @@ computed as: \note{ \eqn{SS_{res}}{SS_res} is the residual sum of squares and \eqn{SS_{tot}}{SS_tot} the total sum of squares. They are computed as: -\deqn{SS_{res} = \sum_{i=1}^n (y_i - \hat{y_i})^2} -{SS_res= sum((obs-sim)^2)} -\deqn{SS_{tot} = \sum_{i=1}^{n}\left(y_{i}-\bar{y}\right)^2} -{SS_tot= sum((obs-mean(obs))^2} +\deqn{SS_{res} = \sum_{i=1}^n (y_i - \hat{y_i})^2}{SS_res= sum((obs-sim)^2)} +\deqn{SS_{tot} = \sum_{i=1}^{n}\left(y_{i}-\bar{y}\right)^2}{SS_tot= sum((obs-mean(obs))^2} Also, it should be noted that \eqn{y_i} refers to the observed values and \eqn{\hat{y_i}} to the predicted values, \eqn{\bar{y}} to the mean value of observations and \eqn{\sim{y_i}} to diff --git a/man/specific_dynamic_plots.Rd b/man/specific_dynamic_plots.Rd new file mode 100644 index 00000000..d2134509 --- /dev/null +++ b/man/specific_dynamic_plots.Rd @@ -0,0 +1,57 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/specific_plotting_dynamic.R +\name{specific_dynamic_plots} +\alias{specific_dynamic_plots} +\alias{plot_dynamic} +\title{Specific functions to generate dynamic plots} +\usage{ +plot_dynamic(df_data, sit, successive, title = NULL) +} +\arguments{ +\item{df_data}{A named list of data frame including the data to plot (one df +per situation)} + +\item{sit}{The name of the situation to plot} + +\item{successive}{A list of lists containing the situations to be represented +as a contiguous sequence} + +\item{title}{The plot title (optional, NULL by default)} +} +\value{ +A ggplot object + +A list of ggplot objects +} +\description{ +Generate dynamic plots for the different +cases handled in CroPlotR +(plant mixture, plot several simulation results on same graph, ...) +as specified by the different arguments. +} +\details{ +List of the different specific functions: +\itemize{ +\item \code{plot_dynamic_mixture}: Generate a dynamic plot for the case of +mixture of crops, single simulation version and each variable +in different plot +\item \code{plot_dynamic_mixture_overlap}: Generate a dynamic plot for the +case of mixture of crops, single simulation version and several variables +in same plot (overlap) +\item \code{plot_dynamic_versions}: Generate a dynamic plot for the +case of sole crops, all simulation versions in same plot and each +variable in a plot +\item \code{plot_dynamic_overlap}: Generate a dynamic plot for the +case of sole crops, single simulation version and several variables +in same plot (overlap) +\item \code{plot_dynamic_mixture_versions_overlap}: not implemented (seems not +useful because too complex to analyze) +\item \code{plot_dynamic_versions_overlap}: Generate a dynamic plot for the +case of sole crops, all simulation versions and several variables +in same plot (overlap) +\item \code{plot_dynamic_mixture_versions}: Generate a dynamic plot for the +case of mixture of crops, all simulation versions in same plot and +each variable in a plot +} +} +\keyword{internal} diff --git a/man/specific_scatter_plots.Rd b/man/specific_scatter_plots.Rd new file mode 100644 index 00000000..7a1727f2 --- /dev/null +++ b/man/specific_scatter_plots.Rd @@ -0,0 +1,134 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/specific_plotting_scatter.R +\name{specific_scatter_plots} +\alias{specific_scatter_plots} +\alias{compute_axis_bounds} +\alias{make_axis_square} +\alias{force_y_axis} +\alias{add_obs_error_bars} +\alias{plot_scat_mixture_allsit} +\alias{plot_scat_mixture_versions} +\alias{plot_scat_allsit} +\alias{plot_scat_versions_per_sit} +\alias{plot_scat_versions_allsit} +\title{Specific functions to generate scatter plots} +\usage{ +compute_axis_bounds(df_data, reference_var, y_var_type, is_obs_sd) + +make_axis_square(df_data, reference_var, y_var_type, is_obs_sd, p) + +force_y_axis(df_data, reference_var, y_var_type, is_obs_sd, p) + +add_obs_error_bars(p, colour_factor = NULL) + +plot_scat_mixture_allsit( + df_data, + sit, + select_scat, + shape_sit, + reference_var, + is_obs_sd, + title = NULL +) + +plot_scat_mixture_versions( + df_data, + sit, + select_scat, + shape_sit, + reference_var, + is_obs_sd, + title = NULL +) + +plot_scat_allsit( + df_data, + sit, + select_scat, + shape_sit, + reference_var, + is_obs_sd, + title = NULL, + has_distinct_situations = FALSE, + one_version = FALSE, + mixture = FALSE +) + +plot_scat_versions_per_sit( + df_data, + sit, + select_scat, + shape_sit, + reference_var, + is_obs_sd, + title = NULL +) + +plot_scat_versions_allsit( + df_data, + sit, + select_scat, + shape_sit, + reference_var, + is_obs_sd, + title = NULL +) +} +\arguments{ +\item{df_data}{A named list of data frame including the data to plot (one df +per situation, or only one df if sit==all_situations)} + +\item{y_var_type}{type of variable to plot ("Simulated" or "Residuals")} + +\item{is_obs_sd}{TRUE if error standard deviation of observations is provided} + +\item{p}{A ggplot to modify`} + +\item{colour_factor}{The factor to use for colouring the error bars} + +\item{sit}{The name of the situation to plot (or all_situations)} + +\item{has_distinct_situations}{TRUE if the plot is for several situations} + +\item{one_version}{TRUE if the plot is for one version} + +\item{mixture}{TRUE if the plot is for a mixture of crops} +} +\value{ +A ggplot object + +A list of ggplot objects + +List of x and y axis bounds (xaxis_min, xaxis_max, yaxis_min, +yaxis_max) + +The modified ggplot + +The modified ggplot + +The modified ggplot +} +\description{ +Generate scatter plots for the different cases handled in +CroPlotR (plant mixture, plot of residuals, plot several simulation results +on same graph, ...) as specified by the different arguments. + +Compute axis bounds (+/-0.05 added to the min/max of the data). + +Make axis square + +Ensure that the Y axis includes zero when all values in a facet +are strictly positive or strictly negative. + +Add error bars on observed values in given scatterplot +} +\details{ +List of the different specific functions: +\itemize{ +\item \code{plot_scat_mixture_allsit}: Generate a scatter plot for the case of +mixture of crops, single simulation version and all_situations in same plot +\item \code{plot_scat_allsit}: Generate a scatter plot for the case of +sole crops, single simulation version and all_situations in same plot +} +} +\keyword{internal} diff --git a/man/statistics.Rd b/man/statistics.Rd index fb32bdf2..3d8c0730 100644 --- a/man/statistics.Rd +++ b/man/statistics.Rd @@ -10,7 +10,6 @@ statistics( all_situations = FALSE, all_plants = TRUE, verbose = TRUE, - formater, stat = "all" ) } @@ -29,20 +28,16 @@ for all plants (when applicable).} \item{verbose}{Boolean. Print informations during execution.} -\item{formater}{The function used to format the models outputs and -observations in a standard way. You can design your own function -that format one situation and provide it here.} - \item{stat}{A character vector of required statistics, "all" for all, or any of \code{\link[=predictor_assessment]{predictor_assessment()}} (e.g. \code{"n"} or \code{"RMSE"}, or both \code{c("n", "RMSE")}).} } \value{ A data.frame with statistics for each variable and possibly each -grouping variable returned by the formater. +grouping variable. } \description{ Compute statistics for evaluation of any model outputs against -observations, providing a formater function (see \code{\link[=format_cropr]{format_cropr()}}). +observations. } \note{ Because this function has the purpose to assess model quality, all @@ -64,7 +59,6 @@ obs <- SticsRFiles::get_obs(workspace = workspace, usm = situations) statistics( sim = sim$`IC_Wheat_Pea_2005-2006_N0`, obs = obs$`IC_Wheat_Pea_2005-2006_N0`, - formater = format_cropr ) } diff --git a/man/statistics_situations.Rd b/man/statistics_situations.Rd index 263b84ad..65c2ba02 100644 --- a/man/statistics_situations.Rd +++ b/man/statistics_situations.Rd @@ -10,8 +10,7 @@ statistics_situations( stat = "all", all_situations = TRUE, all_plants = TRUE, - verbose = TRUE, - formater + verbose = TRUE ) } \arguments{ @@ -32,11 +31,6 @@ statistics for all situations.} for all plants (when applicable).} \item{verbose}{Boolean. Print information during execution.} - -\item{formater}{The function used to format the models outputs and -observations in a standard way. You can design your own function -that format one situation and provide it here (see \code{\link[=statistics]{statistics()}} and -\code{\link[=format_cropr]{format_cropr()}} for more information).} } \value{ A \code{\link[tibble:as_tibble]{tibble::as_tibble()}} with statistics grouped by group diff --git a/man/template_aesthetics.Rd b/man/template_aesthetics.Rd deleted file mode 100644 index e45d37fb..00000000 --- a/man/template_aesthetics.Rd +++ /dev/null @@ -1,16 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/aesthetics.R -\name{template_aesthetics} -\alias{template_aesthetics} -\title{Template aesthetics} -\usage{ -template_aesthetics() -} -\value{ -A list of aesthetics for a plot. -} -\description{ -This function returns a template list of aesthetics for a plot, including -color, shape, linetype, and group. -} -\keyword{internal} diff --git a/tests/testthat/_inputs/sim_obs.RData b/tests/testthat/_inputs/sim_obs.RData index c8512d6b..25a28bce 100644 Binary files a/tests/testthat/_inputs/sim_obs.RData and b/tests/testthat/_inputs/sim_obs.RData differ diff --git a/tests/testthat/_inputs/tests_scatter_plots.csv b/tests/testthat/_inputs/tests_scatter_plots.csv index 65aa179e..29e4c533 100644 --- a/tests/testthat/_inputs/tests_scatter_plots.csv +++ b/tests/testthat/_inputs/tests_scatter_plots.csv @@ -1,18 +1,44 @@ -Number;Title;mixture;version;all_situations;shape_sit;situation_group;init_col;init_shape;init_linetype;init_group;version_col;version_shape;version_linetype;version_group;nb_geom_point;nb_geom_smooth;nb_abline -1;Mixture, per situation;TRUE;FALSE;FALSE;none;NULL;Plant;NULL;NULL;NULL;NULL;NULL;NULL;NULL;3;2;1 -2;Mixture, All situations;TRUE;FALSE;TRUE;none;NULL;Plant;NULL;NULL;NULL;NULL;NULL;NULL;NULL;3;2;1 -3;Mixture, shape_sit=txt, All situations;TRUE;FALSE;TRUE;txt;NULL;Plant;NULL;NULL;NULL;NULL;NULL;NULL;NULL;3;2;1 -4;Mixture, shape_sit=symbol, All situations;TRUE;FALSE;TRUE;symbol;NULL;Plant;Situation;NULL;NULL;NULL;NULL;NULL;NULL;3;2;1 -5;Mixture (shape_sit=group), All situations;TRUE;FALSE;TRUE;group;NULL;Plant;Situation;NULL;NULL;NULL;NULL;NULL;NULL;3;2;1 -6;Sole crop, Versions, per situation;FALSE;TRUE;FALSE;none;NULL;NULL;NULL;NULL;NULL;Version;NULL;Version;NULL;4;3;1 -7;Sole crop, Versions, All situations;FALSE;TRUE;TRUE;none;NULL;NULL;NULL;NULL;NULL;Version;NULL;Version;NULL;4;3;1 -8;Sole crop, Versions, shape_sit=txt, All situations;FALSE;TRUE;TRUE;txt;NULL;NULL;NULL;NULL;NULL;Version;NULL;Version;NULL;4;3;1 -9;Sole crop, Versions, shape_sit=symbol, All situations;FALSE;TRUE;TRUE;symbol;NULL;NULL;Situation;NULL;NULL;Version;NULL;Version;NULL;4;3;1 -10;Sole crop, Versions (shape_sit=group), All situations;FALSE;TRUE;TRUE;group;NULL;NULL;Situation;NULL;NULL;Version;NULL;Version;NULL;4;3;1 -11;Sole crop, All situations, shape_sit=symbol;FALSE;FALSE;TRUE;symbol;NULL;Situation;NULL;NULL;NULL;Version;NULL;NULL;NULL;3;2;1 -12;Sole crop, All situations, shape_sit=group;FALSE;FALSE;TRUE;group;NULL;Situation;NULL;NULL;NULL;Version;NULL;NULL;NULL;3;2;1 -13;Mixture, versions, per situation;TRUE;TRUE;FALSE;none;NULL;NULL;Plant;NULL;NULL;Version;NULL;Version;NULL;4;3;1 -14;Mixture, versions, All situations;TRUE;TRUE;TRUE;none;NULL;NULL;Plant;NULL;NULL;Version;NULL;Version;NULL;4;3;1 -15;Mixture, versions, shape_sit=txt, All situations;TRUE;TRUE;TRUE;txt;NULL;NULL;Plant;NULL;NULL;Version;NULL;Version;NULL;4;3;1 -16;Mixture, versions, shape_sit=symbol, All situations;TRUE;TRUE;TRUE;symbol;NULL;NULL;NULL;NULL;NULL;Combi;NULL;Version;NULL;4;3;1 -17;Mixture, versions, shape_sit=group, All situations;TRUE;TRUE;TRUE;group;NULL;NULL;NULL;NULL;NULL;Combi;NULL;Version;NULL;4;3;1 +Number;Title;select_scat ;mixture;version;all_situations;shape_sit;reference_var;init_col;init_shape;init_linetype;init_group;version_col;version_shape;version_linetype;version_group;nb_geom_point;nb_geom_smooth;nb_abline;To_test;add_sd_obs +1;Mixture, per situation;sim;TRUE;FALSE;FALSE;none;NULL;"Plant";NULL;NULL;NULL;NULL;NULL;NULL;NULL;1;1;1;TRUE;TRUE +2;Mixture, All situations;sim;TRUE;FALSE;TRUE;none;NULL;"Plant";NULL;NULL;NULL;NULL;NULL;NULL;NULL;1;1;1;TRUE;FALSE +3;Mixture, All situations, reference_var=lai_n_sim;sim;TRUE;FALSE;TRUE;none;lai_n_sim;"Plant";NULL;NULL;NULL;NULL;NULL;NULL;NULL;1;1;1;TRUE;TRUE +4;Mixture, All situations, reference_var=lai_n_obs;sim;TRUE;FALSE;TRUE;none;lai_n_obs;"Plant";NULL;NULL;NULL;NULL;NULL;NULL;NULL;1;1;1;TRUE;FALSE +5;Mixture, shape_sit=txt, All situations;sim;TRUE;FALSE;TRUE;txt;NULL;"Plant";NULL;NULL;NULL;NULL;NULL;NULL;NULL;1;1;1;TRUE;TRUE +6;Mixture, shape_sit=symbol, All situations;sim;TRUE;FALSE;TRUE;symbol;NULL;"Plant";Situation;NULL;NULL;NULL;NULL;NULL;NULL;1;1;1;TRUE;FALSE +7;Mixture (shape_sit=group), All situations;sim;TRUE;FALSE;TRUE;group;NULL;"Plant";Situation;NULL;NULL;NULL;NULL;NULL;NULL;1;1;1;TRUE;TRUE +8;Sole crop, per situation;sim;FALSE;FALSE;FALSE;none;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;1;1;1;TRUE;FALSE +9;Sole crop, All situations;sim;FALSE;FALSE;TRUE;none;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;NULL;1;1;1;TRUE;TRUE +10;Sole crop, Versions, per situation;sim;FALSE;TRUE;FALSE;none;NULL;Version;NULL;NULL;NULL;Version;NULL;Version;NULL;1;1;1;TRUE;FALSE +11;Sole crop, Versions, All situations;sim;FALSE;TRUE;TRUE;none;NULL;Version;NULL;NULL;NULL;Version;NULL;Version;NULL;1;1;1;TRUE;TRUE +12;Sole crop, Versions, shape_sit=txt, All situations;sim;FALSE;TRUE;TRUE;txt;NULL;Version;NULL;NULL;NULL;Version;NULL;Version;NULL;1;1;1;TRUE;FALSE +13;Sole crop, Versions, shape_sit=symbol, All situations;sim;FALSE;TRUE;TRUE;symbol;NULL;Version;Situation;NULL;NULL;Version;NULL;Version;NULL;1;1;1;TRUE;TRUE +14;Sole crop, Versions (shape_sit=group), All situations;sim;FALSE;TRUE;TRUE;group;NULL;Version;Situation;NULL;NULL;Version;NULL;Version;NULL;1;1;1;TRUE;FALSE +15;Sole crop, All situations, shape_sit=symbol;sim;FALSE;FALSE;TRUE;symbol;NULL;Situation;NULL;NULL;NULL;Version;NULL;NULL;NULL;1;1;1;TRUE;TRUE +16;Sole crop, All situations, shape_sit=group;sim;FALSE;FALSE;TRUE;group;NULL;Situation;NULL;NULL;NULL;Version;NULL;NULL;NULL;1;1;1;TRUE;FALSE +17;Mixture, versions, per situation;sim;TRUE;TRUE;FALSE;none;NULL;Version;Plant;NULL;NULL;Version;NULL;Version;NULL;1;1;1;TRUE;TRUE +18;Mixture, versions, All situations;sim;TRUE;TRUE;TRUE;none;NULL;Version;Plant;NULL;NULL;Version;NULL;Version;NULL;1;1;1;TRUE;FALSE +19;Mixture, versions, shape_sit=txt, All situations;sim;TRUE;TRUE;TRUE;txt;NULL;Version;Plant;NULL;NULL;Version;NULL;Version;NULL;1;1;1;TRUE;TRUE +20;Mixture, versions, shape_sit=symbol, All situations;sim;TRUE;TRUE;TRUE;symbol;NULL;Version;Situation;NULL;NULL;Combi;NULL;Version;NULL;1;1;1;TRUE;FALSE +21;Mixture, versions, shape_sit=group, All situations;sim;TRUE;TRUE;TRUE;group;NULL;Version;Situation;NULL;NULL;Combi;NULL;Version;NULL;1;1;1;TRUE;TRUE +22;Mixture, per situation, res;res;TRUE;FALSE;FALSE;none;NULL;"Plant";NULL;NULL;NULL;NULL;NULL;NULL;NULL;1;1;1;TRUE;FALSE +23;Mixture, All situations, res;res;TRUE;FALSE;TRUE;none;NULL;"Plant";NULL;NULL;NULL;NULL;NULL;NULL;NULL;1;1;1;TRUE;TRUE +24;Mixture, All situations, reference_var=lai_n_sim, res;res;TRUE;FALSE;TRUE;none;lai_n_sim;"Plant";NULL;NULL;NULL;NULL;NULL;NULL;NULL;1;1;1;TRUE;FALSE +25;Mixture, All situations, reference_var=lai_n_obs, res;res;TRUE;FALSE;TRUE;none;lai_n_obs;"Plant";NULL;NULL;NULL;NULL;NULL;NULL;NULL;1;1;1;TRUE;TRUE +26;Mixture, All situations, reference_var=lai_n_res, res;res;TRUE;FALSE;TRUE;none;lai_n_res;"Plant";NULL;NULL;NULL;NULL;NULL;NULL;NULL;1;1;1;TRUE;FALSE +27;Mixture, shape_sit=txt, All situations, res;res;TRUE;FALSE;TRUE;txt;NULL;"Plant";NULL;NULL;NULL;NULL;NULL;NULL;NULL;1;1;1;TRUE;TRUE +28;Mixture, shape_sit=symbol, All situations, res;res;TRUE;FALSE;TRUE;symbol;NULL;"Plant";Situation;NULL;NULL;NULL;NULL;NULL;NULL;1;1;1;TRUE;FALSE +29;Mixture (shape_sit=group), All situations, res;res;TRUE;FALSE;TRUE;group;NULL;"Plant";Situation;NULL;NULL;NULL;NULL;NULL;NULL;1;1;1;TRUE;TRUE +30;Sole crop, per situation, res;res;FALSE;FALSE;FALSE;none;NULL;NULL;NULL;NULL;NULL;Version;NULL;NULL;NULL;1;1;1;TRUE;FALSE +31;Sole crop, Versions, All situations, res;res;FALSE;TRUE;TRUE;none;NULL;Version;NULL;NULL;NULL;NULL;NULL;NULL;NULL;1;1;1;TRUE;TRUE +32;Sole crop, Versions, per situation, res;res;FALSE;TRUE;FALSE;none;NULL;Version;NULL;NULL;NULL;Version;NULL;Version;NULL;1;1;1;TRUE;FALSE +33;Sole crop, Versions, All situations, res;res;FALSE;TRUE;TRUE;none;NULL;Version;NULL;NULL;NULL;Version;NULL;Version;NULL;1;1;1;TRUE;TRUE +34;Sole crop, Versions, shape_sit=txt, All situations, res;res;FALSE;TRUE;TRUE;txt;NULL;Version;NULL;NULL;NULL;Version;NULL;Version;NULL;1;1;1;TRUE;FALSE +35;Sole crop, Versions, shape_sit=symbol, All situations, res;res;FALSE;TRUE;TRUE;symbol;NULL;Version;Situation;NULL;NULL;Version;NULL;Version;NULL;1;1;1;TRUE;TRUE +36;Sole crop, Versions (shape_sit=group), All situations, res;res;FALSE;TRUE;TRUE;group;NULL;Version;Situation;NULL;NULL;Version;NULL;Version;NULL;1;1;1;TRUE;FALSE +37;Sole crop, All situations, shape_sit=symbol, res;res;FALSE;FALSE;TRUE;symbol;NULL;Situation;NULL;NULL;NULL;Version;NULL;NULL;NULL;1;1;1;TRUE;TRUE +38;Sole crop, All situations, shape_sit=group, res;res;FALSE;FALSE;TRUE;group;NULL;Situation;NULL;NULL;NULL;Version;NULL;NULL;NULL;1;1;1;TRUE;FALSE +39;Mixture, versions, per situation, res;res;TRUE;TRUE;FALSE;none;NULL;Version;Plant;NULL;NULL;Version;NULL;Version;NULL;1;1;1;TRUE;TRUE +40;Mixture, versions, All situations, res;res;TRUE;TRUE;TRUE;none;NULL;Version;Plant;NULL;NULL;Version;NULL;Version;NULL;1;1;1;TRUE;FALSE +41;Mixture, versions, shape_sit=txt, All situations, res;res;TRUE;TRUE;TRUE;txt;NULL;Version;Plant;NULL;NULL;Version;NULL;Version;NULL;1;1;1;TRUE;TRUE +42;Mixture, versions, shape_sit=symbol, All situations, res;res;TRUE;TRUE;TRUE;symbol;NULL;Version;Situation;NULL;NULL;Combi;NULL;Version;NULL;1;1;1;TRUE;FALSE +43;Mixture, versions, shape_sit=group, All situations, res;res;TRUE;TRUE;TRUE;group;NULL;Version;Situation;NULL;NULL;Combi;NULL;Version;NULL;1;1;1;TRUE;TRUE \ No newline at end of file diff --git a/tests/testthat/test-detect_mixture.R b/tests/testthat/test-detect_mixture.R new file mode 100644 index 00000000..210276d3 --- /dev/null +++ b/tests/testthat/test-detect_mixture.R @@ -0,0 +1,12 @@ +test_that("detect_mixture", { + sim_data <- data.frame( + Dominance = c("Principal", "Principal", "Associated", "Associated") + ) + expect_true(CroPlotR:::detect_mixture(sim_data)) + + sim_data <- data.frame(Dominance = c("Single Crop", "Single Crop")) + expect_false(CroPlotR:::detect_mixture(sim_data)) + + sim_data <- data.frame(lai = c(1, 1.2)) + expect_false(CroPlotR:::detect_mixture(sim_data)) +}) diff --git a/tests/testthat/test-dynamic-plots.R b/tests/testthat/test-dynamic-plots.R index e44292e9..e037c21a 100644 --- a/tests/testthat/test-dynamic-plots.R +++ b/tests/testthat/test-dynamic-plots.R @@ -53,7 +53,6 @@ library(testthat) # save(sim, sim2, obs, sim_rot, file = "tests/testthat/_inputs/sim_obs.RData") - # Loading the inputs # setwd("tests/testthat") (local test) @@ -64,6 +63,10 @@ if (!testthat:::on_ci()) { tmpdir <- "_outputs" if (!file.exists(tmpdir)) { dir.create(tmpdir) + } else { + # Delete the dynamic figures that are already present ("dynamic-fig...") + list.files(tmpdir, pattern = paste0("^dynamic-fig.*.svg$"), full.names = TRUE) |> + file.remove() } } @@ -114,48 +117,53 @@ set.seed(1) test_that("format of plotting several situations on different graphs", { test_plot <- plot(sim, obs = obs, all_situations = FALSE) - expect_true(is.list(test_plot)) - expect_equal(length(test_plot), 3) - expect_true(all(names(test_plot) %in% - c( - "IC_Wheat_Pea_2005-2006_N0", "SC_Pea_2005-2006_N0", - "SC_Wheat_2005-2006_N0" - ))) - lapply(names(test_plot), function(x) { - make_snapshot( - paste0(prefix, "_fig.1_simple_", x, pkg_version), - test_plot[[x]], - tmpdir + if (any(is.na(test_plot))) { + message( + "Dynamic Plot \"several situations on different graphs\" not yet implemented (plot return NA)" ) - }) + } else { + expect_true(is.list(test_plot)) + expect_equal(length(test_plot), 3) + expect_true(all( + names(test_plot) %in% + c( + "IC_Wheat_Pea_2005-2006_N0", + "SC_Pea_2005-2006_N0", + "SC_Wheat_2005-2006_N0" + ) + )) + + lapply(names(test_plot), function(x) { + make_snapshot( + paste0(prefix, "_fig.1_simple_", x, pkg_version), + test_plot[[x]], + tmpdir + ) + }) + } }) test_that("Tests with no observations", { - test_plot <- plot(sim, all_situations = FALSE) + test_plot <- suppressWarnings(plot(sim, all_situations = FALSE)) expect_true(is.list(test_plot)) expect_equal(length(test_plot), 3) - expect_true(all(names(test_plot) %in% - c( - "IC_Wheat_Pea_2005-2006_N0", "SC_Pea_2005-2006_N0", - "SC_Wheat_2005-2006_N0" - ))) + expect_true(all( + names(test_plot) %in% + c( + "IC_Wheat_Pea_2005-2006_N0", + "SC_Pea_2005-2006_N0", + "SC_Wheat_2005-2006_N0" + ) + )) expect_error( plot(sim, select_dyn = "obs", force = FALSE), - "No observations found" + "Observations are required" ) expect_error( plot(sim, select_dyn = "common", force = FALSE), - "No observations found" + "Observations are required" ) - - lapply(names(test_plot), function(x) { - make_snapshot( - paste0(prefix, "_fig.2_no_obs_", x, pkg_version), - test_plot[[x]], - tmpdir - ) - }) }) @@ -164,177 +172,353 @@ all_plots <- list() ### only overlap test_that("Test plot only overlap", { - test_plot <- plot(sim_sole_crop, obs = obs, overlap = list(list("lai_n", "masec_n")), title = "Test plot only overlap") - all_plots <<- c(all_plots, test_plot) - expect_equal(test_plot$`SC_Pea_2005-2006_N0`$labels$shape, "Variable") - expect_equal(test_plot$`SC_Pea_2005-2006_N0`$labels$colour, "Variable") - expect_equal( - unique(test_plot$`SC_Pea_2005-2006_N0`$data$group_var), - "lai_n | masec_n" + test_plot <- plot( + sim_sole_crop, + obs = obs, + overlap = list(list("lai_n", "masec_n")) ) - expect_equal( - unique(test_plot$`SC_Pea_2005-2006_N0`$data$variable), - c("lai_n", "masec_n") - ) - - lapply(names(test_plot), function(x) { - make_snapshot( - paste0(prefix, "_fig.3_overlap_", x, pkg_version), - test_plot[[x]], - tmpdir + if (any(is.na(test_plot))) { + message( + "Dynamic Plot \"only overlap\" not yet implemented (plot return NA)" ) - }) + } else { + labels <- ggplot2::get_labs(test_plot$`SC_Pea_2005-2006_N0`) + expect_equal(labels$shape, "Variable") + expect_equal(labels$colour, "Variable") + expect_equal( + unique(test_plot$`SC_Pea_2005-2006_N0`$data$group_var), + "lai_n | masec_n" + ) + expect_equal( + unique(test_plot$`SC_Pea_2005-2006_N0`$data$var), + c("lai_n", "masec_n") + ) + + lapply(names(test_plot), function(x) { + make_snapshot( + paste0(prefix, "_fig.3_overlap_", x, pkg_version), + test_plot[[x]], + tmpdir + ) + }) + ## add title for visual inspection of the graph + test_plot <- lapply(test_plot, function(x) { + x + + ggplot2::labs(caption = "plot only overlap") + + ggplot2::theme( + plot.caption = ggplot2::element_text(hjust = 0.5, color = "red") + ) + }) + all_plots <<- c(all_plots, test_plot) + } }) ### only mixture test_that("Test plot only mixture", { - test_plot <- plot(sim_mixture, obs = obs, title = "Test plot only mixture") - all_plots <<- c(all_plots, test_plot) - expect_equal(test_plot$`IC_Wheat_Pea_2005-2006_N0`$labels$shape, "Plant") - expect_equal(test_plot$`IC_Wheat_Pea_2005-2006_N0`$labels$colour, "Plant") - expect_equal(grepl("Plant", test_plot$`IC_Wheat_Pea_2005-2006_N0`$labels$group), TRUE) + test_plot <- plot(sim_mixture, obs = obs) + if (any(is.na(test_plot))) { + message( + "Dynamic Plot \"only mixture\" not yet implemented (plot return NA)" + ) + } else { + all_plots <<- c(all_plots, test_plot) + labels <- ggplot2::get_labs(test_plot$`IC_Wheat_Pea_2005-2006_N0`) + expect_equal(labels$shape, NULL) + expect_equal(labels$colour, "Plant") + lapply(names(test_plot), function(x) { + make_snapshot( + paste0(prefix, "_fig.4_mixture_", x, pkg_version), + test_plot[[x]], + tmpdir + ) + }) + ## add title for visual inspection of the graph + test_plot <- lapply(test_plot, function(x) { + x + + ggplot2::labs(caption = "plot only mixture") + + ggplot2::theme( + plot.caption = ggplot2::element_text(hjust = 0.5, color = "red") + ) + }) + all_plots <<- c(all_plots, test_plot) + } +}) +# Also add a test without observations: +test_that("Test plot only mixture without obs", { + test_plot <- plot(sim_mixture) + all_plots <<- c(all_plots, test_plot) + labels <- ggplot2::get_labs(test_plot$`IC_Wheat_Pea_2005-2006_N0`) + expect_equal(labels$shape, NULL) + expect_equal(labels$colour, "Plant") lapply(names(test_plot), function(x) { make_snapshot( - paste0(prefix, "_fig.4_mixture_", x, pkg_version), + paste0(prefix, "_fig.4_mixture_no_obs_", x, pkg_version), test_plot[[x]], tmpdir ) }) + ## add title for visual inspection of the graph + test_plot <- lapply(test_plot, function(x) { + x + + ggplot2::labs(caption = "plot only mixture without obs") + + ggplot2::theme( + plot.caption = ggplot2::element_text(hjust = 0.5, color = "red") + ) + }) + all_plots <<- c(all_plots, test_plot) }) - ### only version test_that("Test plot only version", { - test_plot <- plot(sim_sole_crop, sim2_sole_crop, obs = obs, title = "Test plot only version") - all_plots <<- c(all_plots, test_plot) - expect_equal(test_plot$`SC_Pea_2005-2006_N0`$labels$shape, NULL) - expect_equal(test_plot$`SC_Pea_2005-2006_N0`$labels$colour, NULL) - expect_equal(test_plot$`SC_Pea_2005-2006_N0`$labels$group, "group") - expect_equal(all(sapply(test_plot$`SC_Pea_2005-2006_N0`$layers, function(x) grepl("Version_", rlang::eval_tidy(x$mapping$colour)))), TRUE) - - - expect_equal(all(sapply( - test_plot$`SC_Pea_2005-2006_N0`[sapply(test_plot$`SC_Pea_2005-2006_N0`, function(y) "shape" %in% attributes(y$mapping)$names)], - function(x) grepl("Version_", rlang::eval_tidy(x$mapping$shape)) - )), TRUE) - - lapply(names(test_plot), function(x) { - make_snapshot( - paste0(prefix, "_fig.5_version_", x, pkg_version), - test_plot[[x]], - tmpdir + test_plot <- plot(sim_sole_crop, sim2_sole_crop, obs = obs) + if (any(is.na(test_plot))) { + message('Dynamic Plot "only version" not yet implemented (plot return NA)') + } else { + labels <- ggplot2::get_labs(test_plot$`SC_Pea_2005-2006_N0`) + expect_equal( + labels$shape, + "Observations" ) - }) + expect_equal(labels$colour, "Version") + expect_equal(labels$group, NULL) + + lapply(names(test_plot), function(x) { + make_snapshot( + paste0(prefix, "_fig.5_version_", x, pkg_version), + test_plot[[x]], + tmpdir + ) + }) + ## add title for visual inspection of the graph + test_plot <- lapply(test_plot, function(x) { + x + + ggplot2::labs(caption = "plot only version") + + ggplot2::theme( + plot.caption = ggplot2::element_text(hjust = 0.5, color = "red") + ) + }) + all_plots <<- c(all_plots, test_plot) + } }) ### overlap + mixture test_that("Test plot overlap + mixture", { - test_plot <- plot(sim_mixture, obs = obs, overlap = list(list("lai_n", "masec_n")), title = "Test plot overlap + mixture") - all_plots <<- c(all_plots, test_plot) - expect_equal(test_plot$`IC_Wheat_Pea_2005-2006_N0`$labels$shape, "Variable") - expect_equal(test_plot$`IC_Wheat_Pea_2005-2006_N0`$labels$colour, "Plant") - expect_equal(test_plot$`IC_Wheat_Pea_2005-2006_N0`$labels$linetype, "Variable") - expect_equal( - unique(test_plot$`IC_Wheat_Pea_2005-2006_N0`$data$group_var), - "lai_n | masec_n" + test_plot <- plot( + sim_mixture, + obs = obs, + overlap = list(list("lai_n", "masec_n")) ) - expect_equal( - unique(test_plot$`IC_Wheat_Pea_2005-2006_N0`$data$variable), - c("lai_n", "masec_n") - ) - expect_equal( - unique(test_plot$`IC_Wheat_Pea_2005-2006_N0`$data$Plant), - c("ble", "poi") - ) - - lapply(names(test_plot), function(x) { - make_snapshot( - paste0(prefix, "_fig.6_overlap_mixture_", x, pkg_version), - test_plot[[x]], - tmpdir + if (any(is.na(test_plot))) { + message( + "Dynamic Plot \"overlap+mixture\" not yet implemented (plot return NA)" ) - }) + } else { + labels <- ggplot2::get_labs(test_plot$`IC_Wheat_Pea_2005-2006_N0`) + expect_equal(labels$shape, "Plant") + expect_equal(labels$colour, "Variable") + expect_equal(labels$linetype, "Plant") + expect_equal( + unique(test_plot$`IC_Wheat_Pea_2005-2006_N0`$data$group_var), + "lai_n | masec_n" + ) + expect_equal( + unique(test_plot$`IC_Wheat_Pea_2005-2006_N0`$data$var), + c("lai_n", "masec_n") + ) + expect_equal( + unique(test_plot$`IC_Wheat_Pea_2005-2006_N0`$data$Plant), + c("ble", "poi") + ) + + lapply(names(test_plot), function(x) { + make_snapshot( + paste0(prefix, "_fig.6_overlap_mixture_", x, pkg_version), + test_plot[[x]], + tmpdir + ) + }) + ## add title for visual inspection of the graph + test_plot <- lapply(test_plot, function(x) { + x + + ggplot2::labs(caption = "plot overlap + mixture") + + ggplot2::theme( + plot.caption = ggplot2::element_text(hjust = 0.5, color = "red") + ) + }) + all_plots <<- c(all_plots, test_plot) + } }) ### overlap + version test_that("Test plot overlap + version", { - test_plot <- plot(sim_sole_crop, sim2_sole_crop, obs = obs, overlap = list(list("lai_n", "masec_n")), title = "Test plot overlap + version") - all_plots <<- c(all_plots, test_plot) - expect_equal(test_plot$`SC_Pea_2005-2006_N0`$labels$shape, NULL) - expect_equal(test_plot$`SC_Pea_2005-2006_N0`$labels$colour, "Variable") - expect_equal(test_plot$`SC_Pea_2005-2006_N0`$labels$linetype, NULL) - expect_equal(test_plot$`SC_Pea_2005-2006_N0`$labels$group, "variable") - - expect_equal(all(sapply(test_plot$`SC_Pea_2005-2006_N0`$layers, function(x) grepl("variable", rlang::as_label(x$mapping$colour)))), TRUE) - expect_equal(all(sapply( - test_plot$`SC_Pea_2005-2006_N0`$layers[sapply(test_plot$`SC_Pea_2005-2006_N0`$layers, function(y) "shape" %in% attributes(y$mapping)$names)], - function(x) grepl("Version_", rlang::eval_tidy(x$mapping$shape)) - )), TRUE) - expect_equal(all(sapply( - test_plot$`SC_Pea_2005-2006_N0`$layers[sapply(test_plot$`SC_Pea_2005-2006_N0`$layers, function(y) "linetype" %in% attributes(y$mapping)$names)], - function(x) grepl("Version_", rlang::eval_tidy(x$mapping$linetype)) - )), TRUE) - - - expect_equal( - unique(test_plot$`SC_Pea_2005-2006_N0`$data$group_var), - "lai_n | masec_n" - ) - expect_equal( - unique(test_plot$`SC_Pea_2005-2006_N0`$data$variable), - c("lai_n", "masec_n") - ) - expect_equal( - unique(test_plot$`SC_Pea_2005-2006_N0`$data$Sit_Name), - c("SC_Pea_2005-2006_N0") + test_plot <- plot( + sim_sole_crop, + sim2_sole_crop, + obs = obs, + overlap = list(list("lai_n", "masec_n")), all_situations = FALSE ) + if (any(is.na(test_plot))) { + message( + "Dynamic Plot \"overlap+version\" not yet implemented (plot return NA)" + ) + } else { + labels <- ggplot2::get_labs(test_plot$`SC_Pea_2005-2006_N0`) + expect_equal(labels$shape, NULL) + expect_equal(labels$colour, "Variable") + expect_equal(labels$linetype, "Version") + expect_equal(labels$group, NULL) + expect_equal( + all(sapply( + test_plot$`SC_Pea_2005-2006_N0`$layers[sapply( + test_plot$`SC_Pea_2005-2006_N0`$layers, + function(y) "shape" %in% attributes(y$mapping)$names + )], + function(x) grepl("Version_", rlang::eval_tidy(x$mapping$shape)) + )), + TRUE + ) + expect_equal( + all(sapply( + test_plot$`SC_Pea_2005-2006_N0`$layers[sapply( + test_plot$`SC_Pea_2005-2006_N0`$layers, + function(y) "linetype" %in% attributes(y$mapping)$names + )], + function(x) grepl("Version_", rlang::eval_tidy(x$mapping$linetype)) + )), + TRUE + ) - lapply(names(test_plot), function(x) { - make_snapshot( - paste0(prefix, "_fig.7_overlap_version_", x, pkg_version), - test_plot[[x]], - tmpdir + expect_equal( + unique(test_plot$`SC_Pea_2005-2006_N0`$data$group_var), + "lai_n | masec_n" ) - }) + expect_equal( + unique(test_plot$`SC_Pea_2005-2006_N0`$data$var), + c("lai_n", "masec_n") + ) + expect_equal( + unique(test_plot$`SC_Pea_2005-2006_N0`$data$sit_name), + c("SC_Pea_2005-2006_N0") + ) + + lapply(names(test_plot), function(x) { + make_snapshot( + paste0(prefix, "_fig.7_overlap_version_", x, pkg_version), + test_plot[[x]], + tmpdir + ) + }) + ## add title for visual inspection of the graph + test_plot <- lapply(test_plot, function(x) { + x + + ggplot2::labs(caption = "plot overlap + version") + + ggplot2::theme( + plot.caption = ggplot2::element_text(hjust = 0.5, color = "red") + ) + }) + all_plots <<- c(all_plots, test_plot) + } }) ### mixture + version - test_that("Test plot mixture + version", { - test_plot <- plot(sim_mixture, sim2_mixture, obs = obs, title = "Test plot mixture + version") - all_plots <<- c(all_plots, test_plot) - expect_equal(test_plot$`IC_Wheat_Pea_2005-2006_N0`$labels$shape, NULL) - expect_equal(test_plot$`IC_Wheat_Pea_2005-2006_N0`$labels$colour, NULL) - expect_equal(test_plot$`IC_Wheat_Pea_2005-2006_N0`$labels$linetype, NULL) - expect_equal(grepl("Plant", test_plot$`IC_Wheat_Pea_2005-2006_N0`$labels$group), TRUE) - - expect_equal(all(sapply(test_plot$`IC_Wheat_Pea_2005-2006_N0`$layers, function(x) grepl("Plant", rlang::as_label(x$mapping$colour)))), TRUE) - expect_equal(all(sapply( - test_plot$`IC_Wheat_Pea_2005-2006_N0`$layers[sapply(test_plot$`IC_Wheat_Pea_2005-2006_N0`$layers, function(y) "shape" %in% attributes(y$mapping)$names)], - function(x) grepl("Version_", rlang::eval_tidy(x$mapping$shape)) - )), TRUE) - expect_equal(all(sapply( - test_plot$`IC_Wheat_Pea_2005-2006_N0`$layers[sapply(test_plot$`IC_Wheat_Pea_2005-2006_N0`$layers, function(y) "linetype" %in% attributes(y$mapping)$names)], - function(x) grepl("Version_", rlang::eval_tidy(x$mapping$linetype)) - )), TRUE) + test_plot <- plot(sim_mixture, sim2_mixture, obs = obs) + if (any(is.na(test_plot))) { + message( + "Dynamic Plot \"mixture+version\" not yet implemented (plot return NA)" + ) + } else { + labels <- ggplot2::get_labs(test_plot$`IC_Wheat_Pea_2005-2006_N0`) + expect_equal(labels$shape, NULL) + expect_equal(labels$colour, "Plant") + expect_equal(labels$linetype, "Version") + + expect_equal( + all(sapply( + test_plot$`IC_Wheat_Pea_2005-2006_N0`$layers[sapply( + test_plot$`IC_Wheat_Pea_2005-2006_N0`$layers, + function(y) "shape" %in% attributes(y$mapping)$names + )], + function(x) grepl("Version_", rlang::eval_tidy(x$mapping$shape)) + )), + TRUE + ) + expect_equal( + all(sapply( + test_plot$`IC_Wheat_Pea_2005-2006_N0`$layers[sapply( + test_plot$`IC_Wheat_Pea_2005-2006_N0`$layers, + function(y) "linetype" %in% attributes(y$mapping)$names + )], + function(x) grepl("Version_", rlang::eval_tidy(x$mapping$linetype)) + )), + TRUE + ) - lapply(names(test_plot), function(x) { - make_snapshot( - paste0(prefix, "_fig.7_mixture_version_", x, pkg_version), - test_plot[[x]], - tmpdir + lapply(names(test_plot), function(x) { + make_snapshot( + paste0(prefix, "_fig.7_mixture_version_", x, pkg_version), + test_plot[[x]], + tmpdir + ) + }) + ## add title for visual inspection of the graph + test_plot <- lapply(test_plot, function(x) { + x + + ggplot2::labs(caption = "plot mixture + version") + + ggplot2::theme( + plot.caption = ggplot2::element_text(hjust = 0.5, color = "red") + ) + }) + all_plots <<- c(all_plots, test_plot) + } +}) + + +### successive + +test_that("Test successive plot", { + test_plot <- plot(sim_rot, + obs = obs, + successive = list(list("demo_Wheat1", "demo_BareSoil2", "demo_maize3")), + var = c("resmes", "masec_n"), + all_situations = FALSE + ) + + if (any(is.na(test_plot))) { + message( + "Dynamic Plot \"several situations on different graphs\" not yet implemented (plot return NA)" ) - }) + } else { + expect_true(is.list(test_plot)) + expect_equal(length(test_plot), 1) + lapply(names(test_plot), function(x) { + make_snapshot( + paste0(prefix, "_fig.8_successive_", x, pkg_version), + test_plot[[x]], + tmpdir + ) + }) + ## add title for visual inspection of the graph + test_plot <- lapply(test_plot, function(x) { + x + + ggplot2::labs(caption = "plot successive") + + ggplot2::theme( + plot.caption = ggplot2::element_text(hjust = 0.5, color = "red") + ) + }) + all_plots <<- c(all_plots, test_plot) + } }) + if (!testthat:::on_ci()) { save_plot_pdf(all_plots, out_dir = tmpdir, file_name = "all_plots_dynamic") print(paste("Plots saved in pdf format in ", tmpdir)) diff --git a/tests/testthat/test-generic_formatting.R b/tests/testthat/test-generic_formatting.R new file mode 100644 index 00000000..374192ee --- /dev/null +++ b/tests/testthat/test-generic_formatting.R @@ -0,0 +1,56 @@ +# Loading the inputs (see test-plot to reproduce the data) +load("_inputs/sim_obs.RData") +# load("tests/testthat/_inputs/sim_obs.RData") + +# Prepare the data until format_cropr: +all_situations <- TRUE +type <- "dynamic" +var <- "lai_n" +args_list <- CroPlotR:::parse_plot_situations_args( + list(sim), + obs = obs, type = type, var = var, all_situations = all_situations +) + +situations_outputs <- cat_with_situation( + args_list$dot_args, args_list$obs, args_list$obs_sd, + args_list$all_situations, args_list$v_names +) + +sit <- args_list$common_situations_models[1] +df_sit <- format_cropr( + situations_outputs$sim[[sit]], + situations_outputs$obs[[sit]], + situations_outputs$obs_sd[[sit]], + args_list$type, + args_list$select_dyn, + args_list$select_scat, + args_list$successive, + args_list$reference_var, + args_list$var, + args_list$verbose +) + + +# Apply generic_formatting: +df_all <- generic_formatting( + df_sit, + args_list$overlap, + args_list$situation_group, + args_list$type, args_list$shape_sit, + args_list$has_distinct_situations, + 1 +) + +# Apply tests: +test_that("generic_formatting", { + expect_s3_class(df_all, "data.frame") + expect_equal(nrow(df_all), 620) + expect_equal(unique(df_all$sit_name), "IC_Wheat_Pea_2005-2006_N0") + expect_equal(unique(df_all$Plant), c("ble", "poi")) + expect_equal(as.character(min(df_all$Date)), "2005-09-26") + expect_equal(as.character(max(df_all$Date)), "2006-08-01") + expect_equal(unique(df_all$version), "Version_1") + expect_equal(unique(df_all$var), "lai_n") + expect_equal(mean(df_all$Simulated), 0.21725255, tolerance = 1e-8) + expect_equal(mean(df_all$Observed, na.rm = TRUE), 0.7625, tolerance = 1e-8) +}) diff --git a/tests/testthat/test-generic_statistics.R b/tests/testthat/test-generic_statistics.R index fbf808e6..21499fde 100644 --- a/tests/testthat/test-generic_statistics.R +++ b/tests/testthat/test-generic_statistics.R @@ -6,7 +6,7 @@ test_that("format of statistics", { statistics( sim = sim$`IC_Wheat_Pea_2005-2006_N0`, obs = obs$`IC_Wheat_Pea_2005-2006_N0`, - all_situations = FALSE, formater = format_cropr + all_situations = FALSE ) expect_true(is.data.frame(df_stats)) expect_equal(ncol(df_stats), 39) @@ -18,7 +18,7 @@ test_that("statistics with no obs return NULL", { df_stats <- statistics( sim = sim$`IC_Wheat_Pea_2005-2006_N0`, obs = NULL, - all_situations = FALSE, formater = format_cropr + all_situations = FALSE ) expect_true(is.null(df_stats)) }) @@ -123,6 +123,9 @@ test_that("statistical criteria", { 1:3, ncol(df_stats) )], 5) + # To update the reference, make the test locally, and use snapshot_accept() + # Careful, accept only if the new reference is better than the old one and you + # know what you are doing. expect_snapshot_value(df_stats, style = "json2") }) diff --git a/tests/testthat/test-plotting_formatting.R b/tests/testthat/test-plotting_formatting.R index 1c5413f4..4c536a45 100644 --- a/tests/testthat/test-plotting_formatting.R +++ b/tests/testthat/test-plotting_formatting.R @@ -1,13 +1,12 @@ load("_inputs/sim_obs.RData") test_that("Dynamics plot with wrong args values", { - expect_error(plot(sim, all_situations = FALSE, var = c("lai_n", "masec", "mafruit"))) + expect_error(suppressWarnings(plot(sim, all_situations = FALSE, var = c("lai_n", "masec", "mafruit")))) expect_error(plot(sim, all_situations = FALSE, var = c("lai_n"), type = "dynamics")) - expect_error(plot(sim, all_situations = FALSE, var = c("lai_n"), select_dyn = "obs")) + expect_error(plot(sim, all_situations = FALSE, var = c("lai_n"), select_dyn = "obs", force = FALSE)) }) - test_that("Scatter plot with wrong args values", { expect_error(plot(sim, obs = obs, type = "scatter", var = c("lai_n", "masec", "mafruit"))) - expect_error(plot(sim, type = "scatter", var = c("lai_n"), select_scat = "obs")) + expect_error(plot(sim, type = "scatter", var = c("lai_n"), select_scat = "obs", force = FALSE)) }) diff --git a/tests/testthat/test-scatter-plots.R b/tests/testthat/test-scatter-plots.R index 35ea1a05..48f74f09 100644 --- a/tests/testthat/test-scatter-plots.R +++ b/tests/testthat/test-scatter-plots.R @@ -31,6 +31,8 @@ # usms_file = file.path(workspace, "usms.xml") # ) # +# obs_sd <- lapply(obs, function(x) {x %>% dplyr::mutate(across(where(is.numeric), ~.*0.1))}) +# # # Rotation example # workspace2 <- system.file( # file.path("extdata", "stics_example_successive"), @@ -64,7 +66,8 @@ # sim2_sole_crop[[sit]][,c("lai_n","masec_n")]<-sim2_sole_crop[[sit]][,c("lai_n","masec_n")]*1.1 # } -# save(sim, sim2, sim_mixture, sim2_mixture, sim_sole_crop, sim2_sole_crop, obs, sim_rot, file = "tests/testthat/_inputs/sim_obs.RData") +# save(sim, sim2, sim_mixture, sim2_mixture, sim_sole_crop, sim2_sole_crop, obs, +# obs_sd, sim_rot, file = "tests/testthat/_inputs/sim_obs.RData") # Loading the inputs # setwd("tests/testthat") # (local test) @@ -75,6 +78,10 @@ if (!testthat:::on_ci()) { tmpdir <- "_outputs" if (!file.exists(tmpdir)) { dir.create(tmpdir) + } else { + # Delete the scatter figures that are already present ("scatter-fig...") + list.files(tmpdir, pattern = paste0("^scatter-fig.*.svg$"), full.names = TRUE) |> + file.remove() } } @@ -92,7 +99,7 @@ make_snapshot <- function(name, plot, tmpdir) { print(paste("Making snapshot", name, "and saving in", file)) - vdiffr:::write_svg(plot, file, name) + vdiffr:::write_svg(plot, file) return(file) } @@ -126,61 +133,72 @@ set.seed(1) test_that("Tests with no observations", { expect_error( plot(sim, type = "scatter", force = FALSE), - "No observations found" + "Observations are required but not provided" ) expect_error( - plot(sim, select_scat = "res", force = FALSE), - "No observations found" + plot(sim, type = "scatter", select_scat = "res", force = FALSE), + "Observations are required but not provided" ) }) test_that("Extract plot of one situation", { - test_plot <- extract_plot( - plot(sim, - obs = obs, type = "scatter", - all_situations = FALSE - ), - situation = c("IC_Wheat_Pea_2005-2006_N0") + p <- plot(sim, + obs = obs, type = "scatter", + all_situations = FALSE ) - expect_true(is.list(test_plot)) - expect_equal(length(test_plot), 1) - expect_equal(names(test_plot), c("IC_Wheat_Pea_2005-2006_N0")) - expect_error( - extract_plot( - plot(sim, - obs = obs, type = "scatter", - all_situations = TRUE + if (any(is.na(p))) { + message(paste("Scatter plot all_sit=FALSE not yet implemented (plot return NA)")) + } else { + test_plot <- extract_plot(p, + situation = c("IC_Wheat_Pea_2005-2006_N0") + ) + expect_true(is.list(test_plot)) + expect_equal(length(test_plot), 1) + expect_equal(names(test_plot), c("IC_Wheat_Pea_2005-2006_N0")) + + expect_error( + extract_plot( + plot(sim, + obs = obs, type = "scatter", + all_situations = TRUE + ), + situation = c("IC_Wheat_Pea_2005-2006_N0"), + force = FALSE ), - situation = c("IC_Wheat_Pea_2005-2006_N0"), - force = FALSE - ), - "Impossible to extract situations from a list of a single ggplot covering all situations" - ) + "Impossible to extract situations from a list of a single ggplot covering all situations" + ) + } }) test_that("Extract plots of one variable", { - test_plot <- extract_plot( - plot(sim, - obs = obs, type = "scatter", - all_situations = FALSE - ), - var = c("lai_n") + p <- plot(sim, + obs = obs, type = "scatter", + all_situations = FALSE ) - expect_true(is.list(test_plot)) - expect_equal(length(test_plot), 3) - expect_true(all(names(test_plot) %in% - c( - "IC_Wheat_Pea_2005-2006_N0", "SC_Pea_2005-2006_N0", - "SC_Wheat_2005-2006_N0" - ))) + + if (any(is.na(p))) { + message(paste("Scatter plot all_sit=FALSE not yet implemented (plot return NA)")) + } else { + test_plot <- extract_plot(p, + var = c("lai_n") + ) + expect_true(is.list(test_plot)) + expect_equal(length(test_plot), 3) + expect_true(all(names(test_plot) %in% + c( + "IC_Wheat_Pea_2005-2006_N0", "SC_Pea_2005-2006_N0", + "SC_Wheat_2005-2006_N0" + ))) + } }) # Test labels of ggplot in function of the case (see doc/aesthetics_scatter.xlsx) ## Read the file describing the configurations and results of the tests + tmp <- read.csv( file = "_inputs/tests_scatter_plots.csv", header = TRUE, sep = ";", stringsAsFactors = FALSE @@ -209,95 +227,137 @@ tmp$name <- lapply( ) tmp$situation_group <- lapply( 1:nrow(tmp), - function(i) if (tmp$shape_sit[i] == "group") list(as.list(head(names(tmp$sim[[i]]), 1))) else NULL + function(i) if (tmp$shape_sit[i] == "group") list(as.list(head(names(tmp$sim[[i]]), 2))) else NULL +) +tmp$reference_var <- lapply( + 1:nrow(tmp), + function(i) if (tmp$reference_var[i] == "NULL") NULL else tmp$reference_var[i] ) - all_plots <- list() # Test the different variants of plots based on the file _inputs/tests_scatter_plot.csv -invisible(lapply(1:nrow(tmp), function(i) { +invisible(lapply(seq_len(nrow(tmp)), function(i) { test_that(paste0("Test #", tmp$Number[[i]]), { if (tmp$version[i]) { test_plot <- plot(tmp$sim[[i]], tmp$sim2[[i]], - obs = obs, type = "scatter", + obs = obs, + obs_sd = switch(tmp$add_sd_obs[[i]], + obs_sd, + NULL + ), + type = "scatter", + select_scat = tmp$select_scat[[i]], all_situations = tmp$all_situations[i], shape_sit = tmp$shape_sit[i], - situation_group = tmp$situation_group[[i]] + situation_group = tmp$situation_group[[i]], + reference_var = tmp$reference_var[[i]] ) } else { test_plot <- plot(tmp$sim[[i]], - obs = obs, type = "scatter", + obs = obs, + obs_sd = obs_sd, + type = "scatter", + select_scat = tmp$select_scat[[i]], all_situations = tmp$all_situations[i], shape_sit = tmp$shape_sit[i], - situation_group = tmp$situation_group[[i]] + situation_group = tmp$situation_group[[i]], + reference_var = tmp$reference_var[[i]] ) } - expect_true(is.list(test_plot)) - expect_equal(length(test_plot), tmp$length[[i]]) - expect_equal(names(test_plot), tmp$name[[i]]) - init_col <- if (tmp$init_col[i] == "NULL") NULL else tmp$init_col[i] - init_shape <- if (tmp$init_shape[i] == "NULL") NULL else tmp$init_shape[i] - init_linetype <- if (tmp$init_linetype[i] == "NULL") NULL else tmp$init_linetype[i] - init_group <- if (tmp$init_group[i] == "NULL") "group" else tmp$init_group[i] - - ## Check the number and type of layers are correct - layers_class <- sapply(test_plot[[1]]$layers, function(x) class(x$geom)[1]) - expect_equal(length(grep("GeomPoint", layers_class)), tmp$nb_geom_point[i]) - expect_equal(length(grep("GeomSmooth", layers_class)), tmp$nb_geom_smooth[i]) - expect_equal(length(grep("GeomAbline", layers_class)), tmp$nb_abline[i]) - - ## Check attributes in plot labels - expect_equal(test_plot[[1]]$labels$col, init_col) - expect_equal(test_plot[[1]]$labels$shape, init_shape) - expect_equal(test_plot[[1]]$labels$linetype, init_linetype) - expect_equal(test_plot[[1]]$labels$group, init_group) - - ## Check attributes in plot layers - if (tmp$version_col[i] != "NULL") { - version_col <- tmp$version_col[i] - id_layers_with_colour <- sapply(test_plot[[1]]$layers, function(y) "colour" %in% attributes(y$mapping)$names) - expect_equal(all(sapply( - test_plot[[1]]$layers[id_layers_with_colour]$mapping$colour, - function(x) grepl(version_col, rlang::eval_tidy(x)) - )), TRUE) - } - if (tmp$version_shape[i] != "NULL") { - version_shape <- tmp$version_shape[i] - id_layers_with_shape <- sapply(test_plot[[1]]$layers, function(y) "shape" %in% attributes(y$mapping)$names) - expect_equal(all(sapply( - test_plot[[1]]$layers[id_layers_with_shape]$mapping$shape, - function(x) grepl(version_shape, rlang::eval_tidy(x)) - )), TRUE) - } - if (tmp$version_linetype[i] != "NULL") { - version_linetype <- tmp$version_linetype[i] - id_layers_with_linetype <- sapply(test_plot[[1]]$layers, function(y) "linetype" %in% attributes(y$mapping)$names) - expect_equal(all(sapply( - test_plot[[1]]$layers[id_layers_with_linetype]$mapping$linetype, - function(x) grepl(version_linetype, rlang::eval_tidy(x)) - )), TRUE) + if (all(is.na(test_plot))) { + message(paste( + "Scatter Plot #", tmp$Number[[i]], + " decribed in file _inputs/tests_scatter_plot.csv not yet implemented (plot return NA)" + )) + } else if (!tmp$To_test[[i]]) { + message(paste( + "Test of scatter plot #", tmp$Number[[i]], + " is disabled in file _inputs/tests_scatter_plot.csv (see column To_test" + )) + } else { + message("Testing scatter Plot #", tmp$Number[[i]]) + expect_true(is.list(test_plot)) + expect_equal(length(test_plot), tmp$length[[i]]) + expect_equal(names(test_plot), tmp$name[[i]]) + init_col <- if (tmp$init_col[i] == "NULL") NULL else tmp$init_col[i] + init_shape <- if (tmp$init_shape[i] == "NULL") NULL else tmp$init_shape[i] + init_linetype <- if (tmp$init_linetype[i] == "NULL") NULL else tmp$init_linetype[i] + init_group <- if (tmp$init_group[i] == "NULL") NULL + + ## Check the number and type of layers are correct + layers_class <- sapply(test_plot[[1]]$layers, function(x) class(x$geom)[1]) + expect_equal(length(grep("GeomPoint", layers_class)), tmp$nb_geom_point[i]) + expect_equal(length(grep("GeomSmooth", layers_class)), tmp$nb_geom_smooth[i]) + expect_equal(length(grep("GeomAbline", layers_class)), tmp$nb_abline[i]) + + ## Check attributes in plot labels + labels <- ggplot2::get_labs(test_plot[[1]]) + expect_equal(labels$col, init_col) + expect_equal(labels$shape, init_shape) + expect_equal(labels$linetype, init_linetype) + expect_equal(labels$group, init_group) + + ## Check attributes in plot layers + if (tmp$version_col[i] != "NULL") { + version_col <- tmp$version_col[i] + id_layers_with_colour <- sapply(test_plot[[1]]$layers, function(y) "colour" %in% attributes(y$mapping)$names) + expect_equal(all(sapply( + test_plot[[1]]$layers[id_layers_with_colour]$mapping$colour, + function(x) grepl(version_col, rlang::eval_tidy(x)) + )), TRUE) + } + if (tmp$version_shape[i] != "NULL") { + version_shape <- tmp$version_shape[i] + id_layers_with_shape <- sapply(test_plot[[1]]$layers, function(y) "shape" %in% attributes(y$mapping)$names) + expect_equal(all(sapply( + test_plot[[1]]$layers[id_layers_with_shape]$mapping$shape, + function(x) grepl(version_shape, rlang::eval_tidy(x)) + )), TRUE) + } + if (tmp$version_linetype[i] != "NULL") { + version_linetype <- tmp$version_linetype[i] + id_layers_with_linetype <- sapply(test_plot[[1]]$layers, function(y) "linetype" %in% attributes(y$mapping)$names) + expect_equal(all(sapply( + test_plot[[1]]$layers[id_layers_with_linetype]$mapping$linetype, + function(x) grepl(version_linetype, rlang::eval_tidy(x)) + )), TRUE) + } + + ## add title for visual inspection of the graph + test_plot <- test_plot[sapply(test_plot, function(x) inherits(x, "ggplot"))] + test_plot <- lapply(test_plot, function(x) { + x + + ggplot2::labs(caption = paste0("Plot #", i, "\n", tmp$Title[[i]])) + + ggplot2::theme(plot.caption = ggplot2::element_text(hjust = 0.5, color = "red")) + }) + + lapply(names(test_plot), function(y) { + sit <- NULL + if (y != "all_situations" && !is.null(y)) { + sit <- paste0("_", y) + } + make_snapshot( + paste0( + prefix, + "_fig.", + tmp$Number[[i]], + "_", + tmp$Title[[i]], + sit, + pkg_version + ), + test_plot[[y]], + tmpdir + ) + }) + + all_plots <<- c(all_plots, test_plot) } - - ## add title for visual inspection of the graph - test_plot <- lapply(test_plot, function(x) { - x + - ggplot2::labs(caption = paste0("Plot #", i, "\n", tmp$Title[[i]])) + - ggplot2::theme(plot.caption = ggplot2::element_text(hjust = 0.5, color = "red")) - }) - - lapply(names(test_plot), function(y) { - make_snapshot( - paste0(prefix, "_fig.", i, "_", tmp$Title[[i]], "_", y, pkg_version), - test_plot[[y]], - tmpdir - ) - }) - - all_plots <<- c(all_plots, test_plot) }) })) + # Generate a pdf including all the variants of plots for visual inspection if (!testthat:::on_ci()) { save_plot_pdf(all_plots, out_dir = tmpdir, file_name = "all_plots_scatter") diff --git a/tests/testthat/vdiffr/test-snapshots.R b/tests/testthat/vdiffr/test-snapshots.R index 557b64cc..467a330b 100644 --- a/tests/testthat/vdiffr/test-snapshots.R +++ b/tests/testthat/vdiffr/test-snapshots.R @@ -1,8 +1,7 @@ # These tests need R version >= 4.2 for testhat >= 3.0.0. # Also, we only test on the OS and R version the snapshots were built on. -# pkg_version <- "Release"; source('tests/testthat/vdiffr/generate-snapshots.R') -# pkg_version <- "Latest"; source('tests/testthat/vdiffr/generate-snapshots.R') +# snapshots are generated in test-***-plots.R scripts if (!exists("tmpdir")) { stop(paste( @@ -11,11 +10,29 @@ if (!exists("tmpdir")) { )) } -figs <- list.files(tmpdir, pattern = "*fig.*\\.svg$", full.names = TRUE) +figs <- list.files(tmpdir, pattern = "*fig.*\\.svg$", full.names = FALSE) latest_figs <- figs[grepl("latest.svg$", figs)] release_figs <- figs[grepl("release.svg$", figs)] +# grep beginning of latest_figs in release_figs +prefix_latest_figs <- sapply(latest_figs, function(x) substr(x, 1, nchar(x) - 11)) +prefix_release_figs <- sapply(release_figs, function(x) substr(x, 1, nchar(x) - 12)) + +missing_figs <- setdiff(prefix_release_figs, prefix_latest_figs) +if (length(missing_figs) > 0) { + message(paste( + "Warning: figure(s) ", + paste(missing_figs, collapse = ", "), + "not generated for latest version.", + "\n They will therefore not be taken into account in snapshot comparison." + )) + release_figs <- paste0(prefix_latest_figs, "-release.svg") +} + +release_figs <- file.path(tmpdir, release_figs) +latest_figs <- file.path(tmpdir, latest_figs) + set.seed(1) mapply(