Mercurial > repos > siwaa > redelac_stics_g
view 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 source
library(SticsRFiles) library(dplyr) workspace <- paste0(getwd(), "/WS") javastics_path <- getwd() txt_path <- paste0(getwd(), "/WS/txt_files") dir.create(txt_path,recursive = T) USMsFile <- "USMs.csv" TecFile <- "Tec.csv" IniFile <- "Ini.csv" StationFile <- "Station.csv" # 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 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 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) # generating txt folder gen_usms_xml2txt(javastics = javastics_path, workspace = workspace, out_dir = txt_path, verbose = TRUE) }