R/gen_ini_xml.R
gen_ini_xml.Rd
Generate STICS ini xml file(s) from a template or an input file
gen_ini_xml(
param_df,
file = NULL,
out_dir,
crop_tag = "Crop",
stics_version = "latest",
ini_in_file = lifecycle::deprecated(),
param_table = lifecycle::deprecated(),
out_path = lifecycle::deprecated()
)
A table (df, tibble) containing the values of the parameters to use (see details)
Path of an ini xml file to be used as a template. Optional,
if not provided, the function will use a standard template depending on
the STICS version (see stics_version
argument)
Path of the directory where to generate the file(s).
identifier for the crop parameters names related to the main crop, or the associated crop if any (example: Crop is used in the param_table example in the details section below)
Name of the STICS version.
Optional, used if the file
argument is not provided. In this case
the function uses a standard template associated to the STICS version.
None
Please see get_stics_versions_compat()
for the full list of
STICS versions that can be used for the
argument stics_version
.
param_df
is a data.frame
with the following format:
Ini_name | nbplantes | stade0_Crop1 | lai0_Crop1 | masec0_Crop1 |
USM_2017_T1_ini.xml | 1 | snu | 0 | 0 |
Vill09_ini.xml | 1 | snu | 0 | 0 |
Vill10_ini.xml | 1 | snu | 0 | 0 |
Vill11_ini.xml | 1 | snu | 0 | 0 |
Vill12_ini.xml | 1 | snu | 0 | 0 |
Vill13_ini.xml | 1 | snu | 0 | 0 |
Vill14_ini.xml | 1 | snu | 0 | 0 |
Standard_ini.xml | 1 | snu | 0 | 0 |
The first column gives the ini file name (to be generated), all following columns give the parameter value to put in the file, and each line denotes a separate ini file (for e.g. several USMs).
The first column name must contain the keyword ini or Ini or INI as a prefix to be detected (as shown in the table extract above).
If not given (the default, NULL
), the function returns the template as is.
library(readxl)
xl_path <- download_usm_xl(file = "inputs_stics_example.xlsx")
#> Warning: inputs_stics_example.xlsx already exists in /var/folders/1y/56hdyx6x0_jb18k7b4ys9b6w0000gn/T//Rtmp6TMon6
#> Consider to set overwrite = TRUE to overwrite (it | them )
ini_param_df <- read_excel(xl_path, sheet = "Ini")
gen_ini_xml(
out_dir = tempdir(),
param_df = ini_param_df[1:2,]
)