| Title: | Read and Modify STICS Input/Output Files |
| Version: | 1.7.0 |
| Description: | Manipulating input and output files of the 'STICS' crop model (Beaudouin et al. (2022) <doi:10.35690/978-2-7592-3679-4>). The package is based on the model software, which is accessible, as well as resources, on its web site https://stics.inrae.fr/eng/. Files are either 'JavaSTICS' XML files or text files used by the model 'fortran' executable. Most basic functionalities are reading or writing parameter names and values in both XML or text input files, and getting data from output files. Advanced functionalities include XML files generation from XML templates and/or spreadsheets, or text files generation from XML files by using 'xslt' transformation. |
| License: | LGPL (≥ 3) |
| URL: | https://github.com/SticsRPacks/SticsRFiles, https://doi.org/10.5281/zenodo.4443206 |
| BugReports: | https://github.com/SticsRPacks/SticsRFiles/issues |
| Depends: | R (≥ 4.0.0) |
| Imports: | cli, crayon, curl, data.table, doParallel, dplyr (≥ 1.0.0), foreach, lubridate, methods, parallel, rlang, rstudioapi, semver, tibble, tidyr, tidyselect, tools, utils, XML, xml2, xslt |
| Suggests: | covr, formatR, knitr, learnr, readxl, rmarkdown, spelling, testthat |
| VignetteBuilder: | knitr |
| ByteCompile: | true |
| Config/roxygen2/version: | 8.0.0 |
| Encoding: | UTF-8 |
| Language: | en-US |
| Collate: | 'add_node_to_doc.R' 'add_stics_nodes.R' 'all_in_par.R' 'all_out_var.R' 'approx_vapour_pressure.R' 'attributes_list2matrix.R' 'check_choice_param.R' 'check_java_path.R' 'check_java_workspace.R' 'check_output_files.R' 'check_param_names.R' 'check_upgrade_versions.R' 'col_names_to_var.R' 'compute_date_from_day.R' 'compute_day_number.R' 'convert_xml2txt.R' 'convert_xml2txt_int.R' 'download_data.R' 'download_usm_xl.R' 'exist_param_xml.R' 'exists_javastics_pref.R' 'exists_param.R' 'expand_stics_names.R' 'extract.R' 'extract_workspace.R' 'global.R' 'file_document.R' 'find_names.R' 'force_param_values.R' 'gen_climate.R' 'gen_general_param_xml.R' 'gen_ini_doc.R' 'gen_ini_xml.R' 'gen_new_travail.R' 'gen_obs.R' 'gen_paramsti.R' 'gen_sol_xsl_file.R' 'gen_sols_xml.R' 'gen_sta_doc.R' 'gen_sta_xml.R' 'gen_tec_doc.R' 'gen_tec_xml.R' 'gen_usms_sols_doc.R' 'gen_usms_xml.R' 'gen_usms_xml2txt.R' 'gen_varmod.R' 'get_climate_txt.R' 'get_cores_nb.R' 'get_cultivars_list.R' 'get_cultivars_param.R' 'get_dev_stages.R' 'get_file.R' 'get_file_int.R' 'get_files_list.R' 'get_formalisms_xml.R' 'get_java_workspace.R' 'get_lai_forcing.R' 'get_name_value_file_value.R' 'get_obs.R' 'get_option_choice_param_values.R' 'get_options_choices.R' 'get_options_names.R' 'get_param_bounds.R' 'get_param_bounds_xml.R' 'get_param_formalisms.R' 'get_param_info_xml.R' 'get_param_names.R' 'get_param_names_xml.R' 'get_param_number.R' 'get_param_txt.R' 'get_param_type.R' 'get_param_value.R' 'get_param_xml.R' 'get_params_dict.R' 'get_params_from_doc.R' 'get_params_from_doc_attr.R' 'get_params_from_doc_node.R' 'get_params_from_table.R' 'get_plant_name.R' 'get_plants_nb.R' 'get_report_results.R' 'get_sim.R' 'get_soils_list.R' 'get_stics_versions_compat.R' 'get_used_param.R' 'get_usms_list.R' 'get_values_by_param.R' 'get_varmod.R' 'get_xml_base_doc.R' 'get_xml_base_node.R' 'get_xml_doc_example.R' 'get_xml_files_param_df.R' 'get_xml_stics_version.R' 'init_javastics_pref.R' 'is_os_name.R' 'is_stics_doc.R' 'is_stics_xml.R' 'javastics_cmd_util.R' 'javastics_path.R' 'manage_stics_versions.R' 'merge_nodesets.R' 'read_params_table.R' 'remove_node_from_doc.R' 'remove_parent_from_doc.R' 'replace_string_in_file.R' 'replace_txt_param_value.R' 'rewrite_xml_files.R' 'set_codeoptim.R' 'set_file_executable.R' 'set_java_workspace.R' 'set_param_txt.R' 'set_param_value.R' 'set_param_xml.R' 'set_sols_param_xml.R' 'set_usms_param_xml.R' 'setup_parallelism.R' 'static_help.R' 'stics_environment.R' 'stics_files_utils.R' 'upgrade_v10_v11.R' 'upgrade_v9_v10.R' 'upgrade_xml_files.R' 'var_to_col_names.R' 'xml_document.R' 'xml_files_functions.R' 'zzz.R' |
| NeedsCompilation: | no |
| Packaged: | 2026-09-14 13:51:35 UTC; plecharpent |
| Author: | Patrice Lecharpentier
|
| Maintainer: | Patrice Lecharpentier <patrice.lecharpentier@inrae.fr> |
| Repository: | CRAN |
| Date/Publication: | 2026-09-14 22:40:09 UTC |
[ method for cropr_simulation
Description
This method ensure keeping the cropr_simulation attribute when subsetting a
cropr_simulation list.
Usage
## S3 method for class 'cropr_simulation'
x[...]
Arguments
x |
A |
... |
An index |
Value
A subset of a cropr_simulation, keeping its attribute
Examples
path <- file.path(get_examples_path("sti"), "workspace1")
sim <- SticsRFiles::get_sim(workspace = path)
# sim returns a `cropr_simulation` list
Approximate vapour pressure
Description
Approximates vapour pressure as the saturated vapour pressure at the daily mean air temperature using relative humidity. See section 9.3 of the STICS book, as well as M. Launay's explanations on the STICS forum (link).
Usage
approx_vapour_pressure(mean_temp, rel_humid)
Arguments
mean_temp |
numeric vector of daily mean air temperature (in Celsius degrees) |
rel_humid |
numeric vector of relative humidity (in percentage) |
Value
numeric vector
Author(s)
Timothee Flutre
Examples
approx_vapour_pressure(15, 60)
Convert day number into date
Description
Computes the date corresponding to a given day number (or vector of) with reference to a start year. Typically, the start year should be the year of a STICS simulation start, but not necessarily.
Usage
compute_date_from_day(day, start_year)
Arguments
day |
day number(s) to be converted |
start_year |
year to be used as time reference (simulation start year). |
Value
Date vector
Author(s)
Timothee Flutre
Examples
compute_date_from_day(day = 290, start_year = 1994)
compute_date_from_day(day = 700, start_year = 1994)
compute_date_from_day(day = 999, start_year = 1994)
Convert date into day number
Description
Computes the day number corresponding to a given date (or vector of) from the first day of a start year. Typically, the start year should be the year of a STICS simulation start. Leap years are properly handled.
Usage
compute_day_from_date(date, start_year = NULL)
Arguments
date |
date(s) vector to be converted,
in the character format ("YYYY-MM-DD") or |
start_year |
year to be used as time reference (simulation start year). Optional. |
Value
numeric vector
Author(s)
Timothee Flutre
Examples
compute_day_from_date(date = as.Date("2015-02-10"))
compute_day_from_date(date = "2015-02-10", start_year = 2014)
compute_day_from_date(date = as.Date("2009-02-10"), start_year = 2008)
dates <- c(as.Date("2008-02-10"), as.Date("2009-02-10"))
compute_day_from_date(date = dates, start_year = 2008)
Transforming a STICS xml file into a text file
Description
The input file according to his type (ini,plant,tec,station,soil,par) is converted to a text file readable by the STICS model (ficini.txt, ficplt1.txt,...)
Usage
convert_xml2txt(
file,
plant_id = 1,
soil_name = NULL,
out_dir = NULL,
save_as = NULL,
stics_version = "latest"
)
Arguments
file |
Path (including name) of the xml file to convert |
plant_id |
The plant identifier (main crop: 1 ; associated crop: 2) |
soil_name |
Soil name (optional, required for soil file) |
out_dir |
Path of the directory where to generate the file. Optional, set to the path of the input xml file by default |
save_as |
Name of the output file (optional, default: fixed name for STICS) |
stics_version |
the STICS files version to use (optional, default to latest). |
Value
None
Examples
xml_path <- file.path(get_examples_path("xml"), "file_plt.xml")
convert_xml2txt(file = xml_path)
xml_path <- file.path(get_examples_path("xml"), "sols.xml")
convert_xml2txt(file = xml_path, soil_name = "soil_rice")
Download example USMs
Description
Download locally the example data from the data repository in the SticsRPacks organization.
Usage
download_data(
branch = NULL,
out_dir = tempdir(),
example_dirs = NULL,
stics_version = "latest",
raise_error = FALSE
)
Arguments
branch |
Git branch name (optional) |
out_dir |
Path of the directory where to download the data (optional, default: tempdir()) |
example_dirs |
List of use case directories names (optional) |
stics_version |
Name of the STICS version (optional) The default value is the latest version returned by get_stics_versions_compat(). |
raise_error |
Logical, if TRUE, an error is raised instead of message when FALSE (default) |
Value
The path of the folder data have been downloaded into or NULL if the download fails and raise_error is FALSE.
Examples
# Getting data for a given example : study_case_1 and a given STICS version
download_data(example_dirs = "study_case_1", stics_version = "V9.0")
# raising an error instead of a message
download_data(
example_dirs = "study_case_1", stics_version = "V9.0",
raise_error = TRUE
)
Downloading a CSV usms data file example into a directory
Description
The file is an example that can be used for generating JavaSTICS
usms.xml input file from parameters values stored in a CSV file using
the function gen_usms_xml
Usage
download_usm_csv(
file = NULL,
out_dir = tempdir(),
stics_version = "latest",
overwrite = FALSE,
verbose = FALSE
)
Arguments
file |
Name of a csv file (optional, not used for the moment) |
out_dir |
Directory path where to copy the csv file
(default: |
stics_version |
Name of the STICS version. Optional, by default the latest version returned by get_stics_versions_compat() is used. |
overwrite |
Optional logical, TRUE for overwriting files, FALSE otherwise (default) |
verbose |
Logical value for displaying information while running |
Value
A vector of copied files path.
Examples
download_usm_csv()
Downloading an Excel usms data file example into a directory
Description
The file is an example that can be used for generating
JavaSTICS input files from parameters values stored in Excel spreadsheet
format (USMs, Ini, Soils, Tec, Station, ...). Each sheet contains parameters
values to insert into XML files, with the help of these functions:
gen_usms_xml, gen_sols_xml,
gen_tec_xml, gen_sta_xml,
gen_usms_xml, gen_ini_xml
Usage
download_usm_xl(
file = NULL,
out_dir = tempdir(),
stics_version = "latest",
overwrite = FALSE,
verbose = FALSE,
...
)
Arguments
file |
Name of an Excel file (optional, not used for the moment) |
out_dir |
Directory path where to copy the Excel file
(optional, default: |
stics_version |
Name of the STICS version. Optional, by default the latest version returned by get_stics_versions_compat() is used. |
overwrite |
Optional logical, TRUE for overwriting files, FALSE otherwise (default) |
verbose |
Logical value for displaying information while running |
... |
Additional arguments to be passed |
Value
A vector of copied files path.
Examples
download_usm_xl()
Extract an XML JavaSTICS workspace from a source workspace
Description
Extract an XML JavaSTICS workspace from a source workspace
Usage
extract_workspace(
from_workspace,
to_workspace,
javastics,
usm = NULL,
use_mod_files = FALSE
)
Arguments
from_workspace |
Source workspace path |
to_workspace |
Target workspace path |
javastics |
JavaSTICS directory path, needed for getting
plant files which are stored in JavaSTICS |
usm |
vector of situation names (i.e. USMs to extract.) |
use_mod_files |
Logical: if TRUE, *.mod files are searched in the from_workspace and copied to the to_workspace if found. Default is FALSE. |
Value
None
Examples
## Not run:
# Extract all usms from a source workspace to a target workspace
extract_workspace(
"/path/to/source/workspace",
"/path/to/target/workspace",
"/path/to/javastics/dir"
)
# Extract only selected usms from a source workspace to a target workspace
extract_workspace("/path/to/source/workspace",
"/path/to/target/workspace",
"/path/to/javastics/dir",
usm = c("SugarCane", "potato")
)
## End(Not run)
Generates files to force parameters values in STICS simulations
Description
Generates a param.sti file and sets code optim in
new_travail.usm to force parameters values in STICS simulations
(this function is typically called before SticsOnR::run_stics())
Usage
force_param_values(workspace, values, javastics, force = FALSE)
Arguments
workspace |
Path of the workspace containing the STICS (txt) input files. |
values |
named vector of parameter values to force. See Details for more information. |
javastics |
Path of JavaSTICS |
force |
Logical, if |
Details
This function operates on STICS text input files.
Do not use it before calling gen_usms_xml2txt(), otherwise
param.sti and new_travail.usm files will be overwritten.
This function has been created to be called before
SticsOnR::run_stics(). It can not work with SticsOnR::run_javastics(),
that will overwrite param.sti and new_travail.usm files.
values can contain NA. In this case, the corresponding parameter(s)
will not be forced (default value(s), i.e. read in STICS input files,
will be used). If values==NA or values==NULL,
not any parameter will be forced (all default values used).
Value
A logical status TRUE if successful, FALSE otherwise
See Also
SticsOnR::run_stics()
Examples
## Not run:
example_txt_dir <- get_examples_path(file_type = "txt")
force_param_values(example_txt_dir,
setNames(object = c(220, 330), c("stlevamf", "stamflax")),
javastics = "/path/to/javastics"
)
## End(Not run)
Generate STICS general parameters xml file(s) from a template file according to a STICS version
Description
Generate STICS general parameters xml file(s) from a template file according to a STICS version
Usage
gen_general_param_xml(out_dir, stics_version = "latest", overwrite = FALSE)
Arguments
out_dir |
Path of the directory where to generate the file(s). |
stics_version |
Name of the STICS version. Optional, the latest one is used as default |
overwrite |
Optional logical, TRUE for overwriting files, FALSE otherwise (default) |
Details
Please see get_stics_versions_compat() for the full list of
STICS versions that can be used for the argument stics_version.
Value
None
Examples
gen_general_param_xml(out_dir = tempdir())
gen_general_param_xml(
out_dir = tempdir(),
stics_version = "V10.0",
overwrite = TRUE
)
Generate STICS ini xml file(s) from a template or an input file
Description
Generate STICS ini xml file(s) from a template or an input file
Usage
gen_ini_xml(
param_df,
file = NULL,
out_dir,
crop_tag = "Crop",
stics_version = "latest"
)
Arguments
param_df |
A table (df, tibble) containing the values of the parameters to use (see details) |
file |
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 |
out_dir |
Path of the directory where to generate the file(s). |
crop_tag |
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) |
stics_version |
Name of the STICS version.
Optional, used if the |
Details
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.
Value
None
Examples
library(readxl)
xl_path <- download_usm_xl(file = "inputs_stics_example.xlsx")
ini_param_df <- read_excel(xl_path, sheet = "Ini")
gen_ini_xml(
out_dir = tempdir(),
param_df = ini_param_df[1:2, ]
)
Generating observation data files from a data.frame
Description
Generating observation data files from a data.frame
Usage
gen_obs(df, out_dir, usms_list = NULL)
Arguments
df |
A data frame containing the values of the observations to use (see Details). |
out_dir |
Path of the directory where to generate the file(s). |
usms_list |
An optional list of usms names to be used for selecting which files to generate from the obs_table |
Details
df is a data.frame with the following format:
| usm_name | ian | mo | jo | jul | densite | lai(n) | masec(n) | azomes |
| USM_2017_T1_CI | 2017 | 9 | 6 | 249 | NA | NA | 0.31 | 27.07395 |
| USM_2017_T1_CI | 2017 | 9 | 20 | 263 | NA | NA | 0.60 | 27.90000 |
| USM_2018_T1 | 2017 | 10 | 20 | 293 | NA | 0.1 | NA | NA |
| USM_2018_T1 | 2018 | 5 | 15 | 482 | NA | 1.2 | NA | NA |
-
usm_namecolumn contains usms names which are used as output .obs files names -
ian,mo,joandjulare mandatory (year, month, day and julian date) Other columns one per variable contain observations values or NA
@seealso get_var_info for getting variable right syntax or
searching a variable name.
Value
A return logical status indicating if any error when writing files (FALSE), TRUE when no errors.
Examples
xl_path <- download_usm_xl(file = "inputs_stics_example.xlsx")
obs_df <- read_params_table(file = xl_path, sheet_name = "Obs")
gen_obs(df = obs_df, out_dir = "/path/to/dest/dir")
Generate STICS sols xml file from a template or an input file
Description
Generate STICS sols xml file from a template or an input file
Usage
gen_sols_xml(file, param_df, template = NULL, stics_version = "latest")
Arguments
file |
Path (including name) of the sols file to generate. |
param_df |
A table (df, tibble) containing the values of the parameters to use (see details) |
template |
Path of a soil xml file to be used as a template. Optional, if not provided, the function will use a standard template depending on the STICS version. |
stics_version |
Name of the STICS version. Optional, used if the |
Details
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:
| Soil_name | argi | norg | calc | pH | albedo | q0 | epc_1 |
| USM_T1 | 20.35000 | 0.100 | 0.52 | 8.23 | 0.22 | 9.630 | 30 |
| LF1 | 17.00000 | 1.900 | 0.00 | 6.70 | 0.22 | 9.360 | 30 |
| LF2 | 17.00000 | 1.800 | 0.00 | 6.70 | 0.22 | 9.360 | 30 |
| LAP | 22.00000 | 2.000 | 0.00 | 6.50 | 0.22 | 9.760 | 25 |
| LAS | 24.05000 | 2.500 | 30.00 | 8.00 | 0.22 | 9.928 | 30 |
| LA0 | 30.00675 | 2.300 | 0.50 | 7.50 | 0.22 | 10.400 | 30 |
| LC0 | 22.38750 | 2.000 | 10.00 | 7.90 | 0.22 | 9.792 | 25 |
| Vill09 | 25.00000 | 0.101 | 0.40 | 7.90 | 0.22 | 10.000 | 30 |
| Vill10 | 14.30000 | 0.099 | 1.50 | 8.20 | 0.22 | 9.144 | 30 |
| Vill11 | 11.80000 | 0.100 | 0.00 | 7.30 | 0.22 | 8.944 | 30 |
| Vill12 | 14.30000 | 0.091 | 0.60 | 8.30 | 0.22 | 9.144 | 30 |
| Vill13 | 16.80000 | 0.088 | 0.20 | 7.80 | 0.22 | 9.344 | 30 |
| Vill14 | 15.10000 | 0.095 | 1.30 | 7.90 | 0.22 | 9.208 | 30 |
The first column gives the soil name, all following columns give the parameter values to put in the sols.xml file for each soil row.
The first column name must contain the keyword Soil or soil or SOIL 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.
Value
None
Examples
xl_path <- download_usm_xl(file = "inputs_stics_example.xlsx")
sols_param_df <- read_params_table(file = xl_path, sheet_name = "Soils")
gen_sols_xml(
file = file.path(tempdir(), "sols.xml"),
param_df = sols_param_df
)
Generate STICS sta xml file(s) from a template or an input file
Description
Generate STICS sta xml file(s) from a template or an input file
Usage
gen_sta_xml(param_df, file = NULL, out_dir, stics_version = "latest")
Arguments
param_df |
A table (df, tibble) containing the values of the parameters to use (see details) |
file |
Path of a sta xml file to be used as a template. Optional, if not provided, the function will use a standard template depending on the STICS version. |
out_dir |
Path of the directory where to generate the file(s). |
stics_version |
Name of the STICS version. Optional, used if
the |
Details
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:
| Sta_name | zr | NH3ref | latitude | patm | aclim |
| climatex_sta.xml | 2.5 | 0 | 49 | 1000 | 20 |
| climatex2_sta.xml | 2.8 | 0 | 49 | 1000 | 20 |
| climatex3_sta.xml | 2.2 | 0 | 49 | 1000 | 20 |
The first column gives the sta file name (to be generated), all following columns give the parameter value to put in the file, and each line denotes a separate sta file (for e.g. several USMs).
The first column name must contain the keyword sta or Sta or STA 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.
Value
None
Examples
xl_path <- download_usm_xl(file = "inputs_stics_example.xlsx")
sta_param_df <- read_params_table(file = xl_path, sheet_name = "Station")
gen_sta_xml(out_dir = tempdir(), param_df = sta_param_df)
Generate STICS tec xml file(s) from a template or an input file
Description
Generate STICS tec xml file(s) from a template or an input file
Usage
gen_tec_xml(
param_df,
file = NULL,
out_dir,
stics_version = "latest",
na_values = NA
)
Arguments
param_df |
A table (df, tibble) containing the values of the parameters to use (see details) |
file |
Path of a tec xml file to be used as a template. Optional, if not provided, the function will use a standard template depending on the STICS version. |
out_dir |
Path of the directory where to generate the file(s). |
stics_version |
Name of the STICS version. Optional, used if
the |
na_values |
value to use as missing value in param_table (optional, default : NA) |
Details
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:
| Tec_name | julres_1 | coderes_1 |
| USM_2017_T1_CI_tec.xml | NA | 1 |
| BIN_CANPC_05_SEC_220-0-0_34K_CANPC05T3_Q_tec.xml | 110 | 1 |
| BIN_AGT_04_IRR_220-0-0_33K_AGT04T2_Q_tec.xml | 73 | 1 |
| AGA_ARB_13_IRR_220-0-0_37K_ARB13_C_tec.xml | 82 | 1 |
| AGA_ARB_13_SEC_220-0-0_37K_ARB13_C_tec.xml | 82 | 1 |
| FRA_ARB_11_SEC_220-0-0_38K_E_tec.xml | 70 | 1 |
| MAG_ARB_09_SEC_220-0-0_38K_E_tec.xml | 81 | 1 |
| MAG_ARV_12_IRR_220-0-0_36K_ARV12_C_tec.xml | 100 | 1 |
| MAG_ARV_12_SEC_220-0-0_36K_ARV12_C_tec.xml | 100 | 1 |
| FRA_ARB_12_SEC_220-0-0_31K_ARB12_C_tec.xml | 92 | 1 |
| FRA_ARB_13_SEC_220-0-0_37K_ARB13_C_tec.xml | 82 | 1 |
The first column gives the tec file name (to be generated), all following columns give the parameter value to put in the file, and each line denotes a separate tec file (for e.g. several USMs).
The first column name must contain the keyword tec or Tec or TEC 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.
Value
None
Examples
xl_path <- download_usm_xl(file = "inputs_stics_example.xlsx")
tec_param_df <- read_params_table(file = xl_path, sheet_name = "Tec")
gen_tec_xml(out_dir = tempdir(), param_df = tec_param_df[1:2, ])
Generate STICS usms xml file from a template or an input file
Description
Generate STICS usms xml file from a template or an input file
Usage
gen_usms_xml(file, param_df, template = NULL, stics_version = "latest")
Arguments
file |
Path (including name) of the usms file to generate. |
param_df |
A table (df, tibble) containing the values of the parameters to use (see details) |
template |
Path of an USM xml file to be used as a template. Optional, if not provided, the function will use a standard template depending on the STICS version. |
stics_version |
Name of the STICS version. Optional,
used if the |
Details
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:
| usm_name | datedebut | datefin | nomsol |
| USM_2017_T1_CI | 199 | 263 | USM_T1 |
| USM_2018_T1 | 264 | 570 | USM_T1 |
| BIN_CANPC_05_SEC_220-0-0_34K_CANPC05T3_Q | 199 | 263 | LF1 |
| BIN_AGT_04_IRR_220-0-0_33K_AGT04T2_Q | 264 | 570 | LF1 |
| AGA_ARB_13_IRR_220-0-0_37K_ARB13_C | 199 | 263 | F1 |
| AGA_ARB_13_SEC_220-0-0_37K_ARB13_C | 264 | 570 | LF1 |
| FRA_ARB_11_SEC_220-0-0_38K_E | 199 | 263 | LF1 |
| MAG_ARB_09_SEC_220-0-0_38K_E | 264 | 570 | LF1 |
| MAG_ARV_12_IRR_220-0-0_36K_ARV12_C | 199 | 263 | LF1 |
| MAG_ARV_12_SEC_220-0-0_36K_ARV12_C | 264 | 570 | LF1 |
| FRA_ARB_12_SEC_220-0-0_31K_ARB12_C | 199 | 263 | LF1 |
| FRA_ARB_13_SEC_220-0-0_37K_ARB13_C | 264 | 570 | LF1 |
The first column gives the usm name, all following columns give the parameter values to put in the usms.xml file for each usm row.
The first column name must contain the keyword Usm or usm or USM 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.
Value
an invisible xml_document object
Examples
xl_path <- download_usm_xl(file = "inputs_stics_example.xlsx")
usms_param_df <- read_params_table(file = xl_path, sheet_name = "USMs")
gen_usms_xml(
file = file.path(tempdir(), "usms.xml"),
param_df = usms_param_df
)
Generating one or several usms directories from a javastics workspace content
Description
The function creates sets of input files for one or multiple
usms from usms data stored in a JavaSTICS workspace. For multiple usms,
sets will be generated into individual folders named with usm names.
Observations files will be also copied if they are named [usm_name].obs
For one usm, files will be generated either in the workspace directory
or in a subdirectory.
Usage
gen_usms_xml2txt(
javastics = NULL,
workspace = NULL,
out_dir = NULL,
usm = NULL,
stics_version = "latest",
verbose = TRUE,
dir_per_usm_flag = TRUE,
java_cmd = "java",
java_converter = FALSE,
parallel = FALSE,
cores = NA
)
Arguments
javastics |
Path of JavaSTICS. Optional (needed if the JavaSTICS converter is used, java_converter set to TRUE in inputs) |
workspace |
Path of a JavaSTICS workspace (i.e. containing the STICS XML input files). Optional, if not provided the current workspace stored in JavaSTICS preferences will be used. |
out_dir |
The path of the directory where to create usms directories (Optional), if not provided the JavaSTICS workspace will be used as root |
usm |
List of usms to generate (Optional). If not provided, all usms contained in workspace/usms.xml file will be generated. |
stics_version |
the STICS files version to use (optional, default to latest). |
verbose |
Logical value TRUE (default) for displaying information while running, FALSE otherwise |
dir_per_usm_flag |
logical, optional; TRUE (default) if one want to create one directory per USM, FALSE if USM files are generated in the out_dir (only useful for usm of size one) |
java_cmd |
For unix like systems, the java virtual machine command name or executable path. Useful only if the JavaSTICS command line is used for generating files. "java" is the default system command, but a full path to a java executable (other than the default one) may be given |
java_converter |
logical, optional; TRUE for using the JavaSTICS command (a JavaSTICS path must be set in the function inputs), FALSE otherwise (default) |
parallel |
Boolean. Is the computation to be done in parallel ? |
cores |
Number of cores to use for parallel computation. |
Value
A list with named elements: usms_path : created directories paths (for storing STICS input files), files : generated files list (in JavaSTICS workspace origin), copy_status : logical value vector, indicating if all files have been generated for each usm obs_copy_status : logical value vector, indicating if observation files have been successfully copied in usms directories
Examples
## Not run:
javastics <- "/path/to/JavaSTICS/folder"
workspace <- "/path/to/workspace"
# For all usms
gen_usms_xml2txt(javastics, workspace)
# For an usms list
usm_list <- c("usm1", "usm2")
gen_usms_xml2txt(javastics, workspace, usms = usm_list)
## End(Not run)
Generating a var.mod type file
Description
Generating a daily variable list file from variables names
Usage
gen_varmod(
workspace,
var,
append = FALSE,
file_name = "var.mod",
stics_version = "latest",
force = FALSE,
verbose = FALSE
)
Arguments
workspace |
Path of the directory containing the STICS var.mod file to modify |
var |
vector of variables names (see details) |
append |
if TRUE, |
file_name |
file name to generate (without path, default value: "var.mod") |
stics_version |
Name of the STICS version (used to check variable names) |
force |
Force variables writing even if they are not a STICS variable (default: FALSE). |
verbose |
if TRUE displaying warning, FALSE otherwise (default) |
Details
Variable names can be found using get_var_info(). They are
checked before writing. If any variable name does not exist,
it will not be written by default, but the function will still write
the variables that exist. force= TRUE may however be used to write
variables that do not exist. Variables already present in a var.mod file
can be listed using get_varmod().
Value
None
Examples
# generate a new file
gen_varmod(tempdir(), c("lai(n)", "hauteur"))
# Add a variable to the others
# var.mod will contain now "lai(n)","hauteur" and "masec(n)"
gen_varmod(tempdir(), "masec(n)", append = TRUE)
Read STICS input meteorology file
Description
Read the meteorology input for STICS ("climat.txt")
Usage
get_climate_txt(workspace, file_name = "climat.txt", preserve = TRUE)
Arguments
workspace |
Path of the workspace containing the STICS climate file to read |
file_name |
The meteorology file name (default to |
preserve |
Logical, |
Value
A data.frame of the input meteorological variables used as input for the STICS model.
Note
The time-related variables are summarized into one POSIXct column named
date.
Examples
path <- get_examples_path(file_type = "txt")
meteo_data <- get_climate_txt(path)
Get the cultivar names for an xml plant file (*_plt.xml)
Description
Extracts the cultivar names from a plant file
Usage
get_cultivars_list(file)
Arguments
file |
The path of a plant file. |
Value
A vector of cultivar names
Examples
path <- get_examples_path(file_type = "xml")
# Read from a plant file (all cultivars available in a plant file)
cv_list <- get_cultivars_list(file = file.path(path, "file_plt.xml"))
Get the values of cultivar-specific parameters from an xml plant file (*_plt.xml)
Description
Extracts the values of cultivar-specific parameters from a plant file
Usage
get_cultivars_param(file)
Arguments
file |
The path of a plant file. |
Value
A data.frame with one row per cultivar and one column per parameter
Examples
path <- get_examples_path(file_type = "xml")
# Read from a plant file (all cultivars available in a plant file)
cv_param_df <- get_cultivars_param(file = file.path(path, "file_plt.xml"))
Get developmental stages from simulations
Description
Extracts the values of developmental stages from simulations
Usage
get_dev_stages(
sim,
dev_vars = c("iplts", "imbs", "ilets", "igers", "idebdorms", "ifindorms", "ilevs",
"iamfs", "ilaxs", "ilats", "iflos", "idrps", "inous", "idebdess", "imats", "irecs"),
usm = NULL
)
Arguments
sim |
A list, where each element is a |
dev_vars |
Vector of output variables corresponding to developmental stages. |
usm |
Vector of USM names. Optional, if not provided, the function returns the results for all USMs. |
Value
List of data.frame, one per USM, with one row per developmental stage.
Author(s)
Timothee Flutre
See Also
Examples
## Not run:
simulations <- get_sim(workspace)
get_dev_stages(simulations, "iplts")
## End(Not run)
Getting examples files path attached to a STICS version for a given file type
Description
Getting examples files path attached to a STICS version for a given file type
Usage
get_examples_path(file_type, stics_version = "latest", overwrite = FALSE)
Arguments
file_type |
A file type string among files types or a vector of ("csv", "obs", "sti", "txt", "xml") |
stics_version |
Name of the STICS version. Optional, by default
the latest version returned by |
overwrite |
TRUE for overwriting directory; FALSE otherwise |
Value
A directory path for examples files for given file type and STICS version or a vector of (for unknown file types "" is returned as path)
Examples
get_examples_path(file_type = "csv")
get_examples_path(file_type = c("csv", "sti"))
get_examples_path(file_type = "csv", stics_version = "V8.5")
Getting existing xml files path list per usm from an usms.xml file
Description
Getting existing xml files path list per usm from an usms.xml file
Usage
get_files_list(
workspace,
usm = NULL,
usms_file = "usms.xml",
file_type = NULL,
only_existing = TRUE,
javastics = NULL,
use_mod_files = FALSE
)
Arguments
workspace |
Path of a JavaSTICS workspace (i.e. containing the STICS XML input files) |
usm |
Vector of usms names (optional) |
usms_file |
Path (including name) of a USM XML file (default: usms.xml). |
file_type |
Vector of file(s) type to get (optional; if not given, all types are returned, see details) |
only_existing |
logical, optional; if TRUE (default) only existing files list is returned, FALSE otherwise for all files |
javastics |
Path of JavaSTICS (optional), only needed when the plant files, general parameter files or .mod files are not in the workspace but included in the JavaSTICS distribution |
use_mod_files |
logical, optional; if TRUE adding the .mod files to the list FALSE otherwise (default) |
Details
The possible values for file_type are: "fplt", "finit", "fclim1", "fclim2", "fstation", "ftec", "sols", "pargen", "parnew", "usms", "mod"
Value
A named list (usms names) with files path in paths field and
a logical vector in exist field indicating if the file exists or not.
See Also
See get_soils_list() to get all soils in a usm file,
and get_usms_list() to get the list of usms.
Examples
## Not run:
get_files_list(
workspace = "/path/to/workspace",
javastics = "/path/to/JavaSTICS/folder"
)
get_files_list(
workspace = "/path/to/workspace",
javastics = "/path/to/JavaSTICS/folder",
usm = c("usm1", "usm3")
)
get_files_list(
workspace = "/path/to/workspace",
file_type = c("finit", "ftec")
)
get_files_list(
workspace = "/path/to/workspace",
use_mod_files = TRUE,
javastics = "/path/to/JavaSTICS/folder"
)
## End(Not run)
Getting LAI forcing for each usm
Description
Is LAI forced for usms in usms.xml
Usage
get_lai_forcing(usm_file_path, usms_list = c())
Arguments
usm_file_path |
Path to usms.xml file |
usms_list |
Usm(s) name(s) (optional, see details) |
Details
Use get_usms_list() to get the list of the usm names for an
usms.xml file.
Value
A named numeric vector with a Boolean value (TRUE = forced)
for each usm
Examples
# Xml case
xml_usms <- file.path(get_examples_path(file_type = "xml"), "usms.xml")
get_lai_forcing(xml_usms)
get_lai_forcing(xml_usms, "wheat")
get_lai_forcing(xml_usms, c("wheat", "intercrop_pea_barley"))
Read STICS observation files (*.obs)
Description
Read STICS observation files from a JavaSTICS workspace and store data into a list per usm
Usage
get_obs(
workspace,
usm = NULL,
var = NULL,
dates = NULL,
usms_file = NULL,
javastics = NULL,
verbose = TRUE,
parallel = FALSE,
cores = NA
)
Arguments
workspace |
Vector of path(s) of directory(ies) containing the STICS
observation files to read (*.obs file) or path of a single directory
containing one sub-folder per USM (named as the USM names),
each of them containing the corresponding files to read.
In the second case, the argument |
usm |
Vector of USM names. Optional, if not provided, the function returns the results for all USMs. |
var |
Vector of variable names for which results have to be provided.
Optional, all variables considered by default. See |
dates |
list of dates to filter (POSIX date) |
usms_file |
Path of a USM xml file. Optional, if provided, the plant names are added in the Plant column (see details). |
javastics |
Path of JavaSTICS. Optional, should be provided in addition to usms_file to get the plant codes if the plant files used are not in the workspace but in the JavaSTICS distribution (see Details). |
verbose |
Logical value for displaying or not information while running |
parallel |
Boolean. Is the computation to be done in parallel ? |
cores |
Number of cores to use for parallel computation. |
Details
The .obs files names must match USMs names, e.g. for a usm
called "banana", the .obs file should be named banana.obs.
For intercrops, the name should be suffixed by "p" for the principal
and "a" for the associated plant.
If usm is not specified (or equal to NULL), the
function reads the files from all usms in the workspace(s).
If usms_file is provided and if the associated plant file is found,
the plant names in the "Plant" column of the generated data.frame
are either the plant code (as specified in the plant file) or
the name of the plant file, if the plant file is not found.
If usms_file is not specified, the plants are named "plant_1"
by default (+ "plant_2" for intercrops).
Value
A list, where each element is a data.frame of observations
for the given usm. The list is named after the USM name.
Intercrops are returned in a single data.frame, and are identified
using either the "Plant" or "Dominance" columns.
See Details section for more information about the "Plant" column.
Examples
path <- file.path(get_examples_path(file_type = "obs"), "mixed")
# Get observations for all usms, but only banana has observations:
Meas <- get_obs(path)
# Get observations only for banana:
Meas_banana <- get_obs(path, "banana")
## Not run:
# Get observations with real plant names when plant
# folder is not in the workspace:
get_obs(path, "banana", javastics = "/path/to/JavaSTICS/folder")
## End(Not run)
Finding parameters information using partial search words
Description
Helper function that returns names and descriptions of STICS input parameters from a partial name and/or descriptive keywords.
Usage
get_param_info(param = NULL, keyword = NULL, stics_version = "latest")
Arguments
param |
Vector of parameter names (or partial names). Optional, if not provided, the function returns information for all parameters |
keyword |
Optional, strings or a vector of to be used for searching in parameters names and definition |
stics_version |
Name of the STICS version. Optional, can be used
to search parameters information relative to a specific STICS version.
By default the latest version returned by |
Details
The function understand regex as input.
Value
A data.frame with information about parameter(s) with columns
name, file, min, max, definition, unit and cultivar
Examples
# Find by parameter name (fuzzy search):
SticsRFiles::get_param_info("alb")
SticsRFiles::get_param_info("alb[e]?")
# Find by keyword (fuzzy search in parameter name and description):
SticsRFiles::get_param_info(keyword = "bdil")
# Find for a particular version:
SticsRFiles::get_param_info("alb", stics_version = "V9.0")
get_param_info()
Read STICS input parameters from text files
Description
Read STICS model input parameters from a usm in text format
(STICS input)
Generally used after calling building a usm with JavaSTICS.
Read a specific STICS model input parameter file.
Users would generally use the wrapper get_param_txt() instead.
Usage
get_param_txt(
workspace,
param = NULL,
plant_id = NULL,
variety = NULL,
value_id = NULL,
exact = FALSE,
stics_version = "latest",
...
)
get_ini_txt(file = "ficini.txt", stics_version, workspace = NULL)
get_general_txt(file = "tempopar.sti", workspace = NULL)
get_tmp_txt(file = "tempoparv6.sti", workspace = NULL)
get_plant_txt(file = "ficplt1.txt", variety = NULL, workspace = NULL)
get_tec_txt(
file = "fictec1.txt",
stics_version = "latest",
several_fert = NULL,
several_thin = NULL,
is_pasture = NULL,
workspace = NULL,
...
)
get_soil_txt(file = "param.sol", stics_version, workspace = NULL)
get_station_txt(file = "station.txt", workspace = NULL)
get_usm_txt(file = "new_travail.usm", plant_id = NULL, workspace = NULL)
Arguments
workspace |
Path of the workspace containing the STICS (txt) input files. |
param |
Vector of parameter names. Optional, if not provided, the function returns an object with all parameters. |
plant_id |
plant index (1, 2), default(NULL) calculated from from plant number in STICS initialization file |
variety |
Integer. The plant variety to get the parameter from. |
value_id |
index of technical interventions to be used to retrieve parameter values, or layer index for soil parameters |
exact |
Boolean indicating if the function must return results only for exact match. |
stics_version |
An optional version name as listed in get_stics_versions_compat() return |
... |
Further arguments to pass (for future-proofing only) |
file |
File path |
several_fert |
Is there several fertilization in the USM ? See details. |
several_thin |
Is there several thinning in the USM ? See details. |
is_pasture |
Is the plant a pasture ? See details. |
Details
If the variety is not given and a param is asked,
the function will return the values for the variety that is simulated in
the USM by checking the variete parameter in the technical file.
If param is not provided by the user, the values from all varieties
will be returned unless the user ask for a given variety.
several_fert, several_thin and is_pasture are read from
the tmp file (tempoparv6.sti). get_param_txt() does it automatically.
If you absolutely need to use directly get_tec_txt, please see example.
Value
A list of parameters value(s),
or if param = NULL a list of all parameters:
ini |
Initialization parameters |
general |
General parameters |
tec |
Technical parameters |
plant |
Plant parameters |
soil |
Soil parameters |
station |
Station parameters |
A list of parameters, depending on the file/function:
ini |
Initialization parameters |
general |
General parameters |
tec |
Technical parameters |
plant |
Plant parameters |
soil |
Soil parameters |
station |
Station parameters |
tmp |
Temporary parameters |
Note
Users would generally use get_param_txt to identify parameters
names and values and pass them to other functions.
The functions are compatible with intercrops. Users generally only use
get_param_txt(), which is a wrapper for all these functions.
See Also
gen_varmod(),
get_param_txt().
Examples
path <- get_examples_path(file_type = "txt")
# Getting the interrow distance parameter value
get_param_txt(path, param = "interrang")
# Getting varietal parameters values
# Get the leaf lifespan of the variety used in the usm:
get_param_txt(workspace = path, param = "durvieF")
# Get the leaf lifespan of another variety available in the plant file:
get_param_txt(workspace = path, param = "durvieF", variety = "Furio")
# To get the values for several (or all) varieties, either put all varieties:
varieties <- c("Pactol", "Cherif", "Furio", "Dunia", "Volga", "Cecilia")
get_param_txt(workspace = path, param = "durvieF", variety = varieties)
# Or get it from the output of the function returning all parameters:
get_param_txt(workspace = path)$plant$plant1$durvieF
# Get parameters for a specific plant
get_param_txt(workspace = path, plant_id = 1)
get_param_txt(workspace = path, param = "durvieF", plant_id = 1)
get_param_txt(
workspace = path, param = "durvieF", plant_id = 1,
variety = varieties
)
# Get parameters for specific interventions or soil layers
get_param_txt(workspace = path, param = "amount", value_id = c(1, 3))
get_param_txt(workspace = path, param = "Hinitf", value_id = c(1, 3))
get_param_txt(workspace = path, param = "epc", value_id = c(1, 3))
## Not run:
# Read the initialization file (ficini.txt):
library(SticsRFiles)
path <- file.path(get_examples_path(file_type = "txt"), "ficini.txt")
get_ini_txt(path)
# Read the tec file directly:
# First, get the parameters from the tmp file:
tmp <- get_tmp_txt(
workspace = get_examples_path(file_type = "txt")
)
several_fert <- tmp$option_engrais_multiple == 1
several_thin <- tmp$option_thinning == 1
is_pasture <- tmp$option_pature == 1
# Then, get the technical parameters:
get_tec_txt(
workspace = get_examples_path(file_type = "txt"),
file = "fictec1.txt",
several_fert = several_fert, several_thin = several_thin,
is_pasture = is_pasture
)
## End(Not run)
Getting parameter values from xml files
Description
Extracting parameter values for a list of xml files and parameters
Usage
get_param_xml(
file,
param = NULL,
select = NULL,
select_value = NULL,
value_id = NULL,
...
)
Arguments
file |
Vector of the xml file paths from which parameters values must be extracted |
param |
Vector of parameter names. Optional, if not provided, the function returns information for all parameters. |
select |
node name or attribute name to use for selection (optional, default to no selection) |
select_value |
Vector of values used for select (see examples). Optional, should be provided only if select is provided. |
value_id |
Vector of ids of the parameters values to be retrieved from the parameter values vector |
... |
Pass further arguments to |
Value
A list of parameter values for each file (a list of list)
Examples
# Soil file
file <- file.path(get_examples_path(file_type = "xml"), "sols.xml")
# For all soils
get_param_xml(file)
get_param_xml(file, c("argi", "norg"))
# With soil selection
# scalar parameters per soil
get_param_xml(file, c("argi", "norg"),
select = "sol", select_value = c("solcanne", "solbanane")
)
# Crop management file
file <- file.path(get_examples_path(file_type = "xml"), "file_tec.xml")
# Getting parameters for irrigation (date and quantity)
get_param_xml(file, c("julapI_or_sum_upvt", "amount"))
Getting plants code from plant files list by usm
Description
Getting plants code from plant files list by usm
Usage
get_plant_code(plant_dir_path, plant_xml_names)
Arguments
plant_dir_path |
vector of plant files directories |
plant_xml_names |
named list of plant files by usm |
Value
a named list of plant codes by usm
Getting xml plant files by usm from an usms.xml file
Description
Getting xml plant files by usm from an usms.xml file
Usage
get_plant_files(usms_file, usms = NULL)
Arguments
usms_file |
usms.xml file path |
usms |
usms names to get, if NULL all the usms are taken into account |
Value
A named list with usm names containing plant files names
Examples
## Not run:
get_plant_files("path/to/usms.xml")
get_plant_files("path/to/usms.xml", c("usm1", "usm2")
## End(Not run)
Getting plant tag(s) from a plant files list by usm
Description
Getting plant tag(s) from a plant files list by usm
Usage
get_plant_id(usms_plant)
Arguments
usms_plant |
a list of plants files names by usm |
Value
a list of plant tags by usm
Getting plants number per usm for all usms or selected from a usm name vector
Description
Extracting plant number from usms.xml or new_travail.usm file data
Usage
get_plants_nb(usms_file, usms_list = c())
Arguments
usms_file |
Path (including name) of a USM xml file or of a new_travail.usm file |
usms_list |
Usm(s) name(s) (optional, see details) |
Details
Use get_usms_list() to get the list of the usm names for
an usms.xml file.
Value
A named numeric vector of plants number per usm
Examples
# Xml case
xml_usms <- file.path(get_examples_path(file_type = "xml"), "usms.xml")
get_plants_nb(xml_usms)
get_plants_nb(xml_usms, "wheat")
get_plants_nb(xml_usms, c("wheat", "intercrop_pea_barley"))
# Txt case
txt_usm <- file.path(get_examples_path(file_type = "txt"), "new_travail.usm")
get_plants_nb(txt_usm)
Extracting data from the STICS report file
Description
Extracting data from the STICS report file
Usage
get_report_results(
workspace,
file_name = "mod_rapport.sti",
usm = NULL,
var_list = NULL
)
Arguments
workspace |
Path of the directory containing the STICS report file to read. |
file_name |
A report file name among "mod_rapport.sti" (default), "mod_rapportA.sti", "mod_rapportP.sti" |
usm |
Vector of USM names. Optional, if not provided, the function returns the results for all USMs. |
var_list |
vector of output variables names to filter
(optional, see |
Details
The data may be filtered using usm_name vector of usm names and
and/or var_list vector of variables names. In the returned data.frame,
variables names respect the same syntax as in the get_sim output.
Value
A data.frame
Examples
path <- get_examples_path(file_type = "sti")
get_report_results(workspace = path)
get_report_results(workspace = path, usm = c("DurumWheat", "grass"))
get_report_results(workspace = path, var_list = c("masec(n)", "QNplante"))
get_report_results(workspace = path, usm = c("DurumWheat", "grass"))
get_report_results(workspace = path)
get_report_results(workspace = path, file_name = "mod_rapportA.sti")
Load and format STICS daily output file(s)
Description
Reads and format daily output file(s) (mod_s*.sti) for usm(s) with possible selection on variable names, cumulative DOY and dates
Usage
get_sim(
workspace,
usm = NULL,
var = NULL,
dates = NULL,
usms_file = NULL,
javastics = NULL,
verbose = TRUE,
parallel = FALSE,
cores = NA
)
Arguments
workspace |
Vector of path(s) of directory(ies) containing the STICS
output files to read (mod_s*.sti file) or path of a single directory
containing one sub-folder per USM (named as the USM names),
each of them containing the corresponding STICS output file to read.
In the second case, the argument |
usm |
Vector of USM names. Optional, if not provided, the function returns the results for all USMs. |
var |
Vector of variable names for which results have to be provided.
Optional, all variables considered by default. See |
dates |
list of dates to filter (POSIX date) |
usms_file |
Path of a USM xml file. Optional, if provided, the plant names are added in the Plant column (see details). |
javastics |
Path of JavaSTICS Optional, should be provided in addition to usms_file to get the plant codes if the plant files used are not in the workspace but in the JavaSTICS distribution (see Details). |
verbose |
Logical value for displaying or not information while running |
parallel |
Boolean. Is the computation to be done in parallel ? |
cores |
Number of cores to use for parallel computation. |
Details
If usm is not specified (or equal to NULL), the
function reads the files from all usms in the workspace(s).
If usms_file is provided and if the associated plant file is found,
the plant names in the "Plant" column of the generated data.frame
are either the plant code (as specified in the plant file) or
the name of the plant file, if the plant file is not found.
If usms_file is not specified, the plants are named "plant_1" by default
(+ "plant_2" for intercrops).
Value
A list, where each element is a data.frame of simulation results
for the given usm. The list is named after the USM name.
Intercrops are returned in a single data.frame, and are identified
using either the "Plant" or "Dominance" columns.
See Details section for more information about the "Plant" column.
Examples
path <- get_examples_path(file_type = "sti")
sim_data <- get_sim(path, "banana")
Get the soil names for an usms.xml or sols.xml file
Description
Extracts the soil names from a USMs file, or from a soil file
Usage
get_soils_list(file, soil = NULL)
Arguments
file |
Either the path of an usm file or of a soil file. |
soil |
Vector of soil names (or partial names). Optional, if not provided, the function returns the names of all the soils included in the given file. |
Details
The file given as the file_path is either a "usms" file type
to get all the soils used in a particular USM, or a soil file type ("sols")
to get all soil types available in a soil file.
Value
A vector of soil names
Examples
path <- get_examples_path(file_type = "xml")
# Read from a usms file (soils used in a USM):
soil_list <- get_soils_list(file = file.path(path, "usms.xml"))
# Read from a soil file (all soil types available in a soil file)
soil_list <- get_soils_list(file = file.path(path, "sols.xml"))
soil_list <- get_soils_list(
file = file.path(path, "usms.xml"),
soil = c("solcanne", "sole")
)
Get the compatible STICS versions
Description
Get the versions of STICS that are fully compatible with this package.
Usage
get_stics_versions_compat(version_index = NULL)
Arguments
version_index |
Absolute positive index, or negative relative index from latest version |
Value
A named list with the STICS versions compatible with this package ($versions_list), and the latest version in use ($latest_version) or an existing version selected using version_index.
Examples
# Getting the complete versions list
get_stics_versions_compat()
# Getting the first version
get_stics_versions_compat(1)
# Getting the previous version of the latest one
get_stics_versions_compat(-1)
Getting usms names list for an usms.xml file
Description
Extracting a usm names list from an usms.xml file
Usage
get_usms_list(file, usm = NULL)
Arguments
file |
Path (including name) of the USM xml file |
usm |
Vector of USM names (or partial names). Optional, if not provided, the function returns the names of all the USMs included in the given file. |
Value
A vector of usm names
Examples
path <- get_examples_path(file_type = "xml")
usms_list <- get_usms_list(file = file.path(path, "usms.xml"))
usms_list <- get_usms_list(
file = file.path(path, "usms.xml"),
usm = c("usm1", "usm2")
)
Find STICS output variable names and description
Description
Helper function that returns names and descriptions of STICS output variables from a partial name and/or descriptive keywords.
Usage
get_var_info(var = NULL, keyword = NULL, stics_version = "latest")
Arguments
var |
Vector of variable names (or partial names). Optional, if not provided, the function returns information for all variables. |
keyword |
Search by keyword instead of variable name (search in the name and description field) |
stics_version |
Name of the STICS version. Optional, can be used
to search parameters information relative to a specific STICS version.
By default the latest version returned by |
Details
The function understand regex as input.
Value
A data.frame with information about variable(s) with columns
name, definition, unit, type
Examples
# Find by variable name (fuzzy search):
SticsRFiles::get_var_info("lai")
# Find by keyword (fuzzy search in variable name and description):
SticsRFiles::get_var_info(keyword = "lai")
# Find for a particular version:
SticsRFiles::get_var_info("lai", stics_version = "V9.0")
get_var_info()
Get desired STICS outputs
Description
Get the STICS output variables (from var.mod file)
Usage
get_varmod(workspace, file_name = "var.mod")
Arguments
workspace |
Path of the directory containing the STICS var.mod file |
file_name |
file name to read (without path, default value: "var.mod") |
Details
A var.mod file can be created or modified using gen_varmod().
Value
The variables that will be returned by STICS
See Also
gen_varmod
Examples
get_varmod(get_examples_path(file_type = "txt"))
Extracting a data.frame of parameters values for an xml file or a set of (whatever the xml file kind)
Description
Extracting a data.frame of parameters values for an xml file or a set of (whatever the xml file kind)
Usage
get_xml_files_param_df(file_path, param_names = NULL, wide_shape = FALSE)
Arguments
file_path |
A file path or a vector of STICS XML files |
param_names |
vector of parameters names (optional) |
wide_shape |
Optional logical for keeping the long data.frame format FALSE, default) or converting it to a wider format one (TRUE), with parameters as columns |
Details
An extract of returned data.frames with the 2 formats from an usms.xml file as input
Default data.frame long format
| name | type | param | id | value |
| SugarCane | usms | datedebut | NA | 286 |
| SugarCane | usms | datefin | NA | 650 |
| SugarCane | usms | finit | NA | canne_ini.xml |
| SugarCane | usms | nomsol | NA | solcanne |
| SugarCane | usms | fstation | NA | climcanj_sta.xml |
| ... | ... | ... | ... | ... |
| ... | ... | ... | ... | ... |
| param_gen.xml | fichierpar | Qmulchdec | 17 | 0 |
| param_gen.xml | fichierpar | Qmulchdec | 18 | 0 |
| param_gen.xml | fichierpar | Qmulchdec | 19 | 0 |
| param_gen.xml | fichierpar | Qmulchdec | 20 | 0 |
| param_gen.xml | fichierpar | Qmulchdec | 21 | 0 |
name: a file name or an usm or soil name type: type of file param: param name id: NA for scalar, integer id for vectors parameters value: parameter value
wide data.frame format
| name | type | datedebut | datefin | finit | nomsol |
| SugarCane | usms | 286 | 650 | canne_ini.xml | solcanne |
| potato | usms | 91 | 250 | patate_ini.xml | solpatate |
| banana | usms | 30 | 300 | banane_ini.xml | solbanane |
| sorghum | usms | 112 | 360 | sorgho_ini.xml | solsorgho |
| barley | usms | 88 | 196 | orge_ini.xml | solorge |
name: a file name or an usm or soil name type: type of file all other columns names correspond to parameter names, with indices as suffix for multiple values (as in _tec.xml files)
Value
A single long data.frame with name, type, param, id and value columns, value is of type character. or a wide a data.frame with name, type, and all other columns correspond to parameter names, with indices as suffix for multiple values (as in _tec.xml files for water supply, N supply, ...)
Examples
## Not run:
dir_path <- get_examples_path("xml")
get_xml_files_param_df(
file_path = file.path(dir_path, "sols.xml")
)
files_list <- file.path(dir_path, c("sols.xml", "usms.xml", "param_gen.xml"))
# long format (default)
get_xml_files_param_df(file_path = files_list)
# wide format
get_xml_files_param_df(file_path = files_list, wide_shape = TRUE)
## End(Not run)
Getting years from file(s) names(s)
Description
Getting years from file(s) names(s)
Usage
get_year_from_file_name(file_path)
Arguments
file_path |
a vector of weather file path(s) |
Value
a vector of numeric years
Examples
#'
## Not run:
get_year_from_file_name(
c("path/to/weather.year1", "path/to/weather.year2")
)
# should return c(year1, year2)
get_year_from_file_name(
c("path/to/weather.year1", "path/to/weather.year3")
)
# should return c(year1, year2, year3)
## End(Not run)
Evaluating if the OS is a Mac OS type
Description
Evaluating if the OS is a Mac OS type
Usage
is_mac()
Value
TRUE/FALSE
Examples
is_mac()
Search if a STICS parameter exist
Description
Tells if one or more parameter names are valid STICS input parameters.
Usage
is_stics_param(param, stics_version = "latest")
Arguments
param |
A vector of parameter names |
stics_version |
Name of the STICS version. Optional, can be used
to search parameters information relative to a specific STICS version.
By default the latest version returned by |
Value
A boolean vector: TRUE if the parameter exist, FALSE otherwise
See Also
get_param_info() for interactive use.
Examples
is_stics_param(c("adil", "adilmax", "unknown"))
Search if a STICS variable exist
Description
Tells if one or more variable names are valid STICS output variables.
Usage
is_stics_var(var, stics_version = "latest", verbose = FALSE)
Arguments
var |
A vector of variable names |
stics_version |
Name of the STICS version. Optional, can be used
to search parameters information relative to a specific STICS version.
By default the latest version returned by |
verbose |
if TRUE displaying warning, FALSE otherwise (default) |
Value
A boolean vector: TRUE if the variable exist, FALSE otherwise
See Also
get_var_info() for interactive use.
Examples
is_stics_var(c("lai(n)", "masec(n)", "unknown"))
Evaluating if the OS is a unix like type
Description
Evaluating if the OS is a unix like type
Usage
is_unix()
Value
TRUE/FALSE
Examples
is_unix()
Evaluating if the OS is a windows type
Description
Evaluating if the OS is a windows type
Usage
is_windows()
Value
TRUE/FALSE
Examples
is_windows()
Getting parameters data from tables files (Excel sheet, csv)
Description
Getting parameters data from tables files (Excel sheet, csv)
Usage
read_params_table(file_path, sheet_name = NULL, num_na = "NA", char_na = "NA")
Arguments
file_path |
Excel or csv file path (including name of the file) |
sheet_name |
Name of an Excel sheet (useless for csv files) |
num_na |
Replacement value for numerical NA values (default: NA) |
char_na |
Replacement value for character NA values (default: "") |
Details
After data are loaded, numerical and string NA values are replaced respectively with num_na or char_na
Value
A tibble of parameters
Examples
usm_xl_file <- download_usm_xl(
file_name = "inputs_stics_example.xlsx",
verbose = FALSE
)
read_params_table(usm_xl_file, sheet = "USMs")
usm_csv_file <- download_usm_csv(
file = "inputs_stics_example_USMs.csv",
stics_version = "V9.2"
)
read_params_table(file_path = usm_csv_file)
Set (replace) STICS input file parameters
Description
Replace or set an input parameter from an existing STICS input file.
Usage
set_param_txt(
workspace,
param,
value,
append = FALSE,
plant_id = 1,
variety = NULL,
value_id = NULL,
stics_version = "latest"
)
set_usm_txt(file = "new_travail.usm", param, value, append = FALSE)
set_station_txt(file = "station.txt", param, value, append = FALSE)
set_ini_txt(
file = "ficini.txt",
param,
value,
append = FALSE,
plant_id = 1,
value_id = NULL,
stics_version = "latest"
)
set_general_txt(file = "tempopar.sti", param, value, append = FALSE)
set_tmp_txt(file = "tempoparv6.sti", param, value, append = FALSE)
set_plant_txt(
file = "ficplt1.txt",
param,
value,
append = FALSE,
variety = NULL
)
set_tec_txt(
file = "fictec1.txt",
param,
value,
append = FALSE,
value_id = NULL
)
set_soil_txt(
file = "param.sol",
param,
value,
value_id = NULL,
stics_version = "latest"
)
Arguments
workspace |
Path of the workspace containing the STICS (txt) input files. |
param |
Vector of parameter names. |
value |
New parameter value |
append |
Boolean. Append input to existing file |
plant_id |
The plant identifier (main crop: 1 ; associated crop: 2). Only used for plant, technical or initialization parameters (default = 1). |
variety |
The plant variety to set the parameter value,
either the variety name ( |
value_id |
The soil layers id or technical interventions id |
stics_version |
An optional version name as listed in get_stics_versions_compat() return |
file |
Path (including name) of the file to modify |
Details
The plant parameter can be either equal to 1,
2 for the associated plant in the case of intercrop, or
c(1,2) for both Principal and associated plants.
get_var_info is a helper function that returns
all possible output variables.
If the variety is not given and if param
is a varietal parameter, the function will modify the value of
param for the simulated variety, as given
in the technical file.
Value
None
Note
gen_varmod is not used by set_param_txt.
To replace the output variables required from STICS,
please directly call gen_varmod.
Examples
# Getting example data path
path <- get_examples_path(file_type = "txt")
# Change the value of durvieF for the current variety:
set_param_txt(workspace = path, param = "durvieF", value = 245)
# Change the value of durvieF for another variety:
set_param_txt(
workspace = path, param = "durvieF",
variety = "Nefer", value = 178
)
# Change the value of soil parameter "cailloux" for all layers
# or a specific one
set_param_txt(workspace = path, param = "cailloux", value = 1)
set_param_txt(workspace = path, param = "cailloux", value_id = 2, value = 2)
# Change the value of parameter "amount" for all water supply interventions
# or a specific one
set_param_txt(workspace = path, param = "amount", value = 50)
set_param_txt(workspace = path, param = "amount", value_id = 2, value = 40)
Setting parameter values into xml files
Description
Setting parameter values for a parameter or a vector of and with a parameters values vector
Usage
set_param_xml(
file,
param,
values,
save_as = NULL,
select = NULL,
select_value = NULL,
value_id = NULL,
overwrite = FALSE,
...
)
Arguments
file |
Path (including name) of the xml file to modify |
param |
Vector of parameter names. |
values |
A vector or a list of parameter(s) values (see details). |
save_as |
Path (including name) of the xml file to generate.
Optional, if NULL |
select |
node name or attribute name to use for selection (optional, default to no selection) |
select_value |
Vector of values used for select (see examples). Optional, should be provided only if select is provided. |
value_id |
Vector of ids of the parameters values to be retrieved from the parameter values vector |
overwrite |
Logical TRUE for overwriting the output file, FALSE otherwise (default) |
... |
Pass further arguments to |
Details
It is possible to give several values for a parameter by passing a vector of values. For example, for two parameters with two values each: value= list(c(1,2), c(2.3,4.5))
Value
A logical value TRUE for operation success, FALSE otherwise
Examples
ex_path <- get_examples_path(file_type = "xml")
# Soil file
sol_path <- file.path(ex_path, "sols.xml")
# For scalar parameters per soil
# Setting all soils "argi" values to 50
set_param_xml(sol_path, "argi", 50, overwrite = TRUE)
# Getting changed values
# get_param_xml(sol_path, "argi")
# Setting a specific value to "argi" for "solcanne" soil
set_param_xml(
file = sol_path, param = "argi", values = 56,
select = "sol", select_value = "solcanne", overwrite = TRUE
)
# Getting changed values
# get_param_xml(sol_path, "argi",
# select = "sol", select_value = "solcanne"
# )
# Setting a specific values to 2 parameters "argi" and
# "norg" for "solcanne" soil
set_param_xml(sol_path, c("argi", "norg"), list(100, 150),
select = "sol", select_value = "solcanne", overwrite = TRUE
)
# Getting changed values
# get_param_xml(sol_path, c("argi", "norg"),
# select = "sol", select_value = "solcanne"
# )
# For vector parameters per soil (5 values, one per soil layer)
set_param_xml(sol_path, c("epc", "HCCF"),
select = "sol",
select_value = c("solcanne", "solbanane"),
values = list(c(20:24, 10:14), c(50:54, 40:44)),
overwrite = TRUE
)
# Getting changed values
# get_param_xml(sol_path, c("epc", "HCCF"),
# select = "sol",
# select_value = c("solcanne", "solbanane")
# )
# For specific values of vector parameters
set_param_xml(sol_path, "HCCF",
select = "sol",
select_value = "solcanne",
values = c(46.8, 48.5, 50.1),
value_id = c(1, 3, 5),
overwrite = TRUE
)
# Getting changed values
# get_param_xml(sol_path, "HCCF",
# select = "sol",
# select_value = "solcanne",
# value_id = c(1,3,5)
# )
# Crop management file
tec_path <- file.path(ex_path, "file_tec.xml")
# Modifying irrigations parameters
set_param_xml(tec_path, c("julapI_or_sum_upvt", "amount"),
values = list(200:215, 20:35), overwrite = TRUE
)
# Getting changed values
# get_param_xml(tec_path, c("julapI_or_sum_upvt", "amount"))
Upgrade _ini.xml file(s) to a next major version
Description
Upgrade _ini.xml file(s) to a next major version
Usage
upgrade_ini_xml(file, out_dir, param_gen_file, overwrite = FALSE)
Arguments
file |
xml plant file path or a vector of |
out_dir |
Output directory path |
param_gen_file |
Path of the param_gen.xml file corresponding to the initial version |
overwrite |
Logical TRUE for overwriting files, FALSE otherwise (default) |
Value
None
Examples
dir_path <- get_examples_path(file_type = "xml", stics_version = "V10.0")
upgrade_ini_xml(
file = file.path(dir_path, "file_ini.xml"),
out_dir = tempdir(),
param_gen_file = file.path(dir_path, "param_gen.xml")
)
Upgrade _ini.xml file(s) from STICS version 10 to 11
Description
Upgrade _ini.xml file(s) from STICS version 10 to 11
Usage
upgrade_ini_xml_10_11(file, out_dir, overwrite = FALSE)
Arguments
file |
xml plant file path or a vector of |
out_dir |
Output directory path |
overwrite |
Logical TRUE for overwriting files, FALSE otherwise (default) |
Value
None
Examples
## Not run:
dir_path <- get_examples_path(file_type = "xml", stics_version = "V10.0")
upgrade_ini_xml_10_11(
file = file.path(dir_path, "file_ini.xml"),
out_dir = tempdir()
)
## End(Not run)
Upgrade _ini.xml file(s) from STICS version 9 to 10
Description
Upgrade _ini.xml file(s) from STICS version 9 to 10
Usage
upgrade_ini_xml_9_10(file, out_dir, param_gen_file, overwrite = FALSE)
Arguments
file |
Path of an initialization (*_ini.xml) file or a vector of |
out_dir |
Output directory path of the generated files |
param_gen_file |
Path of the param_gen.xml file corresponding to the file version |
overwrite |
logical (optional), TRUE for overwriting file if it exists, FALSE otherwise |
Details
See SticsRFiles::get_stics_versions_compat() for listing versions
Value
None
Examples
## Not run:
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2")
upgrade_ini_xml_9_10(
file = file.path(dir_path, "file_ini.xml"),
out_dir = tempdir(),
param_gen_file = file.path(dir_path, "param_gen.xml")
)
## End(Not run)
Upgrade a param_gen.xml file to a next major version
Description
Upgrade a param_gen.xml file to a next major version
Usage
upgrade_param_gen_xml(file, out_dir, ..., overwrite = FALSE)
Arguments
file |
xml param_gen file path or a vector of |
out_dir |
Output directory path |
... |
additional argument(s) to pass to called functions |
overwrite |
Logical TRUE for overwriting files, FALSE otherwise (default) |
Value
None
Examples
dir_path <- get_examples_path(file_type = "xml", stics_version = "V10.0")
upgrade_param_gen_xml(
file = file.path(dir_path, "param_gen.xml"),
out_dir = tempdir()
)
Upgrade a param_gen.xml file from STICS version 10 to 11
Description
Upgrade a param_gen.xml file from STICS version 10 to 11
Usage
upgrade_param_gen_xml_10_11(file, out_dir, ..., overwrite = FALSE)
Arguments
file |
xml param_gen file path or a vector of |
out_dir |
Output directory path |
... |
additional argument(s) to pass |
overwrite |
Logical TRUE for overwriting files, FALSE otherwise (default) |
Value
None
Examples
## Not run:
dir_path <- get_examples_path(file_type = "xml", stics_version = "V10.0")
upgrade_param_gen_xml_10_11(
file = file.path(dir_path, "param_gen.xml"),
out_dir = tempdir()
)
## End(Not run)
Upgrade a param_gen.xml file from STICS version 9 to 10
Description
Upgrade a param_gen.xml file from STICS version 9 to 10
Usage
upgrade_param_gen_xml_9_10(file, out_dir, overwrite = FALSE)
Arguments
file |
Path of a param_gen.xml file |
out_dir |
Output directory path of the generated file |
overwrite |
logical (optional), TRUE for overwriting file if it exists, FALSE otherwise |
Details
See get_stics_versions_compat() for listing versions
Value
None
Examples
## Not run:
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2")
upgrade_param_gen_xml_9_10(
file = file.path(dir_path, "param_gen.xml"),
out_dir = tempdir()
)
## End(Not run)
Upgrade a param_newform.xml file to a next major version
Description
Upgrade a param_newform.xml file to a next major version
Usage
upgrade_param_newform_xml(
file,
out_dir,
param_gen_file,
...,
overwrite = FALSE
)
Arguments
file |
xml param_newform file path or a vector of |
out_dir |
Output directory path |
param_gen_file |
Path of the param_gen.xml file corresponding to the file version |
... |
additional argument(s) to pass to called functions |
overwrite |
Logical TRUE for overwriting files, FALSE otherwise (default) |
Value
None
Examples
dir_path <- get_examples_path(file_type = "xml", stics_version = "V10.0")
upgrade_param_newform_xml(
file = file.path(dir_path, "param_newform.xml"),
out_dir = tempdir(),
param_gen_file = file.path(dir_path, "param_gen.xml")
)
Upgrade a param_newform.xml file from STICS version 10 to 11
Description
Upgrade a param_newform.xml file from STICS version 10 to 11
Usage
upgrade_param_newform_xml_10_11(file, out_dir, ..., overwrite = FALSE)
Arguments
file |
xml param_newform file path or a vector of |
out_dir |
Output directory path |
... |
additional argument(s) to pass |
overwrite |
Logical TRUE for overwriting files, FALSE otherwise (default) |
Value
None
Examples
## Not run:
dir_path <- get_examples_path(file_type = "xml", stics_version = "V10.0")
upgrade_param_newform_xml_10_11(
file = file.path(dir_path, "param_newform.xml"),
out_dir = tempdir()
)
## End(Not run)
Upgrade a param_newform.xml file from STICS version 9 to 10
Description
Upgrade a param_newform.xml file from STICS version 9 to 10
Usage
upgrade_param_newform_xml_9_10(
file,
out_dir,
param_gen_file,
overwrite = FALSE
)
Arguments
file |
Path of a param_newform.xml file |
out_dir |
Output directory path of the generated file |
param_gen_file |
Path of the param_gen.xml file corresponding to the file version |
overwrite |
logical (optional), TRUE for overwriting file if it exists, FALSE otherwise |
Details
See SticsRFiles::get_stics_versions_compat() for listing versions
Value
None
Examples
## Not run:
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2")
upgrade_param_newform_xml_9_10(
file = file.path(dir_path, "param_newform.xml"),
out_dir = tempdir(),
param_gen_file = file.path(dir_path, "param_gen.xml")
)
## End(Not run)
Upgrade _plt.xml file(s) to a next major version
Description
Upgrade _plt.xml file(s) to a next major version
Usage
upgrade_plt_xml(
file,
out_dir,
param_gen_file,
param_newform_file,
...,
overwrite = FALSE,
warning = TRUE
)
Arguments
file |
xml plant file path or a vector of |
out_dir |
Output directory path |
param_gen_file |
Path of the param_gen.xml file corresponding to the initial version |
param_newform_file |
Path of the param_newform.xml file corresponding to the file version |
... |
additional argument(s) to pass to called functions |
overwrite |
Logical TRUE for overwriting files, FALSE otherwise (default) |
warning |
Logical for rising warnings, FALSE otherwise |
Value
None
Examples
dir_path <- get_examples_path(file_type = "xml", stics_version = "V10.0")
upgrade_plt_xml(
file = file.path(dir_path, "file_plt.xml"),
out_dir = tempdir(),
param_gen_file = file.path(dir_path, "param_gen.xml"),
param_newform_file = file.path(dir_path, "param_newform.xml")
)
Upgrade _plt.xml file(s) from version 10 to 11
Description
Upgrade _plt.xml file(s) from version 10 to 11
Usage
upgrade_plt_xml_10_11(file, out_dir, ..., overwrite = FALSE, warning = TRUE)
Arguments
file |
xml plant file path or a vector of |
out_dir |
Output directory path |
... |
additional argument(s) to pass |
overwrite |
Logical TRUE for overwriting files, FALSE otherwise (default) |
warning |
Logical for rising warnings, FALSE otherwise |
Value
None
Examples
## Not run:
dir_path <- get_examples_path(file_type = "xml", stics_version = "V10.0")
upgrade_plt_xml_10_11(
file = file.path(dir_path, "file_plt.xml"),
out_dir = tempdir()
)
## End(Not run)
Upgrade _plt.xml file(s) from STICS version 9 to 10
Description
Upgrade _plt.xml file(s) from STICS version 9 to 10
Usage
upgrade_plt_xml_9_10(
file,
out_dir,
param_gen_file,
param_newform_file,
overwrite = FALSE
)
Arguments
file |
Path of an plant (*_plt.xml) file or a vector of |
out_dir |
Output directory path of the generated files |
param_gen_file |
Path of the param_gen.xml file corresponding to the file version |
param_newform_file |
Path of the param_newform.xml file corresponding to the file version |
overwrite |
logical (optional), TRUE for overwriting file if it exists, FALSE otherwise |
Details
See get_stics_versions_compat() for listing versions
Value
None
Examples
## Not run:
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2")
upgrade_plt_xml_9_10(
file = file.path(dir_path, "file_plt.xml"),
out_dir = tempdir(),
param_gen_file = file.path(dir_path, "param_gen.xml"),
param_newform_file = file.path(dir_path, "param_newform.xml")
)
## End(Not run)
Upgrade a sols.xml file to a next major version
Description
Upgrade a sols.xml file to a next major version
Usage
upgrade_sols_xml(file, out_dir, param_gen_file, overwrite = FALSE)
Arguments
file |
xml sols file path |
out_dir |
Output directory path |
param_gen_file |
Path of the param_gen.xml file corresponding to the file version |
overwrite |
Logical TRUE for overwriting files, FALSE otherwise (default) |
Value
None
Examples
dir_path <- get_examples_path(file_type = "xml", stics_version = "V10.0")
upgrade_sols_xml(
file = file.path(dir_path, "sols.xml"),
out_dir = tempdir(),
param_gen_file = file.path(dir_path, "param_gen.xml")
)
Upgrade a sols.xml file from STICS version 10 to 11
Description
Upgrade a sols.xml file from STICS version 10 to 11
Usage
upgrade_sols_xml_10_11(file, out_dir, overwrite = FALSE)
Arguments
file |
xml sols file path |
out_dir |
Output directory path |
overwrite |
Logical TRUE for overwriting files, FALSE otherwise (default) |
Value
None
Examples
## Not run:
dir_path <- get_examples_path(file_type = "xml", stics_version = "V10.0")
upgrade_sols_xml_10_11(
file = file.path(dir_path, "sols.xml"),
out_dir = tempdir()
)
## End(Not run)
Upgrade a sols.xml file from STICS version 9 to 10
Description
Upgrade a sols.xml file from STICS version 9 to 10
Usage
upgrade_sols_xml_9_10(file, out_dir, param_gen_file, overwrite = FALSE)
Arguments
file |
Path of a sols.xml file |
out_dir |
Output directory path of the generated file |
param_gen_file |
Path of the param_gen.xml file corresponding to the file version |
overwrite |
logical (optional), TRUE for overwriting file if it exists, FALSE otherwise |
Details
See SticsRFiles::get_stics_versions_compat() for listing versions
Value
None
Examples
## Not run:
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2")
upgrade_sols_xml_9_10(
file = file.path(dir_path, "sols.xml"),
out_dir = tempdir(),
param_gen_file = file.path(dir_path, "param_gen.xml")
)
## End(Not run)
Upgrade _sta.xml file(s) to a next major version
Description
Upgrade _sta.xml file(s) to a next major version
Usage
upgrade_sta_xml(file, out_dir, param_gen_file, overwrite = FALSE)
Arguments
file |
xml plant file path or a vector of |
out_dir |
Output directory path |
param_gen_file |
Path of the param_gen.xml file corresponding to the initial version |
overwrite |
Logical TRUE for overwriting files, FALSE otherwise (default) |
Value
None
Examples
dir_path <- get_examples_path(file_type = "xml", stics_version = "V10.0")
upgrade_sta_xml(
file = file.path(dir_path, "file_sta.xml"),
out_dir = tempdir(),
param_gen_file = file.path(dir_path, "param_gen.xml")
)
Upgrade _sta.xml file(s) from STICS version 10 to 11
Description
Upgrade _sta.xml file(s) from STICS version 10 to 11
Usage
upgrade_sta_xml_10_11(file, out_dir, overwrite = FALSE)
Arguments
file |
xml plant file path or a vector of |
out_dir |
Output directory path |
overwrite |
Logical TRUE for overwriting files, FALSE otherwise (default) |
Value
None
Examples
## Not run:
dir_path <- get_examples_path(file_type = "xml", stics_version = "V10.0")
upgrade_sta_xml_10_11(
file = file.path(dir_path, "file_sta.xml"),
out_dir = tempdir()
)
## End(Not run)
Upgrade _sta.xml file(s) from STICS version 9 to 10
Description
Upgrade _sta.xml file(s) from STICS version 9 to 10
Usage
upgrade_sta_xml_9_10(file, out_dir, param_gen_file, overwrite = FALSE)
Arguments
file |
Path of a station (*_sta.xml) file or a vector of |
out_dir |
Output directory path of the generated files |
param_gen_file |
Path of the param_gen.xml file corresponding to the file version |
overwrite |
logical (optional), TRUE for overwriting file if it exists, FALSE otherwise |
Details
See SticsRFiles::get_stics_versions_compat() for listing versions
Value
None
Examples
## Not run:
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2")
upgrade_sta_xml_9_10(
file = file.path(dir_path, "file_sta.xml"),
out_dir = tempdir(),
param_gen_file = file.path(dir_path, "param_gen.xml")
)
## End(Not run)
Upgrade _tec.xml file(s) to a next major version
Description
Upgrade _tec.xml file(s) to a next major version
Usage
upgrade_tec_xml(
file,
out_dir,
param_gen_file,
param_newform_file,
...,
overwrite = FALSE
)
Arguments
file |
xml technical file path or a vector of |
out_dir |
Output directory path |
param_gen_file |
Path of the param_gen.xml file corresponding to the initial version |
param_newform_file |
Path of the param_newform.xml file corresponding to the file version |
... |
additional argument(s) to pass to called functions |
overwrite |
Logical TRUE for overwriting files, FALSE otherwise (default) |
Value
None
Examples
dir_path <- get_examples_path(file_type = "xml", stics_version = "V10.0")
upgrade_tec_xml(
file = file.path(dir_path, "file_tec.xml"),
out_dir = tempdir(),
param_gen_file = file.path(dir_path, "param_gen.xml"),
param_newform_file = file.path(dir_path, "param_newform.xml")
)
Upgrade _tec.xml file(s) from version 10 to 11
Description
Upgrade _tec.xml file(s) from version 10 to 11
Usage
upgrade_tec_xml_10_11(file, out_dir, ..., overwrite = FALSE)
Arguments
file |
xml technical file path or a vector of |
out_dir |
Output directory path |
... |
additional argument(s) to pass |
overwrite |
Logical TRUE for overwriting files, FALSE otherwise (default) |
Value
None
Examples
## Not run:
dir_path <- get_examples_path(file_type = "xml", stics_version = "V10.0")
upgrade_tec_xml_10_11(
file = file.path(dir_path, "file_tec.xml"),
out_dir = tempdir()
)
## End(Not run)
Upgrade _tec.xml file(s) from STICS version 9 to 10
Description
Upgrade _tec.xml file(s) from STICS version 9 to 10
Usage
upgrade_tec_xml_9_10(
file,
out_dir,
param_gen_file,
param_newform_file,
overwrite = FALSE
)
Arguments
file |
Path of a crop management (*_tec.xml) file or a vector of |
out_dir |
Output directory path of the generated files |
param_gen_file |
Path of the param_gen.xml file corresponding to the file version |
param_newform_file |
Path of the param_newform.xml file corresponding to the file version |
overwrite |
logical (optional), TRUE for overwriting file if it exists, FALSE otherwise |
Details
See get_stics_versions_compat() for listing versions
Value
None
Examples
## Not run:
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2")
upgrade_tec_xml_9_10(
file = file.path(dir_path, "file_tec.xml"),
out_dir = tempdir(),
param_gen_file = file.path(dir_path, "param_gen.xml"),
param_newform_file = file.path(dir_path, "param_newform.xml")
)
## End(Not run)
Upgrade a usms.xml file to a next major version
Description
Upgrade a usms.xml file to a next major version
Usage
upgrade_usms_xml(file, out_dir, param_gen_file, overwrite = FALSE)
Arguments
file |
xml usms file path |
out_dir |
Output directory path |
param_gen_file |
Path of the param_gen.xml file corresponding to the file version |
overwrite |
Logical TRUE for overwriting files, FALSE otherwise (default) |
Value
None
Examples
dir_path <- get_examples_path(file_type = "xml", stics_version = "V10.0")
upgrade_usms_xml(
file = file.path(dir_path, "usms.xml"),
out_dir = tempdir(),
param_gen_file = file.path(dir_path, "param_gen.xml")
)
Upgrade a usms.xml file from STICS version 10 to 11
Description
Upgrade a usms.xml file from STICS version 10 to 11
Usage
upgrade_usms_xml_10_11(file, out_dir, overwrite = FALSE)
Arguments
file |
xml usms file path |
out_dir |
Output directory path |
overwrite |
Logical TRUE for overwriting files, FALSE otherwise (default) |
Value
None
Examples
## Not run:
dir_path <- get_examples_path(file_type = "xml", stics_version = "V10.0")
upgrade_usms_xml_10_11(
file = file.path(dir_path, "usms.xml"),
out_dir = tempdir()
)
## End(Not run)
Upgrade a usms.xml file from STICS version 9 to 10
Description
Upgrade a usms.xml file from STICS version 9 to 10
Usage
upgrade_usms_xml_9_10(file, out_dir, param_gen_file, overwrite = FALSE)
Arguments
file |
Path of a usms.xml file |
out_dir |
Output directory path of the generated file |
param_gen_file |
Path of the param_gen.xml file corresponding to the file version |
overwrite |
logical (optional), TRUE for overwriting file if it exists, FALSE otherwise |
Details
See get_stics_versions_compat() for listing versions
Value
None
Examples
## Not run:
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2")
upgrade_usms_xml_9_10(
file = file.path(dir_path, "usms.xml"),
out_dir = tempdir(),
param_gen_file = file.path(dir_path, "param_gen.xml")
)
## End(Not run)
Upgrade a Javastics STICS xml workspace directory to a next major version
Description
Upgrade a Javastics STICS xml workspace directory to a next major version
Usage
upgrade_workspace_xml(
workspace,
out_dir,
...,
javastics = NULL,
overwrite = FALSE,
verbose = FALSE
)
Arguments
workspace |
JavaStics xml workspace path |
out_dir |
Output directory path |
... |
additional argument(s) to pass to called functions |
javastics |
Path of JavaSTICS containing the STICS version corresponding to the version of the files to be converted (optional) |
overwrite |
Logical TRUE for overwriting files, FALSE otherwise (default) |
verbose |
logical, TRUE for displaying a copy message FALSE otherwise (default) |
Value
None
Examples
## Not run:
upgrade_workspace_xml(
workspace = "/path/to/JavaSTICS/workspace",
out_dir = "/path/to/an/output/directory",
javastics = "/path/to/JavaSTICS/folder"
)
## End(Not run)