Mercurial > repos > siwaa > redelac_stics_g
comparison 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 |
comparison
equal
deleted
inserted
replaced
5:4f8d87b9c246 | 6:bb1ac57f8545 |
---|---|
10 USMsFile <- "USMs.csv" | 10 USMsFile <- "USMs.csv" |
11 TecFile <- "Tec.csv" | 11 TecFile <- "Tec.csv" |
12 IniFile <- "Ini.csv" | 12 IniFile <- "Ini.csv" |
13 StationFile <- "Station.csv" | 13 StationFile <- "Station.csv" |
14 | 14 |
15 # Generate STICS xml files------------------------------------------------------------------------------ | 15 # USMs file loading |
16 | |
17 # USMs file | |
18 usms_param <- read_params_table(file.path(workspace, USMsFile)) %>% | 16 usms_param <- read_params_table(file.path(workspace, USMsFile)) %>% |
19 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) | 17 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) |
20 | 18 |
21 # Tec files | 19 # Tec files loading and generating xml |
22 tec_param <- read_params_table(file.path(workspace, TecFile)) %>% | 20 tec_param <- read_params_table(file.path(workspace, TecFile)) |
23 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)) | 21 columnToRemove <- names(tec_param[grep("juleclair|nbinfloecl", names(tec_param))]) |
22 columnToKeep <- names(tec_param)[names(tec_param) %in% columnToRemove == FALSE] | |
23 tec_param <- subset(tec_param, select=columnToKeep) | |
24 gen_tec_xml(param_df = tec_param, out_dir = workspace) | 24 gen_tec_xml(param_df = tec_param, out_dir = workspace) |
25 | 25 |
26 # Ini files | 26 # Ini files loading and generating xml |
27 ini_param <- read_params_table(file.path(workspace, IniFile)) | 27 ini_param <- read_params_table(file.path(workspace, IniFile)) |
28 gen_ini_xml(param_df = ini_param, out_dir = workspace) | 28 gen_ini_xml(param_df = ini_param, out_dir = workspace) |
29 | 29 |
30 # Sta files | 30 # Station files loading and generating xml |
31 sta_param <- read_params_table(file.path(workspace, StationFile)) | 31 sta_param <- read_params_table(file.path(workspace, StationFile)) |
32 gen_sta_xml(param_df = sta_param, out_dir = workspace) | 32 gen_sta_xml(param_df = sta_param, out_dir = workspace) |
33 | 33 |
34 # Generate STICS txt files------------------------------------------------------------------------------ | |
35 # List of USMs | |
36 | 34 |
37 ### Generate txt files into individual folders | 35 # looping on USMs |
38 | |
39 for(i in 1:nrow(usms_param)) { | 36 for(i in 1:nrow(usms_param)) { |
40 row <- usms_param[i,] | 37 row <- usms_param[i,] |
41 # do stuff with row | 38 |
42 | 39 # generating xml |
43 gen_usms_xml(file = file.path(workspace, "usms.xml"), param_df = row) | 40 gen_usms_xml(file = file.path(workspace, "usms.xml"), param_df = row) |
44 | 41 |
42 # generating txt folder | |
45 gen_usms_xml2txt(javastics = javastics_path, | 43 gen_usms_xml2txt(javastics = javastics_path, |
46 workspace = workspace, | 44 workspace = workspace, |
47 out_dir = txt_path, | 45 out_dir = txt_path, |
48 verbose = TRUE) | 46 verbose = TRUE) |
49 } | 47 } |