diff --git a/DESCRIPTION b/DESCRIPTION index e2646bdc..cd126c7d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -27,7 +27,7 @@ Description: Manipulating input and output files of the 'STICS' crop or writing parameter names and values in both XML or text input files, and getting data from output files. Advanced functionalities include XML files generation from XML templates and/or spreadsheets, or text - files generation from XML files by using xslt transformation. + files generation from XML files by using 'xslt' transformation. License: LGPL (>= 3) URL: https://github.com/SticsRPacks/SticsRFiles, https://doi.org/10.5281/zenodo.4443206 diff --git a/R/gen_ini_xml.R b/R/gen_ini_xml.R index 1ee8975a..81cc8f91 100644 --- a/R/gen_ini_xml.R +++ b/R/gen_ini_xml.R @@ -63,9 +63,9 @@ #' #' @export #' -gen_ini_xml <- function(param_df = NULL, +gen_ini_xml <- function(param_df, file = NULL, - out_dir = getwd(), + out_dir, crop_tag = "Crop", stics_version = "latest", ini_in_file = lifecycle::deprecated(), diff --git a/R/gen_new_travail.R b/R/gen_new_travail.R index 7c60305f..f7ccc378 100644 --- a/R/gen_new_travail.R +++ b/R/gen_new_travail.R @@ -20,16 +20,16 @@ gen_new_travail <- function(workspace, usm, - lai_forcing = 0, - codesuite = 0, - codoptim = 0, - out_dir = getwd()) { + lai_forcing = NULL, + codesuite = NULL, + codoptim = NULL, + out_dir = NULL) { usm_data <- get_usm_data(workspace, usm, - lai_forcing = 0, - codesuite = 0, - codoptim = 0) + lai_forcing = lai_forcing, + codesuite = codesuite, + codoptim = codoptim) data_order <- c("codesimul", "codoptim", "codesuite", "nbplantes", "nom", "datedebut", "datefin", "finit", "numsol", "nomsol", @@ -37,6 +37,8 @@ gen_new_travail <- function(workspace, "fclim1", "fclim2", "nbans", "culturean", "fplt1", "ftec1", "flai1", "fplt2", "ftec2", "flai2") + if (is.null(out_dir)) out_dir <- workspace + out_file <- file.path(out_dir, "new_travail.usm") p_table <- vector(mode = "character", length = 2 * length(data_order)) @@ -54,9 +56,9 @@ gen_new_travail <- function(workspace, get_usm_data <- function(workspace, usm, - lai_forcing = 0, - codesuite = 0, - codoptim = 0) { + lai_forcing = NULL, + codesuite = NULL, + codoptim = NULL) { data <- list() @@ -65,13 +67,18 @@ get_usm_data <- function(workspace, usm, select = "usm", select_value = usm)$usms.xml - # codesimul + # forcing codesimul # 0: culture, 1: feuille, lai forcing - data$codesimul <- get_codesimul(lai_forcing) + if(!is.null(lai_forcing) & lai_forcing %in% c(0,1)) + data$codesimul <- get_codesimul(lai_forcing) - data$codoptim <- codoptim + # forcing codoptim + if(!is.null(codoptim) & codoptim %in% c(0,1)) + data$codoptim <- codoptim - data$codesuite <- codesuite + # forcing codesuite + if(!is.null(codesuite) & codesuite %in% c(0,1)) + data$codesuite <- codesuite # nbplantes #data$nbplantes @@ -110,7 +117,7 @@ get_usm_data <- function(workspace, data$nbans <- as.numeric(strsplit(x = data$fclim2, split = ".", fixed = TRUE)[[1]][2]) - as.numeric(strsplit(x = data$fclim1, split = ".", fixed = TRUE)[[1]][2]) + - data$culturean + 1 # culturean # data$culturean diff --git a/R/gen_obs.R b/R/gen_obs.R index e5efbed9..20913e3f 100644 --- a/R/gen_obs.R +++ b/R/gen_obs.R @@ -41,7 +41,7 @@ #' @export #' gen_obs <- function(df, - out_dir = getwd(), + out_dir, usms_list = NULL, obs_table = lifecycle::deprecated(), out_path = lifecycle::deprecated()) { diff --git a/R/gen_sols_xml.R b/R/gen_sols_xml.R index d40c9395..5029b137 100644 --- a/R/gen_sols_xml.R +++ b/R/gen_sols_xml.R @@ -63,8 +63,8 @@ #' #' #' -gen_sols_xml <- function(file = file.path(getwd(), "sols.xml"), - param_df = NULL, +gen_sols_xml <- function(file, + param_df, template = NULL, stics_version = "latest", sols_in_file = lifecycle::deprecated(), @@ -111,11 +111,6 @@ gen_sols_xml <- function(file = file.path(getwd(), "sols.xml"), xml_doc <- NULL - # Fix : default output file path if not provided - if (base::is.null(sols_out_file)) { - sols_out_file <- file.path(getwd(), "sols.xml") - } - if (!base::is.null(sols_in_file)) { xml_doc <- xmldocument(sols_in_file) } diff --git a/R/gen_sta_xml.R b/R/gen_sta_xml.R index 9adb30d2..3ce0ceda 100644 --- a/R/gen_sta_xml.R +++ b/R/gen_sta_xml.R @@ -46,9 +46,9 @@ #' @export #' # TODO: refactor with gen_tec_file, gen_ini_file : same code -gen_sta_xml <- function(param_df = NULL, +gen_sta_xml <- function(param_df, file = NULL, - out_dir = getwd(), + out_dir, stics_version = "latest", param_table = lifecycle::deprecated(), sta_in_file = lifecycle::deprecated(), diff --git a/R/gen_tec_xml.R b/R/gen_tec_xml.R index 9be1ade2..6c8be79a 100644 --- a/R/gen_tec_xml.R +++ b/R/gen_tec_xml.R @@ -59,7 +59,7 @@ gen_tec_xml <- function(param_df = NULL, file = NULL, - out_dir = getwd(), + out_dir, stics_version = "latest", na_values = NA, param_table = lifecycle::deprecated(), diff --git a/R/gen_usms_xml.R b/R/gen_usms_xml.R index 277f874b..ef41f856 100644 --- a/R/gen_usms_xml.R +++ b/R/gen_usms_xml.R @@ -1,7 +1,6 @@ #' @title Generate STICS usms xml file from a template or an input file #' -#' @param file Path (including name) of the usms file to generate. Optional, -#' set to `file.path(getwd(), "usms.xml")`by default. +#' @param file Path (including name) of the usms file to generate. #' @param param_df A table (df, tibble) containing the values of the parameters #' to use (see details) #' @param template Path of an USM xml file to be used as a template. @@ -59,7 +58,7 @@ #' @export #' -gen_usms_xml <- function(file = file.path(getwd(), "usms.xml"), +gen_usms_xml <- function(file, param_df = NULL, template = NULL, stics_version = "latest", @@ -99,11 +98,6 @@ gen_usms_xml <- function(file = file.path(getwd(), "usms.xml"), xml_doc <- NULL - # Fix : default output file path if not provided - if (base::is.null(usms_out_file)) { - usms_out_file <- file.path(getwd(), "usms.xml") - } - # If a template file is provided if (!base::is.null(usms_in_file)) { xml_doc <- xmldocument(usms_in_file) diff --git a/R/get_climate_txt.R b/R/get_climate_txt.R index e815c1a1..896237af 100644 --- a/R/get_climate_txt.R +++ b/R/get_climate_txt.R @@ -28,7 +28,7 @@ #' #' @export #' -get_climate_txt <- function(workspace = getwd(), +get_climate_txt <- function(workspace, file_name = "climat.txt", preserve = TRUE, dirpath = lifecycle::deprecated(), diff --git a/R/get_file.R b/R/get_file.R index 2752a11b..6863861e 100644 --- a/R/get_file.R +++ b/R/get_file.R @@ -117,7 +117,7 @@ get_file <- function(workspace, #' #' @noRd #' -get_file_ <- function(workspace = getwd(), +get_file_ <- function(workspace, usm_name = NULL, usms_filepath = NULL, var_list = NULL, diff --git a/R/get_obs_txt.R b/R/get_obs_txt.R index c75e52ed..048e16f5 100644 --- a/R/get_obs_txt.R +++ b/R/get_obs_txt.R @@ -36,7 +36,9 @@ #' #' @noRd #' -get_obs_txt <- function(dirpath = getwd(), filename = NULL, mixed = NULL) { +get_obs_txt <- function(dirpath, + filename = NULL, + mixed = NULL) { . <- NULL # to avoid CRAN note for pipe if (is.null(mixed)) { if (file.exists(file.path(dirpath, "new_travail.usm"))) { diff --git a/R/get_param_txt.R b/R/get_param_txt.R index d483fbd3..9e58ecb3 100644 --- a/R/get_param_txt.R +++ b/R/get_param_txt.R @@ -58,7 +58,7 @@ #' #' #' @export -get_param_txt <- function(workspace = getwd(), +get_param_txt <- function(workspace, param = NULL, variety = NULL, exact = FALSE, diff --git a/R/set_param_txt.R b/R/set_param_txt.R index f4be2973..952f63bb 100644 --- a/R/set_param_txt.R +++ b/R/set_param_txt.R @@ -72,7 +72,7 @@ #' param = "cailloux", layer = 2, value = 1) #' #' -set_param_txt <- function(workspace = getwd(), +set_param_txt <- function(workspace, param, value, append = FALSE, diff --git a/R/static_help.R b/R/static_help.R index bc2542bc..c9d5c377 100644 --- a/R/static_help.R +++ b/R/static_help.R @@ -23,7 +23,7 @@ static_help <- function(pkg, links_level = 0, topic = NULL, - out_dir = getwd(), + out_dir, overwrite = TRUE) { if (!dir.exists(out_dir)) dir.create(out_dir) diff --git a/cran-comments.md b/cran-comments.md index 544944f2..9aad498a 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,9 +1,9 @@ ── SticsRFiles 1.1.3: NOTE - Build ID: SticsRFiles_1.1.3.tar.gz-c4b9e5e1c0f0486ab292c73748a6ed2a + Build ID: SticsRFiles_1.1.3.tar.gz-77acad5161384a8e90d3b0461507f39e Platform: Windows Server 2022, R-devel, 64 bit - Submitted: 1h 9m 54.9s ago - Build time: 7m 41.8s + Submitted: 1h 41m 5.2s ago + Build time: 6m 34.7s ❯ checking CRAN incoming feasibility ... [17s] NOTE Maintainer: 'Patrice Lecharpentier ' @@ -22,12 +22,12 @@ ── SticsRFiles 1.1.3: NOTE - Build ID: SticsRFiles_1.1.3.tar.gz-200502a17eab4563a2972360a9407d88 + Build ID: SticsRFiles_1.1.3.tar.gz-7a811a73d6964b13ad859b175e690f20 Platform: Ubuntu Linux 20.04.1 LTS, R-release, GCC - Submitted: 1h 9m 54.9s ago - Build time: 57m 29.5s + Submitted: 1h 41m 5.2s ago + Build time: 33m 20.1s -❯ checking CRAN incoming feasibility ... [7s/26s] NOTE +❯ checking CRAN incoming feasibility ... [7s/25s] NOTE Maintainer: ‘Patrice Lecharpentier ’ New submission @@ -39,12 +39,12 @@ ── SticsRFiles 1.1.3: NOTE - Build ID: SticsRFiles_1.1.3.tar.gz-16096564b3744da893ed5ebd16c3c81f + Build ID: SticsRFiles_1.1.3.tar.gz-c83b92714ee64a8b967a641231cec721 Platform: Fedora Linux, R-devel, clang, gfortran - Submitted: 1h 9m 54.9s ago - Build time: 54m 54.4s + Submitted: 1h 41m 5.2s ago + Build time: 31m 6.5s -❯ checking CRAN incoming feasibility ... [9s/33s] NOTE +❯ checking CRAN incoming feasibility ... [8s/29s] NOTE Maintainer: ‘Patrice Lecharpentier ’ New submission @@ -53,9 +53,3 @@ Skipping checking HTML validation: no command 'tidy' found 0 errors ✔ | 0 warnings ✔ | 2 notes ✖ - - - - - - diff --git a/man/gen_ini_xml.Rd b/man/gen_ini_xml.Rd index f1855ceb..672141b1 100644 --- a/man/gen_ini_xml.Rd +++ b/man/gen_ini_xml.Rd @@ -5,9 +5,9 @@ \title{Generate STICS ini xml file(s) from a template or an input file} \usage{ gen_ini_xml( - param_df = NULL, + param_df, file = NULL, - out_dir = getwd(), + out_dir, crop_tag = "Crop", stics_version = "latest", ini_in_file = lifecycle::deprecated(), diff --git a/man/gen_obs.Rd b/man/gen_obs.Rd index 21887318..8689ee0b 100644 --- a/man/gen_obs.Rd +++ b/man/gen_obs.Rd @@ -6,7 +6,7 @@ \usage{ gen_obs( df, - out_dir = getwd(), + out_dir, usms_list = NULL, obs_table = lifecycle::deprecated(), out_path = lifecycle::deprecated() diff --git a/man/gen_sols_xml.Rd b/man/gen_sols_xml.Rd index 26bdb298..accb55b6 100644 --- a/man/gen_sols_xml.Rd +++ b/man/gen_sols_xml.Rd @@ -5,8 +5,8 @@ \title{Generate STICS sols xml file from a template or an input file} \usage{ gen_sols_xml( - file = file.path(getwd(), "sols.xml"), - param_df = NULL, + file, + param_df, template = NULL, stics_version = "latest", sols_in_file = lifecycle::deprecated(), diff --git a/man/gen_sta_xml.Rd b/man/gen_sta_xml.Rd index 6cfa7270..01c12f04 100644 --- a/man/gen_sta_xml.Rd +++ b/man/gen_sta_xml.Rd @@ -5,9 +5,9 @@ \title{Generate STICS sta xml file(s) from a template or an input file} \usage{ gen_sta_xml( - param_df = NULL, + param_df, file = NULL, - out_dir = getwd(), + out_dir, stics_version = "latest", param_table = lifecycle::deprecated(), sta_in_file = lifecycle::deprecated(), diff --git a/man/gen_tec_xml.Rd b/man/gen_tec_xml.Rd index b9404546..23d2fe91 100644 --- a/man/gen_tec_xml.Rd +++ b/man/gen_tec_xml.Rd @@ -7,7 +7,7 @@ gen_tec_xml( param_df = NULL, file = NULL, - out_dir = getwd(), + out_dir, stics_version = "latest", na_values = NA, param_table = lifecycle::deprecated(), diff --git a/man/gen_usms_xml.Rd b/man/gen_usms_xml.Rd index dc57e1fe..e7ab93a5 100644 --- a/man/gen_usms_xml.Rd +++ b/man/gen_usms_xml.Rd @@ -5,7 +5,7 @@ \title{Generate STICS usms xml file from a template or an input file} \usage{ gen_usms_xml( - file = file.path(getwd(), "usms.xml"), + file, param_df = NULL, template = NULL, stics_version = "latest", @@ -16,8 +16,7 @@ gen_usms_xml( ) } \arguments{ -\item{file}{Path (including name) of the usms file to generate. Optional, -set to \code{file.path(getwd(), "usms.xml")}by default.} +\item{file}{Path (including name) of the usms file to generate.} \item{param_df}{A table (df, tibble) containing the values of the parameters to use (see details)} diff --git a/man/get_climate_txt.Rd b/man/get_climate_txt.Rd index 0a2ff6eb..ebee0645 100644 --- a/man/get_climate_txt.Rd +++ b/man/get_climate_txt.Rd @@ -5,7 +5,7 @@ \title{Read STICS input meteorology file} \usage{ get_climate_txt( - workspace = getwd(), + workspace, file_name = "climat.txt", preserve = TRUE, dirpath = lifecycle::deprecated(), diff --git a/man/get_param_txt.Rd b/man/get_param_txt.Rd index e05f7381..cc352863 100644 --- a/man/get_param_txt.Rd +++ b/man/get_param_txt.Rd @@ -13,7 +13,7 @@ \title{Read STICS input parameters from text files} \usage{ get_param_txt( - workspace = getwd(), + workspace, param = NULL, variety = NULL, exact = FALSE, diff --git a/man/set_param_txt.Rd b/man/set_param_txt.Rd index 00499a0d..65b8d0e1 100644 --- a/man/set_param_txt.Rd +++ b/man/set_param_txt.Rd @@ -13,7 +13,7 @@ \title{Set (replace) STICS input file parameters} \usage{ set_param_txt( - workspace = getwd(), + workspace, param, value, append = FALSE,