| Title: | Read and Modify 'STICS' Input/Output Files |
|---|---|
| Description: | Manipulating input and output files of the 'STICS' crop model. 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. |
| Authors: | Patrice Lecharpentier [aut, cre] (ORCID: <https://orcid.org/0000-0002-4044-4322>), Remi Vezy [aut] (ORCID: <https://orcid.org/0000-0002-0808-1461>), Samuel Buis [aut] (ORCID: <https://orcid.org/0000-0002-8676-5447>), Michel Giner [aut] (ORCID: <https://orcid.org/0000-0002-9310-2377>), Timothee Flutre [aut] (ORCID: <https://orcid.org/0000-0003-4489-4782>), Thomas Robine [ctb], Amine Barkaoui [ctb], Patrick Chabrier [ctb], Julie Constantin [rev], Dominique Ripoche [rev], Marie Launay [rev], Alain Mollier [rev], Christine Le Bas [rev], Joel Leonard [rev] |
| Maintainer: | Patrice Lecharpentier <[email protected]> |
| License: | LGPL (>= 3) |
| Version: | 1.6.0 |
| Built: | 2026-05-22 07:45:31 UTC |
| Source: | https://github.com/SticsRPacks/SticsRFiles |
[ method for cropr_simulation
This method ensure keeping the cropr_simulation attribute when subsetting a
cropr_simulation list.
## S3 method for class 'cropr_simulation' x[...]## S3 method for class 'cropr_simulation' x[...]
x |
A |
... |
An index |
A subset of a cropr_simulation, keeping its attribute
path <- file.path(get_examples_path("sti"), "workspace1") sim <- SticsRFiles::get_sim(workspace = path) # sim returns a `cropr_simulation` listpath <- file.path(get_examples_path("sti"), "workspace1") sim <- SticsRFiles::get_sim(workspace = path) # sim returns a `cropr_simulation` list
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).
approx_vapour_pressure(mean_temp, rel_humid)approx_vapour_pressure(mean_temp, rel_humid)
mean_temp |
numeric vector of daily mean air temperature (in Celsius degrees) |
rel_humid |
numeric vector of relative humidity (in percentage) |
numeric vector
Timothee Flutre
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.
compute_date_from_day(day, start_year)compute_date_from_day(day, start_year)
day |
day number(s) to be converted |
start_year |
year to be used as time reference (simulation start year). |
Date vector
Timothee Flutre
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)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)
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.
compute_day_from_date(date, start_year = NULL)compute_day_from_date(date, start_year = NULL)
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. |
numeric vector
Timothee Flutre
date <- as.Date("2015-02-10") compute_day_from_date(date = date) compute_day_from_date(date = "2015-02-10", start_year = 2014) date <- as.Date("2009-02-10") compute_day_from_date(date = date, start_year = 2008) dates <- c(as.Date("2008-02-10"), as.Date("2009-02-10")) compute_day_from_date(date = dates, start_year = 2008)date <- as.Date("2015-02-10") compute_day_from_date(date = date) compute_day_from_date(date = "2015-02-10", start_year = 2014) date <- as.Date("2009-02-10") compute_day_from_date(date = date, start_year = 2008) dates <- c(as.Date("2008-02-10"), as.Date("2009-02-10")) compute_day_from_date(date = dates, start_year = 2008)
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,...)
convert_xml2txt( file, plant_id = 1, soil_name = NULL, out_dir = NULL, save_as = NULL, stics_version = "latest" )convert_xml2txt( file, plant_id = 1, soil_name = NULL, out_dir = NULL, save_as = NULL, stics_version = "latest" )
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). |
None
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")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 locally the example data from the data repository in the SticsRPacks organization.
download_data( branch = NULL, out_dir = tempdir(), example_dirs = NULL, stics_version = "latest", raise_error = FALSE )download_data( branch = NULL, out_dir = tempdir(), example_dirs = NULL, stics_version = "latest", raise_error = FALSE )
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) |
The path of the folder data have been downloaded into or NULL if the download fails and raise_error is FALSE.
# 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 )# 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 )
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
download_usm_csv( file = NULL, out_dir = tempdir(), stics_version = "latest", overwrite = FALSE, verbose = FALSE )download_usm_csv( file = NULL, out_dir = tempdir(), stics_version = "latest", overwrite = FALSE, verbose = FALSE )
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 |
A vector of copied files path.
download_usm_csv()download_usm_csv()
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
download_usm_xl( file = NULL, out_dir = tempdir(), stics_version = "latest", overwrite = FALSE, verbose = FALSE, ... )download_usm_xl( file = NULL, out_dir = tempdir(), stics_version = "latest", overwrite = FALSE, verbose = FALSE, ... )
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 |
A vector of copied files path.
download_usm_xl()download_usm_xl()
Extract an XML JavaSTICS workspace from a source workspace
extract_workspace( from_workspace, to_workspace, javastics, usm = NULL, use_mod_files = FALSE )extract_workspace( from_workspace, to_workspace, javastics, usm = NULL, use_mod_files = FALSE )
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. |
None
## 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)## 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 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())
force_param_values(workspace, values, javastics)force_param_values(workspace, values, javastics)
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 |
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).
A logical status TRUE if successful, FALSE otherwise
SticsOnR::run_stics()
## 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)## 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
gen_general_param_xml(out_dir, stics_version = "latest", overwrite = FALSE)gen_general_param_xml(out_dir, stics_version = "latest", overwrite = FALSE)
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) |
Please see get_stics_versions_compat() for the full list of
STICS versions that can be used for the argument stics_version.
None
gen_general_param_xml(out_dir = tempdir()) gen_general_param_xml( out_dir = tempdir(), stics_version = "V10.0", overwrite = TRUE )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
gen_ini_xml( param_df, file = NULL, out_dir, crop_tag = "Crop", stics_version = "latest" )gen_ini_xml( param_df, file = NULL, out_dir, crop_tag = "Crop", stics_version = "latest" )
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 |
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.
None
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, ] )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
gen_obs(df, out_dir, usms_list = NULL)gen_obs(df, out_dir, usms_list = NULL)
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 |
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_name column contains usms names which are used as output .obs
files names
ian, mo, jo and jul are 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.
A return logical status indicating if any error when writing files (FALSE), TRUE when no errors.
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")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
gen_sols_xml(file, param_df, template = NULL, stics_version = "latest")gen_sols_xml(file, param_df, template = NULL, stics_version = "latest")
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 |
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.
None
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 )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
gen_sta_xml(param_df, file = NULL, out_dir, stics_version = "latest")gen_sta_xml(param_df, file = NULL, out_dir, stics_version = "latest")
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 |
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.
None
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)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
gen_tec_xml( param_df, file = NULL, out_dir, stics_version = "latest", na_values = NA )gen_tec_xml( param_df, file = NULL, out_dir, stics_version = "latest", na_values = NA )
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) |
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.
None
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, ])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
gen_usms_xml(file, param_df, template = NULL, stics_version = "latest")gen_usms_xml(file, param_df, template = NULL, stics_version = "latest")
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 |
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.
an invisible xml_document object
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 )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 )
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.
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 )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 )
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. |
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
## 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)## 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 daily variable list file from variables names
gen_varmod( workspace, var, append = FALSE, file_name = "var.mod", stics_version = "latest", force = FALSE )gen_varmod( workspace, var, append = FALSE, file_name = "var.mod", stics_version = "latest", force = FALSE )
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). |
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().
None
gen_varmod(tempdir(), c("lai(n)", "hauteur")) # Add a variable to the others: gen_varmod(tempdir(), "masec(n)", append = TRUE) # NB: var.mod will have "lai(n)","hauteur" and "masec(n)"gen_varmod(tempdir(), c("lai(n)", "hauteur")) # Add a variable to the others: gen_varmod(tempdir(), "masec(n)", append = TRUE) # NB: var.mod will have "lai(n)","hauteur" and "masec(n)"
Read the meteorology input for STICS ("climat.txt")
get_climate_txt(workspace, file_name = "climat.txt", preserve = TRUE)get_climate_txt(workspace, file_name = "climat.txt", preserve = TRUE)
workspace |
Path of the workspace containing the STICS climate file to read |
file_name |
The meteorology file name (default to |
preserve |
Logical, |
A data.frame of the input meteorological variables used as input for the STICS model.
The time-related variables are summarized into one POSIXct column named
date.
path <- get_examples_path(file_type = "txt") meteo_data <- get_climate_txt(path)path <- get_examples_path(file_type = "txt") meteo_data <- get_climate_txt(path)
Extracts the cultivar names from a plant file
get_cultivars_list(file)get_cultivars_list(file)
file |
The path of a plant file. |
A vector of cultivar names
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"))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"))
Extracts the values of cultivar-specific parameters from a plant file
get_cultivars_param(file)get_cultivars_param(file)
file |
The path of a plant file. |
A data.frame with one row per cultivar and one column per parameter
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"))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"))
Extracts the values of developmental stages from simulations
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 )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 )
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. |
List of data.frame, one per USM, with one row per developmental stage.
Timothee Flutre
Getting examples files path attached to a STICS version for a given file type
get_examples_path(file_type, stics_version = "latest", overwrite = FALSE)get_examples_path(file_type, stics_version = "latest", overwrite = FALSE)
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 |
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)
get_examples_path(file_type = "csv") get_examples_path(file_type = c("csv", "sti")) get_examples_path(file_type = "csv", stics_version = "V8.5")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
get_files_list( workspace, usm = NULL, usms_file = "usms.xml", file_type = NULL, only_existing = TRUE, javastics = NULL, use_mod_files = FALSE )get_files_list( workspace, usm = NULL, usms_file = "usms.xml", file_type = NULL, only_existing = TRUE, javastics = NULL, use_mod_files = FALSE )
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) |
The possible values for file_type are: "fplt", "finit", "fclim1", "fclim2", "fstation", "ftec", "sols", "pargen", "parnew", "usms", "mod"
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 get_soils_list() to get all soils in a usm file,
and get_usms_list() to get the list of usms.
## 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)## 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)
Is LAI forced for usms in usms.xml
get_lai_forcing(usm_file_path, usms_list = c())get_lai_forcing(usm_file_path, usms_list = c())
usm_file_path |
Path to usms.xml file |
usms_list |
Usm(s) name(s) (optional, see details) |
Use get_usms_list() to get the list of the usm names for an
usms.xml file.
A named numeric vector with a Boolean value (TRUE = forced)
for each usm
# 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"))# 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 from a JavaSTICS workspace and store data into a list per usm
get_obs( workspace, usm = NULL, var = NULL, dates = NULL, usms_file = NULL, javastics = NULL, verbose = TRUE, parallel = FALSE, cores = NA )get_obs( workspace, usm = NULL, var = NULL, dates = NULL, usms_file = NULL, javastics = NULL, verbose = TRUE, parallel = FALSE, cores = NA )
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. |
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).
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.
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)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)
Helper function that returns names and descriptions of STICS input parameters from a partial name and/or descriptive keywords.
get_param_info(param = NULL, keyword = NULL, stics_version = "latest")get_param_info(param = NULL, keyword = NULL, stics_version = "latest")
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 |
The function understand regex as input.
A data.frame with information about parameter(s) with columns
name, file, min, max, definition, unit and cultivar
# 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")# 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")
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.
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)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)
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. |
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.
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 |
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.
gen_varmod(),
get_param_txt().
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 <- ifelse(tmp$option_engrais_multiple == 1, TRUE, FALSE) several_thin <- ifelse(tmp$option_thinning == 1, TRUE, FALSE) is_pasture <- ifelse(tmp$option_pature == 1, TRUE, FALSE) # 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)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 <- ifelse(tmp$option_engrais_multiple == 1, TRUE, FALSE) several_thin <- ifelse(tmp$option_thinning == 1, TRUE, FALSE) is_pasture <- ifelse(tmp$option_pature == 1, TRUE, FALSE) # 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)
Extracting parameter values for a list of xml files and parameters
get_param_xml( file, param = NULL, select = NULL, select_value = NULL, value_id = NULL, ... )get_param_xml( file, param = NULL, select = NULL, select_value = NULL, value_id = NULL, ... )
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 |
A list of parameter values for each file (a list of list)
# 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"))# 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"))
Extracting plant number from usms.xml or new_travail.usm file data
get_plants_nb(usms_file, usms_list = c())get_plants_nb(usms_file, usms_list = c())
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) |
Use get_usms_list() to get the list of the usm names for
an usms.xml file.
A named numeric vector of plants number per usm
# 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)# 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
get_report_results( workspace, file_name = "mod_rapport.sti", usm = NULL, var_list = NULL )get_report_results( workspace, file_name = "mod_rapport.sti", usm = NULL, var_list = NULL )
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 |
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.
A data.frame
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")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")
Reads and format daily output file(s) (mod_s*.sti) for usm(s) with possible selection on variable names, cumulative DOY and dates
get_sim( workspace, usm = NULL, var = NULL, dates = NULL, usms_file = NULL, javastics = NULL, verbose = TRUE, parallel = FALSE, cores = NA )get_sim( workspace, usm = NULL, var = NULL, dates = NULL, usms_file = NULL, javastics = NULL, verbose = TRUE, parallel = FALSE, cores = NA )
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. |
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).
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.
path <- get_examples_path(file_type = "sti") sim_data <- get_sim(path, "banana")path <- get_examples_path(file_type = "sti") sim_data <- get_sim(path, "banana")
Extracts the soil names from a USMs file, or from a soil file
get_soils_list(file, soil = NULL)get_soils_list(file, soil = NULL)
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. |
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.
A vector of soil names
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") )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 versions of STICS that are fully compatible with this package.
get_stics_versions_compat(version_index = NULL)get_stics_versions_compat(version_index = NULL)
version_index |
Absolute positive index, or negative relative index from latest version |
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.
# 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 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)
Extracting a usm names list from an usms.xml file
get_usms_list(file, usm = NULL)get_usms_list(file, usm = NULL)
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. |
A vector of usm names
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") )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") )
Helper function that returns names and descriptions of STICS output variables from a partial name and/or descriptive keywords.
get_var_info(var = NULL, keyword = NULL, stics_version = "latest")get_var_info(var = NULL, keyword = NULL, stics_version = "latest")
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 |
The function understand regex as input.
A data.frame with information about variable(s) with columns
name, definition, unit, type
# 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")# 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 the STICS output variables (from var.mod file)
get_varmod(workspace, file_name = "var.mod")get_varmod(workspace, file_name = "var.mod")
workspace |
Path of the directory containing the STICS var.mod file |
file_name |
file name to read (without path, default value: "var.mod") |
A var.mod file can be created or modified using gen_varmod().
The variables that will be returned by STICS
gen_varmod
get_varmod(get_examples_path(file_type = "txt"))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)
get_xml_files_param_df(file_path, param_names = NULL, wide_shape = FALSE)get_xml_files_param_df(file_path, param_names = NULL, wide_shape = FALSE)
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 |
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)
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, ...)
## 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)## 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)
Evaluating if the OS is a Mac OS type
is_mac()is_mac()
TRUE/FALSE
is_mac()is_mac()
Tells if one or more parameter names are valid STICS input parameters.
is_stics_param(param, stics_version = "latest")is_stics_param(param, stics_version = "latest")
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 |
A boolean vector: TRUE if the parameter exist, FALSE otherwise
get_param_info() for interactive use.
is_stics_param(c("adil", "adilmax", "unknown"))is_stics_param(c("adil", "adilmax", "unknown"))
Tells if one or more variable names are valid STICS output variables.
is_stics_var(var, stics_version = "latest")is_stics_var(var, stics_version = "latest")
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 |
A boolean vector: TRUE if the variable exist, FALSE otherwise
get_var_info() for interactive use.
is_stics_var(c("lai(n)", "masec(n)", "unknown"))is_stics_var(c("lai(n)", "masec(n)", "unknown"))
Evaluating if the OS is a unix like type
is_unix()is_unix()
TRUE/FALSE
is_unix()is_unix()
Evaluating if the OS is a windows type
is_windows()is_windows()
TRUE/FALSE
is_windows()is_windows()
Getting parameters data from tables files (Excel sheet, csv)
read_params_table(file_path, sheet_name = NULL, num_na = "NA", char_na = "NA")read_params_table(file_path, sheet_name = NULL, num_na = "NA", char_na = "NA")
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: "") |
After data are loaded, numerical and string NA values are replaced respectively with num_na or char_na
A tibble of parameters
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)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)
Replace or set an input parameter from an existing STICS input file.
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" )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" )
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 |
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.
None
gen_varmod is not used by set_param_txt.
To replace the output variables required from STICS,
please directly call gen_varmod.
# 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)# 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 for a parameter or a vector of and with a parameters values vector
set_param_xml( file, param, values, save_as = NULL, select = NULL, select_value = NULL, value_id = NULL, overwrite = FALSE, ... )set_param_xml( file, param, values, save_as = NULL, select = NULL, select_value = NULL, value_id = NULL, overwrite = FALSE, ... )
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 |
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))
A logical value TRUE for operation success, FALSE otherwise
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"))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"))
Upgrading _ini.xml file(s) to a newer version
upgrade_ini_xml( file, out_dir, param_gen_file, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE, ... )upgrade_ini_xml( file, out_dir, param_gen_file, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE, ... )
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 |
stics_version |
Name of the STICS version (VX.Y format) |
target_version |
Name of the STICS version to upgrade files to (VX.Y format) |
check_version |
Perform version consistency with in stics_version input with the file version and finally checking if the upgrade is possible allowed to the target_version. If TRUE, param_gen_file is mandatory. |
overwrite |
logical (optional), TRUE for overwriting file if it exists, FALSE otherwise |
... |
Additional input arguments |
See SticsRFiles::get_stics_versions_compat() for listing versions
None
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_ini_xml( file = file.path(dir_path, "file_ini.xml"), out_dir = tempdir(), param_gen_file = file.path(dir_path, "param_gen.xml") )dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_ini_xml( file = file.path(dir_path, "file_ini.xml"), out_dir = tempdir(), param_gen_file = file.path(dir_path, "param_gen.xml") )
Upgrading a param_gen.xml file to a newer version
upgrade_param_gen_xml( file, out_dir, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE )upgrade_param_gen_xml( file, out_dir, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE )
file |
Path of a param_gen.xml file |
out_dir |
Output directory path of the generated file |
stics_version |
Name of the STICS version (VX.Y format) |
target_version |
Name of the STICS version to upgrade files to (VX.Y format) |
check_version |
Perform version consistency with in stics_version input with the file version and finally checking if the upgrade is possible allowed to the target_version |
overwrite |
logical (optional), TRUE for overwriting file if it exists, FALSE otherwise |
See get_stics_versions_compat() for listing versions
None
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_param_gen_xml( file = file.path(dir_path, "param_gen.xml"), out_dir = tempdir() )dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_param_gen_xml( file = file.path(dir_path, "param_gen.xml"), out_dir = tempdir() )
Upgrading a param_newform.xml file to a newer version
upgrade_param_newform_xml( file, out_dir, param_gen_file, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE )upgrade_param_newform_xml( file, out_dir, param_gen_file, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE )
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 |
stics_version |
Name of the STICS version (VX.Y format) |
target_version |
Name of the STICS version to upgrade files to (VX.Y format) |
check_version |
Perform version consistency with in stics_version input with the file version and finally checking if the upgrade is possible allowed to the target_version. If TRUE, param_gen_file is mandatory. |
overwrite |
logical (optional), TRUE for overwriting file if it exists, FALSE otherwise |
See SticsRFiles::get_stics_versions_compat() for listing versions
None
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") 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") )dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") 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") )
Upgrading _plt.xml file(s) to a newer version
upgrade_plt_xml( file, out_dir, param_newform_file, param_gen_file, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE, ... )upgrade_plt_xml( file, out_dir, param_newform_file, param_gen_file, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE, ... )
file |
Path of an plant (*_plt.xml) file or a vector of |
out_dir |
Output directory path of the generated files |
param_newform_file |
Path of the param_newform.xml file corresponding to the file version |
param_gen_file |
Path of the param_gen.xml file corresponding to the file version |
stics_version |
Name of the STICS version (VX.Y format) |
target_version |
Name of the STICS version to upgrade files to (VX.Y format) |
check_version |
Perform version consistency between |
overwrite |
logical (optional), TRUE for overwriting file if it exists, FALSE otherwise |
... |
Additional input arguments |
See get_stics_versions_compat() for listing versions
None
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_plt_xml( file = file.path(dir_path, "file_plt.xml"), out_dir = tempdir(), param_newform_file = file.path(dir_path, "param_newform.xml"), param_gen_file = file.path(dir_path, "param_gen.xml") )dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_plt_xml( file = file.path(dir_path, "file_plt.xml"), out_dir = tempdir(), param_newform_file = file.path(dir_path, "param_newform.xml"), param_gen_file = file.path(dir_path, "param_gen.xml") )
Upgrading a sols.xml file to a newer version
upgrade_sols_xml( file, out_dir, param_gen_file, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE )upgrade_sols_xml( file, out_dir, param_gen_file, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE )
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 |
stics_version |
Name of the STICS version (VX.Y format) |
target_version |
Name of the STICS version to upgrade files to (VX.Y format) |
check_version |
Perform version consistency with in stics_version input with the file version and finally checking if the upgrade is possible allowed to the target_version. If TRUE, param_gen_file is mandatory. |
overwrite |
logical (optional), TRUE for overwriting file if it exists, FALSE otherwise |
See SticsRFiles::get_stics_versions_compat() for listing versions
None
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_sols_xml( file = file.path(dir_path, "sols.xml"), out_dir = tempdir(), param_gen_file = file.path(dir_path, "param_gen.xml") )dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_sols_xml( file = file.path(dir_path, "sols.xml"), out_dir = tempdir(), param_gen_file = file.path(dir_path, "param_gen.xml") )
Upgrading _sta.xml file(s) to a newer version
upgrade_sta_xml( file, out_dir, param_gen_file, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE, ... )upgrade_sta_xml( file, out_dir, param_gen_file, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE, ... )
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 |
stics_version |
Name of the STICS version (VX.Y format) |
target_version |
Name of the STICS version to upgrade files to (VX.Y format) |
check_version |
Perform version consistency with in stics_version input with the file version and finally checking if the upgrade is possible allowed to the target_version. If TRUE, param_gen_file is mandatory. |
overwrite |
logical (optional), TRUE for overwriting file if it exists, FALSE otherwise |
... |
Additional input arguments |
See SticsRFiles::get_stics_versions_compat() for listing versions
None
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_sta_xml( file = file.path(dir_path, "file_sta.xml"), out_dir = tempdir(), param_gen_file = file.path(dir_path, "param_gen.xml") )dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_sta_xml( file = file.path(dir_path, "file_sta.xml"), out_dir = tempdir(), param_gen_file = file.path(dir_path, "param_gen.xml") )
Upgrading _tec.xml file(s) to a newer version
upgrade_tec_xml( file, out_dir, param_newform_file, param_gen_file, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE, ... )upgrade_tec_xml( file, out_dir, param_newform_file, param_gen_file, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE, ... )
file |
Path of a crop management (*_tec.xml) file or a vector of |
out_dir |
Output directory path of the generated files |
param_newform_file |
Path of the param_newform.xml file corresponding to the file version |
param_gen_file |
Path of the param_gen.xml file corresponding to the file version |
stics_version |
Name of the STICS version (VX.Y format) |
target_version |
Name of the STICS version to upgrade files to (VX.Y format) |
check_version |
Perform version consistency with in stics_version input with the file version and finally checking if the upgrade is possible allowed to the target_version. If TRUE, param_gen_file is mandatory. |
overwrite |
logical (optional), TRUE for overwriting file if it exists, FALSE otherwise |
... |
Additional input arguments |
See get_stics_versions_compat() for listing versions
None
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_tec_xml( file = file.path(dir_path, "file_tec.xml"), out_dir = tempdir(), param_newform_file = file.path(dir_path, "param_newform.xml"), param_gen_file = file.path(dir_path, "param_gen.xml") )dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_tec_xml( file = file.path(dir_path, "file_tec.xml"), out_dir = tempdir(), param_newform_file = file.path(dir_path, "param_newform.xml"), param_gen_file = file.path(dir_path, "param_gen.xml") )
Upgrading a usms.xml file to a newer version
upgrade_usms_xml( file, out_dir, param_gen_file, obs_dir = NULL, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE )upgrade_usms_xml( file, out_dir, param_gen_file, obs_dir = NULL, stics_version = "V9.2", target_version = "V10.0", check_version = TRUE, overwrite = FALSE )
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 |
obs_dir |
Directory path of the observation data files |
stics_version |
Name of the STICS version (VX.Y format) |
target_version |
Name of the STICS version to upgrade files to (VX.Y format) |
check_version |
Perform version consistency with in stics_version input with the file version and finally checking if the upgrade is possible allowed to the target_version. If TRUE, param_gen_file is mandatory. |
overwrite |
logical (optional), TRUE for overwriting file if it exists, FALSE otherwise |
See get_stics_versions_compat() for listing versions
None
dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_usms_xml( file = file.path(dir_path, "usms.xml"), out_dir = tempdir(), param_gen_file = file.path(dir_path, "param_gen.xml") )dir_path <- get_examples_path(file_type = "xml", stics_version = "V9.2") upgrade_usms_xml( file = file.path(dir_path, "usms.xml"), out_dir = tempdir(), param_gen_file = file.path(dir_path, "param_gen.xml") )
Upgrading XML files of a JavaSTICS workspace directory to a newer STICS version format
upgrade_workspace_xml( workspace, javastics, out_dir, stics_version = "V9.2", target_version = "V10.0", plant = FALSE, overwrite = FALSE, ... )upgrade_workspace_xml( workspace, javastics, out_dir, stics_version = "V9.2", target_version = "V10.0", plant = FALSE, overwrite = FALSE, ... )
workspace |
Path of a JavaSTICS workspace |
javastics |
Path of JavaSTICS containing the STICS version corresponding to the version of the files to be converted |
out_dir |
Output directory of the generated files |
stics_version |
Name of the STICS version (VX.Y format) |
target_version |
Name of the STICS version to upgrade files to (VX.Y format) |
plant |
logical (optional), TRUE for upgrading plant files if a "plant" sub-directory of workspace exists, FALSE otherwise |
overwrite |
logical (optional), TRUE for overwriting files if they exist, FALSE otherwise |
... |
Additional input arguments |
See SticsRFiles::get_stics_versions_compat() for listing versions
If general parameters files exist in workspace, they are also upgraded.
In that case, residues parameters values are kept and might not be adapted
to the target model version.
Weather data and observations files are fully copied to out_dir
None
## Not run: upgrade_workspace_xml( workspace = "/path/to/JavaSTICS/workspace", javastics = "/path/to/JavaSTICS/folder", out_dir = "/path/to/an/output/directory" ) ## End(Not run)## Not run: upgrade_workspace_xml( workspace = "/path/to/JavaSTICS/workspace", javastics = "/path/to/JavaSTICS/folder", out_dir = "/path/to/an/output/directory" ) ## End(Not run)