diff redelacSticsInputGenerator.R @ 6:bb1ac57f8545 draft

"planemo upload for repository https://forgemia.inra.fr/redelac commit 5c06627ff4fa4a31f7fae2cd625f32a29ed2d773"
author siwaa
date Fri, 07 Jul 2023 10:19:22 +0000
parents 4f8d87b9c246
children fb6f7d60508d
line wrap: on
line diff
--- a/redelacSticsInputGenerator.R	Tue Jul 04 16:37:44 2023 +0000
+++ b/redelacSticsInputGenerator.R	Fri Jul 07 10:19:22 2023 +0000
@@ -12,39 +12,37 @@
 IniFile <- "Ini.csv"
 StationFile <- "Station.csv"
 
-# Generate STICS xml files------------------------------------------------------------------------------
-
-# USMs file
+# 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)
 
-# Tec files
-tec_param <- read_params_table(file.path(workspace, TecFile)) %>%
-   select(!c(annee, date_min, date_max, Date_res_1, Date_res_2, Type_res_1, Type_res_2, Date_trav_1, Date_trav_2, Date_trav_3, Type_trav_1, Type_trav_2 ,Type_trav_3, plante_sem, date_sem, starts_with("nom_vari"), date_ferti_1, date_ferti_2, date_ferti_3, type_eng_1, type_eng_2, type_eng_3, date_rec, date_des, juleclair, nbinfloecl))
+# 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)
 gen_tec_xml(param_df = tec_param, out_dir = workspace)
 
-# Ini files
+# 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)
 
-# Sta files
+# 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)
 
-# Generate STICS txt files------------------------------------------------------------------------------
-# List of USMs
 
-### Generate txt files into individual folders
-
+# looping on USMs
 for(i in 1:nrow(usms_param)) {
    row <- usms_param[i,]
-   # do stuff with row
-    
+
+   # generating xml
    gen_usms_xml(file = file.path(workspace, "usms.xml"), param_df = row)
 
+   # generating txt folder
    gen_usms_xml2txt(javastics = javastics_path,
 	            workspace = workspace, 
                     out_dir = txt_path,
                     verbose = TRUE)
 }
-    
\ No newline at end of file
+