Mercurial > repos > siwaa > redelac_stics_g
changeset 7:fb6f7d60508d draft
"planemo upload for repository https://forgemia.inra.fr/redelac commit d1c69d78e9ccfe06ceb7609dce59b438cd94d9d8"
author | siwaa |
---|---|
date | Thu, 20 Jul 2023 16:18:59 +0000 |
parents | bb1ac57f8545 |
children | 0625e6a639ea |
files | redelacSticsInputGenerator.R redelacSticsInputGenerator.bash redelacSticsInputGenerator.xml |
diffstat | 3 files changed, 147 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/redelacSticsInputGenerator.R Fri Jul 07 10:19:22 2023 +0000 +++ b/redelacSticsInputGenerator.R Thu Jul 20 16:18:59 2023 +0000 @@ -1,48 +1,164 @@ library(SticsRFiles) library(dplyr) +library(lubridate) + + +startTime <- Sys.time() workspace <- paste0(getwd(), "/WS") javastics_path <- getwd() txt_path <- paste0(getwd(), "/WS/txt_files") -dir.create(txt_path,recursive = T) +dir.create(txt_path, recursive = T) USMsFile <- "USMs.csv" TecFile <- "Tec.csv" IniFile <- "Ini.csv" StationFile <- "Station.csv" +args = commandArgs(trailingOnly = TRUE) + +genUSMsXmlOneAfterOther <- (args[1] == "usmx_one_after_other") + # USMs file loading + usms_param <- read_params_table(file.path(workspace, USMsFile)) %>% - select(usm_name,datedebut,datefin,finit,nomsol,fstation,fclim1,fclim2,culturean,nbplantes,codesimul,fplt_1,ftec_1,flai_1,fplt_2,ftec_2,flai_2) + select( + usm_name, + datedebut, + datefin, + finit, + nomsol, + fstation, + fclim1, + fclim2, + culturean, + nbplantes, + codesimul, + fplt_1, + ftec_1, + flai_1, + fplt_2, + ftec_2, + flai_2 + ) # Tec files loading and generating xml + tec_param <- read_params_table(file.path(workspace, TecFile)) -columnToRemove <- names(tec_param[grep("juleclair|nbinfloecl", names(tec_param))]) -columnToKeep <- names(tec_param)[names(tec_param) %in% columnToRemove == FALSE] -tec_param <- subset(tec_param, select=columnToKeep) +columnToRemove <- + names(tec_param[grep("juleclair|nbinfloecl", names(tec_param))]) +columnToKeep <- + names(tec_param)[names(tec_param) %in% columnToRemove == FALSE] + +tec_param <- subset(tec_param, select = columnToKeep) + gen_tec_xml(param_df = tec_param, out_dir = workspace) # Ini files loading and generating xml + ini_param <- read_params_table(file.path(workspace, IniFile)) + gen_ini_xml(param_df = ini_param, out_dir = workspace) # Station files loading and generating xml + sta_param <- read_params_table(file.path(workspace, StationFile)) + gen_sta_xml(param_df = sta_param, out_dir = workspace) - -# looping on USMs -for(i in 1:nrow(usms_param)) { - row <- usms_param[i,] - - # generating xml - gen_usms_xml(file = file.path(workspace, "usms.xml"), param_df = row) +if (genUSMsXmlOneAfterOther) { + durGenX <- lubridate::as.duration(0) + durGenT <- lubridate::as.duration(0) + + # looping on USMs + for (i in 1:nrow(usms_param)) { + row <- usms_param[i, ] + + beforeGenXmlTimeI <- Sys.time() + + gen_usms_xml(file = file.path(workspace, "usms.xml"), + param_df = row) + + afterGenXmlTimeI <- Sys.time() + durGenXI <- + lubridate::as.duration(lubridate::interval(beforeGenXmlTimeI, + afterGenXmlTimeI)) + + # one after the other generating txt folder + + beforeGenTxtTimeI <- Sys.time() + + gen_usms_xml2txt( + javastics = javastics_path, + workspace = workspace, + out_dir = txt_path, + verbose = TRUE + ) + + afterGenTxtTimeI <- Sys.time() + durGenTI <- + lubridate::as.duration(lubridate::interval(beforeGenTxtTimeI, + afterGenTxtTimeI)) + + durGenX <- durGenX + durGenXI + durGenT <- durGenT + durGenTI + } +} else { + beforeGenXmlTime <- Sys.time() + + gen_usms_xml(file = file.path(workspace, "usms.xml"), + param_df = usms_param) + + afterGenXmlTime <- Sys.time() + durGenX <- + lubridate::as.duration(lubridate::interval(beforeGenXmlTime, + afterGenXmlTime)) + + beforeGenTxtTime <- Sys.time() + + gen_usms_xml2txt( + javastics = javastics_path, + workspace = workspace, + out_dir = txt_path, + verbose = TRUE + ) + + afterGenTxtTime <- Sys.time() + durGenT <- + lubridate::as.duration(lubridate::interval(beforeGenTxtTime, + afterGenTxtTime)) + +} - # generating txt folder - gen_usms_xml2txt(javastics = javastics_path, - workspace = workspace, - out_dir = txt_path, - verbose = TRUE) -} - +endTime <- Sys.time() +dur <- + lubridate::as.period(lubridate::as.duration(lubridate::interval(startTime, endTime))) +durGenXP <- lubridate::as.period(durGenX) +durGenTP <- lubridate::as.period(durGenT) + +print("REDELAC Report") +print("==============") +print(paste0("number of usms: ", nrow(usms_param))) +print(paste("usms.xml one after the other:", genUSMsXmlOneAfterOther)) +sprintf( + 'overall duration: %g jour(s) %g heure(s) %g minute(s) %g seconde(s)', + lubridate::day(dur), + lubridate::hour(dur), + lubridate::minute(dur), + lubridate::second(dur) +) +sprintf( + 'inside gen_usms_xml duration: %g jour(s) %g heure(s) %g minute(s) %g seconde(s)', + lubridate::day(durGenXP), + lubridate::hour(durGenXP), + lubridate::minute(durGenXP), + lubridate::second(durGenXP) +) +sprintf( + 'inside gen_usms_xml2txt duration: %g jour(s) %g heure(s) %g minute(s) %g seconde(s)', + lubridate::day(durGenTP), + lubridate::hour(durGenTP), + lubridate::minute(durGenTP), + lubridate::second(durGenTP) +)
--- a/redelacSticsInputGenerator.bash Fri Jul 07 10:19:22 2023 +0000 +++ b/redelacSticsInputGenerator.bash Thu Jul 20 16:18:59 2023 +0000 @@ -1,20 +1,20 @@ cp -r /home/rstudio/JavaSTICS-1.5.1-STICS-10.0.0/JavaSTICS-1.5.1-STICS-10.0.0 . && rm -rf JavaSTICS-1.5.1-STICS-10.0.0/config && -cp -r $1/config JavaSTICS-1.5.1-STICS-10.0.0 && -unzip $2 -d TMP && +cp -r $2/config JavaSTICS-1.5.1-STICS-10.0.0 && +unzip -q $3 -d TMP && export WSname=$(ls TMP) && mv TMP/* JavaSTICS-1.5.1-STICS-10.0.0/WS && cp JavaSTICS-1.5.1-STICS-10.0.0/config/param_gen.xml JavaSTICS-1.5.1-STICS-10.0.0/WS && cp JavaSTICS-1.5.1-STICS-10.0.0/config/param_newform.xml JavaSTICS-1.5.1-STICS-10.0.0/WS && -unzip $3 -d TMPbis && +unzip -q $4 -d TMPbis && mv TMPbis/*/* JavaSTICS-1.5.1-STICS-10.0.0/WS && -cp $4 JavaSTICS-1.5.1-STICS-10.0.0/WS/USMs.csv && -cp $5 JavaSTICS-1.5.1-STICS-10.0.0/WS/Tec.csv && -cp $6 JavaSTICS-1.5.1-STICS-10.0.0/WS/Ini.csv && -cp $7 JavaSTICS-1.5.1-STICS-10.0.0/WS/Station.csv && +cp $5 JavaSTICS-1.5.1-STICS-10.0.0/WS/USMs.csv && +cp $6 JavaSTICS-1.5.1-STICS-10.0.0/WS/Tec.csv && +cp $7 JavaSTICS-1.5.1-STICS-10.0.0/WS/Ini.csv && +cp $8 JavaSTICS-1.5.1-STICS-10.0.0/WS/Station.csv && cd JavaSTICS-1.5.1-STICS-10.0.0 && -Rscript --verbose $1/redelacSticsInputGenerator.R && +Rscript --verbose $2/redelacSticsInputGenerator.R $1 && rm WS/1* && mv WS $WSname && -zip -r $WSname $WSname && +zip -q -r $WSname $WSname && cp $WSname.zip $8
--- a/redelacSticsInputGenerator.xml Fri Jul 07 10:19:22 2023 +0000 +++ b/redelacSticsInputGenerator.xml Thu Jul 20 16:18:59 2023 +0000 @@ -5,8 +5,8 @@ </requirements> <command detect_errors="aggressive"> <![CDATA[ - bash $__tool_directory__/redelacSticsInputGenerator.bash $__tool_directory__ ${Workspace} ${Climat} ${USMs} ${Tec} ${Ini} ${Station} ${GeneratedWorkspace} - ]]> + bash $__tool_directory__/redelacSticsInputGenerator.bash ${IterUsmX} $__tool_directory__ ${Workspace} ${Climat} ${USMs} ${Tec} ${Ini} ${Station} ${GeneratedWorkspace} + ]]>{ </command> <inputs> <param name="Workspace" type="data" format="zip" label="Select a stics Workspace (zip file)"/> @@ -16,6 +16,7 @@ <param name="Ini" type="data" format="csv" label="Select the Ini sheet (csv)"/> <param name="Station" type="data" format="csv" label="Select the Station sheet (csv)"/> <param name="Tag" type="text" value="" label="Outputs tag"/> + <param name="IterUsmX" type="boolean" checked="true" truevalue="usmx_one_after_other" falsevalue="usmx_at_once"/> </inputs> <outputs> <data format="zip" name="GeneratedWorkspace"